-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaststatements.h
153 lines (124 loc) · 2.69 KB
/
aststatements.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#pragma once
#include "astexpressions.h"
class statement : public ast
{
private:
public:
statement()
{ }
};
class statementlist : public ast
{
private:
astnodelist<statement*> statements;
bool repeat;
public:
statementlist()
{ }
void addStatement(statement* st)
{ statements.add(st); }
virtual void debug(int ind);
virtual registerid generateCode(operation* &p);
virtual void semanticCheck();
void setRepeat(bool val)
{ repeat = val; }
bool repeats()
{ return repeat; }
astnodelist<statement*> getNodeList()
{ return statements; }
};
class letstatement : public statement
{
private:
expression* lv;
expression* value;
public:
letstatement(expression* _lv, expression* vl)
: lv(_lv)
, value(vl)
{ }
virtual void debug(int ind);
virtual registerid generateCode(operation* &p);
virtual void semanticCheck();
virtual ~letstatement();
};
class callstatement : public statement
{
private:
symbolid n;
expression* e;
public:
callstatement(symbolid _s, expression* _e)
: n(_s)
, e(_e)
{ }
virtual void debug(int ind);
virtual registerid generateCode(operation* &p);
virtual void semanticCheck();
virtual ~callstatement()
{ delete e; }
};
class dostatement : public statement
{
private:
expression* condexp;
statementlist* allstatements;
public:
dostatement(expression* exp, statementlist* lst)
: condexp(exp)
, allstatements(lst)
{ }
dostatement(statementlist* lst)
: condexp(0)
, allstatements(lst)
{ }
virtual void debug(int ind);
virtual registerid generateCode(operation* &p);
virtual expression* getConditional()
{ return condexp; }
virtual void semanticCheck();
virtual ~dostatement();
};
class choosestatement : public statement
{
private:
statementlist* allstatements;
public:
choosestatement(statementlist* lst)
: allstatements(lst)
{ }
virtual void debug(int ind);
virtual registerid generateCode(operation* &p);
virtual void semanticCheck();
virtual ~choosestatement();
};
class expressionstatement : public statement
{
private:
expression* expr;
public:
expressionstatement(expression* x)
: expr(x)
{ }
virtual void debug(int ind);
virtual registerid generateCode(operation* &p);
virtual void semanticCheck();
virtual ~expressionstatement();
};
/*
class returnstatement : public statement
{
private:
typespec* t;
expression* value; // this expression needs to evaluate to an object reference.
public:
returnstatement(typespec* tt, expression* x)
: t(tt)
, value(x)
{ }
virtual void debug(int ind);
virtual registerid generateCode(operation* &p);
virtual void semanticCheck();
virtual ~returnstatement();
};
*/