summaryrefslogtreecommitdiff
path: root/node/StatementNode.hh
blob: 1bd0cb668f197128b69f2bccac46f74e9c91c10a (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
#ifndef PCC_STATEMENTNODE_HH
#define PCC_STATEMENTNODE_HH

#include <memory>

#include "BaseNode.hh"
#include "ExprNode.hh"

namespace pcc {
using StatementListNode = ListNode<std::shared_ptr<BaseNode>>;

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_;
};
} // namespace pcc

#endif