-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable.h
57 lines (48 loc) · 1.09 KB
/
table.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
/*
* table.h -- symbol table
*/
#ifndef _TABLE_H_
#define _TABLE_H_
#define ENTRY_KIND_TYPE 0
#define ENTRY_KIND_VAR 1
#define ENTRY_KIND_PROC 2
typedef struct {
int kind;
union {
struct {
Type *type;
} typeEntry;
struct {
Type *type;
boolean isRef;
int offset;
} varEntry;
struct {
ParamTypes *paramTypes;
int paramSize; /* eingehende Argumente */
int argSize; /* ausgehende Argumente */
int localVarSize; /* lokale Variable */
struct table *localTable;
} procEntry;
} u;
} Entry;
typedef struct bintree {
Sym *sym;
unsigned key;
Entry *entry;
struct bintree *left;
struct bintree *right;
} Bintree;
typedef struct table {
Bintree *bintree;
struct table *upperLevel;
} Table;
Entry *newTypeEntry(Type * type);
Entry *newVarEntry(Type * type, boolean isRef);
Entry *newProcEntry(ParamTypes * paramTypes, Table * localTable);
Table *newTable(Table * upperLevel);
Entry *enter(Table * table, Sym * sym, Entry * entry);
Entry *lookup(Table * table, Sym * sym);
void showEntry(Entry * entry);
void showTable(Table * table);
#endif /* _TABLE_H_ */