blob: 66c2517a8c3128b528849eeaeb5b357551d68684 (
plain)
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
|
#ifndef PCC_STATEMENTNODE_HH
#define PCC_STATEMENTNODE_HH
#include <memory>
#include "BaseNode.hh"
#include "ExprNode.hh"
namespace pcc {
class StatementListNode : public BaseNode {
public:
StatementListNode(Context* context);
void Append(std::shared_ptr<BaseNode> child);
virtual Value CodeGen();
private:
std::list<std::shared_ptr<BaseNode>> childs_;
};
class EmptyStatementNode : public BaseNode {
public:
EmptyStatementNode(Context* context);
virtual Value CodeGen() override;
};
class AssignStatementNode : public BaseNode {
public:
AssignStatementNode(Context* context, std::shared_ptr<ExprNode> lhs,
std::shared_ptr<ExprNode> rhs);
virtual Value CodeGen() override;
protected:
std::shared_ptr<ExprNode> lhs_;
std::shared_ptr<ExprNode> rhs_;
};
class IfStatementNode : public BaseNode {
public:
IfStatementNode(Context* context, std::shared_ptr<ExprNode> expr,
std::shared_ptr<BaseNode> ThenPart,
std::shared_ptr<BaseNode> ElsePart);
virtual Value CodeGen() override;
protected:
std::shared_ptr<ExprNode> expr_;
std::shared_ptr<BaseNode> ThenPart_;
std::shared_ptr<BaseNode> ElsePart_;
};
class WhileStatementNode : public BaseNode {
public:
WhileStatementNode(Context* context, std::shared_ptr<ExprNode> expr,
std::shared_ptr<BaseNode> WhileBody);
virtual Value CodeGen() override;
protected:
std::shared_ptr<ExprNode> expr_;
std::shared_ptr<BaseNode> WhileBody_;
};
class RepeatStatementNode : public BaseNode {
public:
RepeatStatementNode(Context* context, std::shared_ptr<ExprNode> expr,
std::shared_ptr<BaseNode> RepeatBody);
virtual Value CodeGen() override;
protected:
std::shared_ptr<ExprNode> expr_;
std::shared_ptr<BaseNode> RepeatBody_;
};
class BreakStatementNode : public BaseNode {
public:
BreakStatementNode(Context* context);
virtual Value CodeGen() override;
};
class ContinueStatementNode : public BaseNode {
public:
ContinueStatementNode(Context* context);
virtual Value CodeGen() override;
};
} // namespace pcc
#endif
|