-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsymbol.cpp
More file actions
54 lines (42 loc) · 835 Bytes
/
symbol.cpp
File metadata and controls
54 lines (42 loc) · 835 Bytes
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
#include "symbol.h"
Symbol::Symbol(const std::string& name, Type* type, SymbolKind kind): name(name), type(type), kind(kind) {}
Symbol::~Symbol() = default;
std::string Symbol::get_name() const {
return name;
}
Type* Symbol::get_type() const {
return type;
}
std::string Symbol::get_kind_name() const {
switch (kind) {
case 0:
return "VAR";
case 1:
return "TYPE";
case 2:
return "CONST";
default:
return "<unknown SymbolKind>";
}
}
SymbolKind Symbol::get_kind() const {
return kind;
}
void Symbol::set_ival(int ival) {
this->ival = ival;
}
int Symbol::get_ival() const {
return ival;
}
void Symbol::set_vreg(int vreg) {
this->vreg = vreg;
}
int Symbol::get_vreg() const {
return vreg;
}
void Symbol::set_offset(int offset) {
this->offset = offset;
}
int Symbol::get_offset() const {
return offset;
}