diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-03 16:24:07 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-03 16:24:07 +0000 |
commit | 522cc9d286c5d35ca25ebaa85374f5f9214a7f6e (patch) | |
tree | e4c944cce2fcd736834e35d8e5d06f984b57a976 /c_compiler/src/statement.cpp | |
parent | 446c2394ec8970198d645bbbb462c67b9e3f1b1e (diff) | |
download | Compiler-522cc9d286c5d35ca25ebaa85374f5f9214a7f6e.tar.gz Compiler-522cc9d286c5d35ca25ebaa85374f5f9214a7f6e.zip |
Still working on ast
Diffstat (limited to 'c_compiler/src/statement.cpp')
-rw-r--r-- | c_compiler/src/statement.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/c_compiler/src/statement.cpp b/c_compiler/src/statement.cpp new file mode 100644 index 0000000..e828eaa --- /dev/null +++ b/c_compiler/src/statement.cpp @@ -0,0 +1,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) {} |