-
Notifications
You must be signed in to change notification settings - Fork 0
/
semantic_struct.h
68 lines (59 loc) · 1.37 KB
/
semantic_struct.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
#ifndef _SEMANTIC_STRUCT_H_
#define _SEMANTIC_STRUCT_H_
#include "hashtable.h"
#include "list.h"
enum ConstantType {
CONSTANT_Utf8 = 1,
CONSTANT_Integer = 3,
CONSTANT_Float = 4,
CONSTANT_String = 8,
CONSTANT_NameAndType = 12,
CONSTANT_Class = 7,
CONSTANT_Fieldref = 9,
CONSTANT_Methodref = 10
};
struct Constant {
enum ConstantType type;
int intValue;
float floatValue;
char* utf8;
int id;
//constant for class name, in case method references or field references
struct Constant* const1;
//constant type name and type, in case method references or field references
struct Constant* const2;
};
struct LocalVariable {
int id;
struct SemanticType* semanticType;
char* name;
int scope;
bool isActive;
bool isMutable;
};
struct Field {
struct Constant* constFieldref;
struct SemanticType* type;
int id;
bool isMutable;
};
struct Method {
//method name, because class is unique
struct Constant* constMethodref;
//key: varname, value : LocalVariable
struct SemanticType* returnType;
List* localVariablesTable;
struct ParameterList* paramList;
struct FunctionDecl* functionDecl;
bool isStatic;
};
struct Class {
char* className;
//node of list : struct Constant*
List* constantsTable;
//key: char*, value: Field*;
HashTable* fieldsTable;
//key: char*, value: struct Method* ;
HashTable* methodsTable;
};
#endif //_SEMANTIC_STRUCT_H_