sourcepawn/compiler/sctracker.h
author Ruben Gonzalez <drifter01620@gmail.com>
Thu May 22 09:49:27 2014 -0400 (2014-05-22)
changeset 4378 568f4497ef4a
parent 1952 b7aa2b626807
permissions -rw-r--r--
Update CS:GO team score gamedata.
     1 #ifndef _INCLUDE_SOURCEPAWN_COMPILER_TRACKER_H_
     2 #define _INCLUDE_SOURCEPAWN_COMPILER_TRACKER_H_
     3 
     4 #define MEMUSE_STATIC      0
     5 #define MEMUSE_DYNAMIC     1
     6 
     7 typedef struct memuse_s {
     8   int type;   /* MEMUSE_STATIC or MEMUSE_DYNAMIC */
     9   int size;   /* size of array for static (0 for dynamic) */
    10   struct memuse_s *prev; /* previous block on the list */
    11 } memuse_t;
    12 
    13 typedef struct memuse_list_s {
    14   struct memuse_list_s *prev;   /* last used list */
    15   int list_id;
    16   memuse_t *head;               /* head of the current list */
    17 } memuse_list_t;
    18 
    19 typedef struct funcarg_s
    20 {
    21   int tagcount;
    22   int tags[sTAGS_MAX];
    23   int dimcount;
    24   cell dims[sDIMEN_MAX];
    25   int ident;
    26   int fconst;
    27   int ommittable;
    28 } funcarg_t;
    29 
    30 typedef struct functag_s
    31 {
    32   int ret_tag;
    33   int type;
    34   int argcount;
    35   int ommittable;
    36   funcarg_t args[sARGS_MAX];
    37   struct functag_s *next;
    38 } functag_t;
    39 
    40 typedef struct funcenum_s
    41 {
    42   int value;
    43   char name[sNAMEMAX+1];
    44   functag_t *first;
    45   functag_t *last;
    46   struct funcenum_s *next;
    47 } funcenum_t;
    48 
    49 typedef struct structarg_s
    50 {
    51   int tag;
    52   int dimcount;
    53   cell dims[sDIMEN_MAX];
    54   char name[sNAMEMAX+1];
    55   int fconst;
    56   int ident;
    57   unsigned int offs;
    58   int index;
    59 } structarg_t;
    60 
    61 typedef struct pstruct_s
    62 {
    63   int argcount;
    64   char name[sNAMEMAX+1];
    65   structarg_t **args;
    66   struct pstruct_s *next;
    67 } pstruct_t;
    68 
    69 /**
    70  * Pawn Structs
    71  */
    72 pstruct_t *pstructs_add(const char *name);
    73 void pstructs_free();
    74 pstruct_t *pstructs_find(const char *name);
    75 structarg_t *pstructs_addarg(pstruct_t *pstruct, const structarg_t *arg);
    76 structarg_t *pstructs_getarg(pstruct_t *pstruct, const char *member);
    77 
    78 /**
    79  * Function enumeration tags
    80  */
    81 void funcenums_free();
    82 funcenum_t *funcenums_add(const char *name);
    83 funcenum_t *funcenums_find_byval(int value);
    84 functag_t *functags_add(funcenum_t *en, functag_t *src);
    85 
    86 /**
    87  * Heap functions
    88  */
    89 void pushheaplist();
    90 memuse_list_t *popsaveheaplist();
    91 void popheaplist();
    92 int markheap(int type, int size);
    93 
    94 /**
    95  * Stack functions
    96  */
    97 void pushstacklist();
    98 void popstacklist(int codegen);
    99 int markstack(int type, int size);
   100 /**
   101  * Generates code to free mem usage, but does not pop the list.  
   102  *  This is used for code like dobreak()/docont()/doreturn().
   103  * stop_id is the list at which to stop generating.
   104  */
   105 void genstackfree(int stop_id);
   106 void genheapfree(int stop_id);
   107 
   108 /**
   109  * Resets a mem list by freeing everything
   110  */
   111 void resetstacklist();
   112 void resetheaplist();
   113 
   114 extern memuse_list_t *heapusage;
   115 extern memuse_list_t *stackusage;
   116 
   117 #endif //_INCLUDE_SOURCEPAWN_COMPILER_TRACKER_H_