Skip to content

Commit

Permalink
Move compute_method_name to CodegenCppVisitor. (#1114)
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc authored Dec 8, 2023
1 parent 85b0dfc commit b6801af
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");
}


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 b6801af

Please sign in to comment.