8 #include <unordered_set>
25 const auto& blocks =
node.get_blocks();
29 std::unordered_set<ast::Node*> blocks_to_delete;
30 for (
auto& block: blocks) {
31 if (block->is_initial_block()) {
32 auto statement_block =
33 std::static_pointer_cast<ast::InitialBlock>(block)->get_statement_block();
35 if (statement_block) {
36 for (
const auto& statement: statement_block->get_statements()) {
37 statements.push_back(statement);
40 blocks_to_delete.insert(block.get());
47 node.emplace_back_node(new_initial_block.clone());
50 node.erase_node(blocks_to_delete);
Auto generated AST classes declaration.
Represents a INITIAL block in the NMODL.
Represents top level AST node for whole NMODL input.
Represents block encapsulating list of statements.
void visit_program(ast::Program &node) override
visit node of type ast::Program
@ INITIAL_BLOCK
type of ast::InitialBlock
std::vector< std::shared_ptr< Statement > > StatementVector
Visitor which merges all INITIAL blocks into one.
encapsulates code generation backend implementations
std::vector< std::shared_ptr< const ast::Ast > > collect_nodes(const ast::Ast &node, const std::vector< ast::AstNodeType > &types)
traverse node recursively and collect nodes of given types
static Node * node(Object *)
Utility functions for visitors implementation.