Skip to content

Commit

Permalink
Move compute_method_name to CodegenCppVisitor.
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc committed Dec 7, 2023
1 parent 7265ec9 commit b36d811
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 30 deletions.
23 changes: 0 additions & 23 deletions src/codegen/codegen_coreneuron_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,29 +497,6 @@ void CodegenCoreneuronCppVisitor::print_abort_routine() const {
}


std::string CodegenCoreneuronCppVisitor::compute_method_name(BlockType type) const {
if (type == BlockType::Initial) {
return method_name(naming::NRN_INIT_METHOD);
}
if (type == BlockType::Constructor) {
return method_name(naming::NRN_CONSTRUCTOR_METHOD);
}
if (type == BlockType::Destructor) {
return method_name(naming::NRN_DESTRUCTOR_METHOD);
}
if (type == BlockType::State) {
return method_name(naming::NRN_STATE_METHOD);
}
if (type == BlockType::Equation) {
return method_name(naming::NRN_CUR_METHOD);
}
if (type == BlockType::Watch) {
return method_name(naming::NRN_WATCH_CHECK_METHOD);
}
throw std::logic_error("compute_method_name not implemented");
}


void CodegenCoreneuronCppVisitor::print_global_var_struct_decl() {
printer->add_line(global_struct(), ' ', global_struct_instance(), ';');
}
Expand Down
7 changes: 0 additions & 7 deletions src/codegen/codegen_coreneuron_cpp_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,13 +370,6 @@ class CodegenCoreneuronCppVisitor: public CodegenCppVisitor {
virtual void print_abort_routine() const;


/**
* Return the name of main compute kernels
* \param type A block type
*/
virtual std::string compute_method_name(BlockType type) const;


/**
* Instantiate global var instance
*
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 @@ -911,6 +911,28 @@ void CodegenCppVisitor::setup(const Program& node) {
rename_function_arguments();
}

std::string CodegenCppVisitor::compute_method_name(BlockType type) const {
if (type == BlockType::Initial) {
return method_name(naming::NRN_INIT_METHOD);
}
if (type == BlockType::Constructor) {
return method_name(naming::NRN_CONSTRUCTOR_METHOD);
}
if (type == BlockType::Destructor) {
return method_name(naming::NRN_DESTRUCTOR_METHOD);
}
if (type == BlockType::State) {
return method_name(naming::NRN_STATE_METHOD);
}
if (type == BlockType::Equation) {
return method_name(naming::NRN_CUR_METHOD);
}
if (type == BlockType::Watch) {
return method_name(naming::NRN_WATCH_CHECK_METHOD);
}
throw std::logic_error("compute_method_name not implemented");

Check warning on line 933 in src/codegen/codegen_cpp_visitor.cpp

View check run for this annotation

Codecov / codecov/patch

src/codegen/codegen_cpp_visitor.cpp#L933

Added line #L933 was not covered by tests
}


void CodegenCppVisitor::visit_program(const Program& node) {
setup(node);
Expand Down
1 change: 1 addition & 0 deletions src/codegen/codegen_cpp_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,7 @@ class CodegenCppVisitor: public visitor::ConstAstVisitor {
void visit_mutex_lock(const ast::MutexLock& node) override;
void visit_mutex_unlock(const ast::MutexUnlock& node) override;

std::string compute_method_name(BlockType type) const;

public:
/** Setup the target backend code generator
Expand Down

0 comments on commit b36d811

Please sign in to comment.