-
Notifications
You must be signed in to change notification settings - Fork 37
/
symbol.h
131 lines (111 loc) · 2.36 KB
/
symbol.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//**************************************************************************
//**
//** symbol.h
//**
//**************************************************************************
#ifndef __SYMBOL_H__
#define __SYMBOL_H__
// HEADER FILES ------------------------------------------------------------
#include "common.h"
#include "pcode.h"
// MACROS ------------------------------------------------------------------
#define MAX_ARRAY_DIMS 8
// TYPES -------------------------------------------------------------------
typedef enum
{
SY_DUMMY,
SY_LABEL,
SY_SCRIPTVAR,
SY_SCRIPTALIAS,
SY_MAPVAR,
SY_WORLDVAR,
SY_GLOBALVAR,
SY_SCRIPTARRAY,
SY_MAPARRAY,
SY_WORLDARRAY,
SY_GLOBALARRAY,
SY_SPECIAL,
SY_CONSTANT,
SY_INTERNFUNC,
SY_SCRIPTFUNC
} symbolType_t;
typedef struct
{
U_BYTE index;
} symVar_t;
typedef struct
{
U_BYTE index;
int dimensions[MAX_ARRAY_DIMS];
int ndim;
int size;
} symArray_t;
typedef struct
{
int address;
} symLabel_t;
typedef struct
{
int value;
int argCount;
} symSpecial_t;
typedef struct
{
int value;
char *strValue;
int fileDepth;
} symConstant_t;
typedef struct
{
pcd_t directCommand;
pcd_t stackCommand;
int argCount;
int optMask;
int outMask;
boolean hasReturnValue;
boolean latent;
} symInternFunc_t;
typedef struct
{
int address;
int argCount;
int varCount;
int funcNumber;
boolean hasReturnValue;
int sourceLine;
char *sourceName;
boolean predefined;
} symScriptFunc_t;
typedef struct symbolNode_s
{
struct symbolNode_s *left;
struct symbolNode_s *right;
char *name;
symbolType_t type;
boolean unused;
boolean imported;
union
{
symVar_t var;
symArray_t array;
symLabel_t label;
symSpecial_t special;
symConstant_t constant;
symInternFunc_t internFunc;
symScriptFunc_t scriptFunc;
} info;
} symbolNode_t;
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
void SY_Init(void);
symbolNode_t *SY_Find(char *name);
symbolNode_t *SY_FindLocal(char *name);
symbolNode_t *SY_FindGlobal(char *name);
symbolNode_t *SY_InsertLocal(char *name, symbolType_t type);
symbolNode_t *SY_InsertGlobal(char *name, symbolType_t type);
symbolNode_t *SY_InsertGlobalUnique(char *name, symbolType_t type);
void SY_FreeLocals(void);
void SY_FreeGlobals(void);
void SY_FreeConstants(int depth);
void SY_ClearShared(void);
// PUBLIC DATA DECLARATIONS ------------------------------------------------
#endif