-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasttyping.h
90 lines (74 loc) · 1.4 KB
/
asttyping.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
#pragma once
#include "ast.h"
/////////////// typing
class aExpr : public ast
{
private:
symbolid sid;
public:
aExpr(symbolid id)
: sid(id)
{ }
aExpr(string id);
virtual void debug(int ind);
virtual registerid generateCode(operation* &p);
virtual void semanticCheck();
virtual int getSize()
{ return 1; }
virtual int getSymbolid()
{ return sid; }
};
class arrayAExpr : public aExpr
{
public:
aExpr* t;
int n;
arrayAExpr(int nvals, aExpr* tt)
: aExpr(-1)
, t(tt)
, n(nvals)
{ }
virtual int getSize()
{ return n * t->getSize(); }
virtual int getSymbolid()
{
cout << "not implemented: arrayAExpr" << endl;
exit(1);
}
virtual ~arrayAExpr();
};
class preposition : public ast
{
private:
symbolid name;
aExpr* atype;
public:
preposition(symbolid n, aExpr* a)
: name(n)
, atype(a)
{ }
preposition(symbolid n)
: name(n)
, atype(0)
{ }
virtual void debug(int ind);
virtual registerid generateCode(operation* &p);
virtual void semanticCheck();
virtual ~preposition();
symbolid getName()
{ return name; }
};
class preplist : public ast
{
private:
astnodelist<preposition*> preps;
public:
preplist()
{ }
void addPreposition(preposition* p)
{ preps.add(p); }
virtual void debug(int ind);
virtual registerid generateCode(operation* &p);
virtual void semanticCheck();
vector<type*> getTypes();
};