-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIf_Statement.hpp
57 lines (44 loc) · 902 Bytes
/
If_Statement.hpp
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
#pragma once
#include "SyntaxTree.hpp"
#include "Conditional_Statement.hpp"
namespace compiler
{
class If_Statement : public Conditional_Statement
{
public:
If_Statement(SyntaxTree* Condition, SyntaxTree* Statements)
{
condition.push_back(Condition);
children.push_back(Statements);
}
virtual ~If_Statement()
{
}
virtual std::string toCode() const
{
std::string code = "if(";
for(SyntaxTree* node : condition)
{
if(node != nullptr)
{
if( node->toCode() == "Sylvanas_Rules_Forsaken" )
code += "true";
else if( node->toCode() == "Arthas_Rules_Forsaken" )
code += "false";
else
code += node->toCode();
}
}
code += ")\n{\n";
for(SyntaxTree *node : children)
{
if(node != nullptr)
code += node->toCode();
}
code += "}\n";
return code;
}
protected:
private:
};
}