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