Skip to content

Commit

Permalink
Lift shared print_top_verbatim_blocks code.
Browse files Browse the repository at this point in the history
Both the NEURON and CoreNEURON codegen need the same code for printing
all top-level verbatim blocks.
  • Loading branch information
1uc committed Oct 29, 2024
1 parent 31a6c48 commit 6af6b93
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 28 deletions.
22 changes: 0 additions & 22 deletions src/codegen/codegen_coreneuron_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,28 +346,6 @@ void CodegenCoreneuronCppVisitor::print_abort_routine() const {
/****************************************************************************************/


void CodegenCoreneuronCppVisitor::print_top_verbatim_blocks() {
if (info.top_verbatim_blocks.empty()) {
return;
}
print_namespace_stop();

printer->add_newline(2);
print_using_namespace();

printing_top_verbatim_blocks = true;

for (const auto& block: info.top_verbatim_blocks) {
printer->add_newline(2);
block->accept(*this);
}

printing_top_verbatim_blocks = false;

print_namespace_start();
}


void CodegenCoreneuronCppVisitor::print_function_prototypes() {
if (info.functions.empty() && info.procedures.empty()) {
return;
Expand Down
6 changes: 0 additions & 6 deletions src/codegen/codegen_coreneuron_cpp_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,6 @@ class CodegenCoreneuronCppVisitor: public CodegenCppVisitor {
/****************************************************************************************/


/**
* Print top level (global scope) verbatim blocks
*/
void print_top_verbatim_blocks();


/**
* Print function and procedures prototype declaration
*/
Expand Down
22 changes: 22 additions & 0 deletions src/codegen/codegen_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,28 @@ void CodegenCppVisitor::print_namespace_stop() {
}


void CodegenCppVisitor::print_top_verbatim_blocks() {
if (info.top_verbatim_blocks.empty()) {
return;
}
print_namespace_stop();

printer->add_newline(2);
print_using_namespace();

printing_top_verbatim_blocks = true;

for (const auto& block: info.top_verbatim_blocks) {
printer->add_newline(2);
block->accept(*this);
}

printing_top_verbatim_blocks = false;

print_namespace_start();
}


/****************************************************************************************/
/* Printing routines for code generation */
/****************************************************************************************/
Expand Down
5 changes: 5 additions & 0 deletions src/codegen/codegen_cpp_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,11 @@ class CodegenCppVisitor: public visitor::ConstAstVisitor {
*/
void print_nmodl_constants();

/**
* Print top level (global scope) verbatim blocks
*/
void print_top_verbatim_blocks();


/****************************************************************************************/
/* Overloaded visitor routines */
Expand Down

0 comments on commit 6af6b93

Please sign in to comment.