diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-23 20:57:32 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-23 20:57:32 +0000 |
commit | 64d1100ea5a2f749db3a635d5fb2a688a551ecb7 (patch) | |
tree | 1acde757b3a39d0f7536faa42b1366ccb4b10f37 /c_compiler/src/statement.cpp | |
parent | 5e2dbac8d63b3a0031069495a0e1dafe825aba45 (diff) | |
download | Compiler-64d1100ea5a2f749db3a635d5fb2a688a551ecb7.tar.gz Compiler-64d1100ea5a2f749db3a635d5fb2a688a551ecb7.zip |
Adding more tests and fixing
Diffstat (limited to 'c_compiler/src/statement.cpp')
-rw-r--r-- | c_compiler/src/statement.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/c_compiler/src/statement.cpp b/c_compiler/src/statement.cpp index e5fd369..c266140 100644 --- a/c_compiler/src/statement.cpp +++ b/c_compiler/src/statement.cpp @@ -65,6 +65,8 @@ VariableStackBindings LabelStatement::printAsm(VariableStackBindings bindings, u printf("%s:\n", label_.c_str()); + statement_->printAsm(bindings, label_count); + return bindings; } @@ -468,7 +470,7 @@ VariableStackBindings SwitchStatement::printAsm(VariableStackBindings bindings, if((*itr)->isDefault()) printf("$%d_default_switch:\n", switch_count); - + (*itr)->linkStatement(nullptr); (*itr)->printAsm(bindings, label_count); } @@ -693,8 +695,11 @@ void ReturnStatement::countExpressionDepth(unsigned &depth_count) const BreakStatement::BreakStatement() {} -VariableStackBindings BreakStatement::printAsm(VariableStackBindings bindings, unsigned &) const +VariableStackBindings BreakStatement::printAsm(VariableStackBindings bindings, unsigned &label_count) const { + if(next_statement_ != nullptr) + next_statement_->printAsm(bindings, label_count); + printf("\tb\t%s\n\tnop\n", bindings.breakLabel().c_str()); return bindings; } @@ -705,8 +710,11 @@ VariableStackBindings BreakStatement::printAsm(VariableStackBindings bindings, u ContinueStatement::ContinueStatement() {} -VariableStackBindings ContinueStatement::printAsm(VariableStackBindings bindings, unsigned &) const +VariableStackBindings ContinueStatement::printAsm(VariableStackBindings bindings, unsigned &label_count) const { + if(next_statement_ != nullptr) + next_statement_->printAsm(bindings, label_count); + printf("\tb\t%s\n\tnop\n", bindings.continueLabel().c_str()); return bindings; } @@ -718,8 +726,11 @@ GotoStatement::GotoStatement(const std::string &label) : label_(label) {} -VariableStackBindings GotoStatement::printAsm(VariableStackBindings bindings, unsigned &) const +VariableStackBindings GotoStatement::printAsm(VariableStackBindings bindings, unsigned &label_count) const { + if(next_statement_ != nullptr) + next_statement_->printAsm(bindings, label_count); + printf("\tb\t%s\n\tnop\n", label_.c_str()); return bindings; } |