Skip to content

Commit

Permalink
SOLVE procedure.
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc committed Oct 15, 2024
1 parent 367da97 commit a4b994e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/visitors/solve_block_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "utils/fmt.h"
#include <cassert>
#include <memory>

#include "ast/all.hpp"
#include "codegen/codegen_naming.hpp"
Expand Down Expand Up @@ -67,6 +68,14 @@ ast::SolutionExpression* SolveBlockVisitor::create_solution_expression(
return new ast::SolutionExpression(solve_block.clone(), callback_expr);
}

if (node_to_solve->get_node_type() == ast::AstNodeType::PROCEDURE_BLOCK) {
auto procedure_call = new ast::FunctionCall(solve_block.get_block_name()->clone(), {});
auto statement = std::make_shared<ast::ExpressionStatement>(procedure_call);
auto statement_block = new ast::StatementBlock({statement});

return new ast::SolutionExpression(solve_block.clone(), statement_block);
}

auto block_to_solve = node_to_solve->get_statement_block();
return new ast::SolutionExpression(solve_block.clone(), block_to_solve->clone());
}
Expand Down

0 comments on commit a4b994e

Please sign in to comment.