aboutsummaryrefslogtreecommitdiffstats
path: root/c_compiler/src/statement.cpp
blob: e828eaa2df93124c39f02678bb7f76ed44ff84de (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
#include "ast.hpp"


// General base Statement definition

Statement::Statement(const Base* _left, const Base* _right)
    : BaseNode(_left, _right) {}


// Statement list definition

StatementList::StatementList(const Base* _statement)
    : BaseList(_statement) {}


// Compound Statement definition

CompoundStatement::CompoundStatement(const Base* _dec, const Base* _statement)
    : Statement(_dec, _statement) {}

void CompoundStatement::printxml() const {
    std::cout << "<Scope>" << std::endl;
    leftNode->printxml();
    rightNode->printxml();
    std::cout << "</Scope>" << std::endl;
}


// Selection Statement definition

SelectionStatement::SelectionStatement(const Base* _if, const Base* _else)
    : Statement(_if, _else) {}


// Expression Statement definition

ExpressionStatement::ExpressionStatement(const Base* _expr)
    : Statement(_expr) {}


// Jump Statement definition

JumpStatement::JumpStatement(const Base* _el) : Statement(_el) {}

void JumpStatement::printasm() const {
    leftNode->printasm();
    std::cout << "\tlw\t$2,8($fp)" << std::endl;
}


// Iteration Statement definition

IterationStatement::IterationStatement(const Base* _el) : Statement(_el) {}