Skip to content

Commit

Permalink
fix #13
Browse files Browse the repository at this point in the history
  • Loading branch information
michael.burzan committed Jan 6, 2025
1 parent 9cc3633 commit cd863ba
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 0 additions & 1 deletion include/VirtualMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ template <class POLICY> class VirtualMachine {
old_pc = _pc;
std::visit(
[&](auto& instruction) {
std::cout << "STEP" << std::endl;
InstructionResult res = instruction.execute(this);
res.error([](const Error& err) {
std::cerr << "Instruction failed: " << err.msg() << "\n";
Expand Down
6 changes: 6 additions & 0 deletions src/Codegeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,23 @@ auto StatementVisitor::begin(const std::shared_ptr<StatementNode>& node) -> Visi
auto StatementVisitor::visit(const std::shared_ptr<StatementNode>& node) -> std::shared_ptr<Visitor> {
switch (node->statement_type()) {
case StatementType::RETURN_STATEMENT:
std::cout << "STATEMENT RET" << std::endl;
_return_statement_visitor = std::make_shared<ReturnStatementVisitor>(_local_variables);
return _return_statement_visitor;
case StatementType::VAR_DEC:
std::cout << "VAR DEC" << std::endl;
_var_dec_visitor = std::make_shared<VariableDeclarationVisitor>(_local_variables);
return _var_dec_visitor;
default:
return shared_from_this();
}
}
auto StatementVisitor::end(const std::shared_ptr<StatementNode>& node) -> VisitResult {
if (node->statement_type() == StatementType::VAR_DEC) {
std::cout << "VAR_DECLARATION" << std::endl;
}
if (node->statement_type() == StatementType::RETURN_STATEMENT) {
std::cout << "RETURN_STATEMENT" << std::endl;
_code.insert(_code.end(), _return_statement_visitor->code().begin(), _return_statement_visitor->code().end());
}
return true;
Expand Down
1 change: 0 additions & 1 deletion src/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ auto Parser::parse_statements() -> ParserResult {
if (!statement.result()) {
break; // Epsiolon production
}
statements.push_back(statement.result());
}
_context.pop();
return {std::make_shared<StatementsNode>(statements)};
Expand Down

0 comments on commit cd863ba

Please sign in to comment.