Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move compute_method_name to CodegenCppVisitor. #1114

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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);
}
iomaganaris marked this conversation as resolved.
Show resolved Hide resolved
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
Loading