nmodl::visitor::ConstVisitor.
-Definition at line 2253 of file codegen_neuron_cpp_visitor.cpp.
+Definition at line 2245 of file codegen_neuron_cpp_visitor.cpp.
diff --git a/doxygen/codegen__acc__visitor_8cpp_source.html b/doxygen/codegen__acc__visitor_8cpp_source.html
index db163c5ab..afb363e73 100644
--- a/doxygen/codegen__acc__visitor_8cpp_source.html
+++ b/doxygen/codegen__acc__visitor_8cpp_source.html
@@ -479,8 +479,8 @@
codegen::CodegenInfo info
All ast information for code generation.
std::string global_struct_instance() const
Name of the (host-only) global instance of global_struct
void print_deriv_advance_flag_transfer_to_device() const override
update derivimplicit advance flag on the gpu device
-int derivimplicit_list_num
slist/dlist id for derivimplicit block
-int thread_data_index
thread_data_index indicates number of threads being allocated.
+int derivimplicit_list_num
slist/dlist id for derivimplicit block
+int thread_data_index
thread_data_index indicates number of threads being allocated.
const char * operator_for_d() const noexcept
Operator for diagonal vector update (matrix update)
bool nrn_cur_reduction_loop_required() override
if reduction block in nrn_cur required
encapsulates code generation backend implementations
@@ -491,18 +491,18 @@
void print_atomic_reduction_pragma() override
atomic update pragma for reduction statements
Base class for all block scoped nodes.
void print_instance_struct_transfer_routine_declarations() override
declare helper functions for copying the instance struct to the device
-bool artificial_cell
if mod file is artificial cell
+bool artificial_cell
if mod file is artificial cell
@ Equation
breakpoint block
void print_nrn_cur_matrix_shadow_update() override
update to matrix elements with/without shadow vectors
void print_instance_struct_copy_to_device() override
call helper function for copying the instance struct to the device
void print_rhs_d_shadow_variables() override
setup method for setting matrix shadow vectors
virtual void print_memory_allocation_routine() const
Print memory allocation routine.
@ NetReceive
net_receive block
-bool point_process
if mod file is point process
+bool point_process
if mod file is point process
void print_dt_update_to_device() const override
update dt from host to device
std::string get_variable_name(const std::string &name, bool use_instance=true) const override
Determine variable name in the structure of mechanism properties.
void print_global_variable_device_update_annotation() override
update global variable from host to the device
-bool electrode_current
if electrode current specified
+bool electrode_current
if electrode current specified
void print_kernel_data_present_annotation_block_end() override
end of annotation like "acc enter data"
BlockType
Helper to represent various block types.
void print_abort_routine() const override
abort routine
diff --git a/doxygen/codegen__coreneuron__cpp__visitor_8hpp_source.html b/doxygen/codegen__coreneuron__cpp__visitor_8hpp_source.html
index 92d2b6bf0..a32501485 100644
--- a/doxygen/codegen__coreneuron__cpp__visitor_8hpp_source.html
+++ b/doxygen/codegen__coreneuron__cpp__visitor_8hpp_source.html
@@ -1166,7 +1166,7 @@
virtual void print_newtonspace_transfer_to_device() const
Print code block to transfer newtonspace structure to device.
CodegenCppVisitor(std::string mod_filename, const std::string &output_dir, std::string float_type, const bool optimize_ionvar_copies, std::unique_ptr< nmodl::utils::Blame > blame)
Constructs the C++ code generator visitor.
-int thread_data_index
thread_data_index indicates number of threads being allocated.
+int thread_data_index
thread_data_index indicates number of threads being allocated.
void print_namespace_end() override
Print end of namespaces.
void print_net_send_call(const ast::FunctionCall &node) override
Print call to net_send.
virtual void print_net_receive_loop_begin()
Print the code for the main net_receive loop.
@@ -1238,7 +1238,7 @@
virtual void print_rhs_d_shadow_variables()
Print the setup method for setting matrix shadow vectors.
std::string process_verbatim_text(std::string const &text) override
Process a verbatim block for possible variable renaming.
void print_net_receive()
Print net_receive function definition.
-bool vectorize
true if mod file is vectorizable (which should be always true for coreneuron) But there are some bloc...
+bool vectorize
true if mod file is vectorizable (which should be always true for coreneuron) But there are some bloc...
bool optimize_ion_variable_copies() const override
Check if ion variable copies should be avoided.
void print_function(const ast::FunctionBlock &node) override
Print NMODL function in target backend code.
void print_top_verbatim_blocks()
Print top level (global scope) verbatim blocks.
diff --git a/doxygen/codegen__cpp__visitor_8cpp_source.html b/doxygen/codegen__cpp__visitor_8cpp_source.html
index 4cd5ca86d..93641fb8b 100644
--- a/doxygen/codegen__cpp__visitor_8cpp_source.html
+++ b/doxygen/codegen__cpp__visitor_8cpp_source.html
@@ -168,8 +168,8 @@
-
- 76 return "lazy_update_";
+
+ 76 return "update_table_" + method_name(block_name);
@@ -1620,130 +1620,130 @@
1524 auto float_type = default_float_data_type();
1526 printer->add_newline(2);
- 1527 printer->fmt_push_block(
"void {}{}({})",
- 1528 table_function_prefix(),
-
- 1530 get_parameter_str(internal_params));
-
- 1532 printer->fmt_push_block(
"if ({} == 0)", use_table_var);
- 1533 printer->add_line(
"return;");
- 1534 printer->pop_block();
-
- 1536 printer->add_line(
"static bool make_table = true;");
- 1537 for (
const auto& variable: depend_variables) {
- 1538 printer->fmt_line(
"static {} save_{};", float_type, variable->get_node_name());
-
-
- 1541 for (
const auto& variable: depend_variables) {
- 1542 const auto& var_name = variable->get_node_name();
- 1543 const auto& instance_name = get_variable_name(var_name);
- 1544 printer->fmt_push_block(
"if (save_{} != {})", var_name, instance_name);
- 1545 printer->add_line(
"make_table = true;");
- 1546 printer->pop_block();
-
-
- 1549 printer->push_block(
"if (make_table)");
-
- 1551 printer->add_line(
"make_table = false;");
-
- 1553 printer->add_indent();
- 1554 printer->add_text(tmin_name,
" = ");
- 1555 from->accept(*
this);
- 1556 printer->add_text(
';');
- 1557 printer->add_newline();
-
- 1559 printer->add_indent();
- 1560 printer->add_text(
"double tmax = ");
-
- 1562 printer->add_text(
';');
- 1563 printer->add_newline();
+ 1527 printer->fmt_push_block(
"void {}({})",
+ 1528 table_update_function_name(name),
+ 1529 get_parameter_str(internal_params));
+
+ 1531 printer->fmt_push_block(
"if ({} == 0)", use_table_var);
+ 1532 printer->add_line(
"return;");
+ 1533 printer->pop_block();
+
+ 1535 printer->add_line(
"static bool make_table = true;");
+ 1536 for (
const auto& variable: depend_variables) {
+ 1537 printer->fmt_line(
"static {} save_{};", float_type, variable->get_node_name());
+
+
+ 1540 for (
const auto& variable: depend_variables) {
+ 1541 const auto& var_name = variable->get_node_name();
+ 1542 const auto& instance_name = get_variable_name(var_name);
+ 1543 printer->fmt_push_block(
"if (save_{} != {})", var_name, instance_name);
+ 1544 printer->add_line(
"make_table = true;");
+ 1545 printer->pop_block();
+
+
+ 1548 printer->push_block(
"if (make_table)");
+
+ 1550 printer->add_line(
"make_table = false;");
+
+ 1552 printer->add_indent();
+ 1553 printer->add_text(tmin_name,
" = ");
+ 1554 from->accept(*
this);
+ 1555 printer->add_text(
';');
+ 1556 printer->add_newline();
+
+ 1558 printer->add_indent();
+ 1559 printer->add_text(
"double tmax = ");
+
+ 1561 printer->add_text(
';');
+ 1562 printer->add_newline();
+
-
- 1566 printer->fmt_line(
"double dx = (tmax-{}) / {}.;", tmin_name, with);
- 1567 printer->fmt_line(
"{} = 1./dx;", mfac_name);
-
- 1569 printer->fmt_line(
"double x = {};", tmin_name);
- 1570 printer->fmt_push_block(
"for (std::size_t i = 0; i < {}; x += dx, i++)", with + 1);
- 1571 auto function = method_name(
"f_" + name);
-
- 1573 printer->fmt_line(
"{}({}, x);",
function, internal_method_arguments());
- 1574 for (
const auto& variable: table_variables) {
- 1575 auto var_name = variable->get_node_name();
- 1576 auto instance_name = get_variable_name(var_name);
- 1577 auto table_name = get_variable_name(
"t_" + var_name);
- 1578 auto [is_array, array_length] = check_if_var_is_array(var_name);
-
- 1580 for (
int j = 0; j < array_length; j++) {
-
- 1582 "{}[{}][i] = {}[{}];", table_name, j, instance_name, j);
-
-
- 1585 printer->fmt_line(
"{}[i] = {};", table_name, instance_name);
-
-
-
- 1589 auto table_name = get_variable_name(
"t_" + name);
- 1590 printer->fmt_line(
"{}[i] = {}({}, x);",
-
-
- 1593 internal_method_arguments());
-
- 1595 printer->pop_block();
-
- 1597 for (
const auto& variable: depend_variables) {
- 1598 auto var_name = variable->get_node_name();
- 1599 auto instance_name = get_variable_name(var_name);
- 1600 printer->fmt_line(
"save_{} = {};", var_name, instance_name);
-
-
- 1603 printer->pop_block();
-
- 1605 printer->pop_block();
-
-
-
- 1609 const std::unordered_set<CppObjectSpecifier>& specifiers) {
-
- 1611 for (
const auto& specifier: specifiers) {
- 1612 if (!result.empty()) {
-
-
- 1615 result += object_specifier_map[specifier];
-
-
-
-
-
- 1621 const auto& table_statements =
collect_nodes(node, {AstNodeType::TABLE_STATEMENT});
-
- 1623 if (table_statements.size() != 1) {
- 1624 auto message = fmt::format(
"One table statement expected in {} found {}",
-
- 1626 table_statements.size());
- 1627 throw std::runtime_error(message);
-
-
-
+ 1565 printer->fmt_line(
"double dx = (tmax-{}) / {}.;", tmin_name, with);
+ 1566 printer->fmt_line(
"{} = 1./dx;", mfac_name);
+
+ 1568 printer->fmt_line(
"double x = {};", tmin_name);
+ 1569 printer->fmt_push_block(
"for (std::size_t i = 0; i < {}; x += dx, i++)", with + 1);
+ 1570 auto function = method_name(
"f_" + name);
+
+ 1572 printer->fmt_line(
"{}({}, x);",
function, internal_method_arguments());
+ 1573 for (
const auto& variable: table_variables) {
+ 1574 auto var_name = variable->get_node_name();
+ 1575 auto instance_name = get_variable_name(var_name);
+ 1576 auto table_name = get_variable_name(
"t_" + var_name);
+ 1577 auto [is_array, array_length] = check_if_var_is_array(var_name);
+
+ 1579 for (
int j = 0; j < array_length; j++) {
+
+ 1581 "{}[{}][i] = {}[{}];", table_name, j, instance_name, j);
+
+
+ 1584 printer->fmt_line(
"{}[i] = {};", table_name, instance_name);
+
+
+
+ 1588 auto table_name = get_variable_name(
"t_" + name);
+ 1589 printer->fmt_line(
"{}[i] = {}({}, x);",
+
+
+ 1592 internal_method_arguments());
+
+ 1594 printer->pop_block();
+
+ 1596 for (
const auto& variable: depend_variables) {
+ 1597 auto var_name = variable->get_node_name();
+ 1598 auto instance_name = get_variable_name(var_name);
+ 1599 printer->fmt_line(
"save_{} = {};", var_name, instance_name);
+
+
+ 1602 printer->pop_block();
+
+ 1604 printer->pop_block();
+
+
+
+ 1608 const std::unordered_set<CppObjectSpecifier>& specifiers) {
+
+ 1610 for (
const auto& specifier: specifiers) {
+ 1611 if (!result.empty()) {
+
+
+ 1614 result += object_specifier_map[specifier];
+
+
+
+
+
+ 1620 const auto& table_statements =
collect_nodes(node, {AstNodeType::TABLE_STATEMENT});
+
+ 1622 if (table_statements.size() != 1) {
+ 1623 auto message = fmt::format(
"One table statement expected in {} found {}",
+
+ 1625 table_statements.size());
+ 1626 throw std::runtime_error(message);
+
+
+
+
-
-
- 1634 auto symbol = program_symtab->lookup_in_scope(name);
-
- 1636 throw std::runtime_error(
- 1637 fmt::format(
"CodegenCppVisitor:: {} not found in symbol table!", name));
-
- 1639 if (symbol->is_array()) {
- 1640 return {
true, symbol->get_length()};
-
-
-
-
-
-
+
+ 1633 auto symbol = program_symtab->lookup_in_scope(name);
+
+ 1635 throw std::runtime_error(
+ 1636 fmt::format(
"CodegenCppVisitor:: {} not found in symbol table!", name));
+
+ 1638 if (symbol->is_array()) {
+ 1639 return {
true, symbol->get_length()};
+
+
+
+
+
+
std::string get_node_name() const override
Return name of the node.
std::shared_ptr< Expression > get_length() const noexcept
Getter for member variable IndexedName::length.
+std::string table_update_function_name(const std::string &block_name) const
The name of the function that updates the table value if the parameters changed.
void visit_eigen_linear_solver_block(const ast::EigenLinearSolverBlock &node) override
visit node of type ast::EigenLinearSolverBlock
bool ion_variable_struct_required() const
Check if a structure for ion variables is required.
static bool need_semicolon(const ast::Statement &node)
Check if a semicolon is required at the end of given statement.
@@ -1800,7 +1800,6 @@
void print_statement_block(const ast::StatementBlock &node, bool open_brace=true, bool close_brace=true)
Print any statement block in nmodl with option to (not) print braces.
const std::string & get_value() const noexcept
Getter for member variable Double::value.
StatementVector::const_iterator insert_statement(StatementVector::const_iterator position, const std::shared_ptr< Statement > &n)
Insert member to statements.
-std::string table_function_prefix() const
Prefix used for the function that performs the lazy update.
virtual bool is_procedure_block() const noexcept
Check if the ast node is an instance of ast::ProcedureBlock.
Represents TABLE statement in NMODL.
@@ -1808,7 +1807,7 @@
void visit_binary_expression(const ast::BinaryExpression &node) override
visit node of type ast::BinaryExpression
Represents an integer variable.
-std::string get_object_specifiers(const std::unordered_set< CppObjectSpecifier > &)
+std::string get_object_specifiers(const std::unordered_set< CppObjectSpecifier > &)
std::vector< SymbolType > get_float_variables() const
Determine all float variables required during code generation.
virtual bool is_expression_statement() const noexcept
Check if the ast node is an instance of ast::ExpressionStatement.
@@ -1882,7 +1881,7 @@
bool net_send_buffer_required() const noexcept
Check if net_send_buffer is required.
void visit_float(const ast::Float &node) override
visit node of type ast::Float
void visit_string(const ast::String &node) override
visit node of type ast::String
-Represent semantic information for index variable.
+Represent semantic information for index variable.
std::string to_string(const T &obj)
virtual bool is_block_comment() const noexcept
Check if the ast node is an instance of ast::BlockComment.
@@ -1894,7 +1893,7 @@
virtual void print_global_var_struct_decl()
Instantiate global var instance.
static constexpr char AREA_SEMANTIC[]
semantic type for area variable
void visit_var_name(const ast::VarName &node) override
-std::string mod_file
name of mod file
+std::string mod_file
name of mod file
void print_nmodl_constants()
Print the nmodl constants used in backend code.
std::shared_ptr< Expression > get_expression() const noexcept
Getter for member variable ParenExpression::expression.
const BinaryOperator & get_op() const noexcept
Getter for member variable BinaryExpression::op.
@@ -1915,7 +1914,7 @@
std::string eval() const
Return enum value in string form.
virtual bool is_mutex_unlock() const noexcept
Check if the ast node is an instance of ast::MutexUnlock.
@ LOCAL_VAR
type of ast::LocalVar
-codegen::CodegenInfo analyze(const ast::Program &node)
run visitor and return information for code generation
+codegen::CodegenInfo analyze(const ast::Program &node)
run visitor and return information for code generation
std::shared_ptr< StatementBlock > get_statement_block() const noexcept override
Getter for member variable WhileStatement::statement_block.
void visit_integer(const ast::Integer &node) override
visit node of type ast::Integer
Represent linear solver solution block based on Eigen.
@@ -1923,10 +1922,10 @@
Visitor to return Def-Use chain for a given variable in the block/node
Statement to indicate a change in timestep in a given block.
std::shared_ptr< StatementBlock > get_functor_block() const noexcept
Getter for member variable EigenNewtonSolverBlock::functor_block.
-const ast::TableStatement * get_table_statement(const ast::Block &)
+const ast::TableStatement * get_table_statement(const ast::Block &)
std::string format_float_string(const std::string &value)
Convert a given float value to its string representation.
-std::tuple< bool, int > check_if_var_is_array(const std::string &name)
Check if the given name exist in the symbol.
+std::tuple< bool, int > check_if_var_is_array(const std::string &name)
Check if the given name exist in the symbol.
bool is_functor_const(const ast::StatementBlock &variable_block, const ast::StatementBlock &functor_block)
Checks whether the functor_block generated by sympy solver modifies any variable outside its scope.
std::shared_ptr< Expression > get_node_to_solve() const noexcept
Getter for member variable SolutionExpression::node_to_solve.
static std::vector< std::string > split_string(const std::string &text, char delimiter)
Split a text in a list of words, using a given delimiter character.
diff --git a/doxygen/codegen__cpp__visitor_8hpp_source.html b/doxygen/codegen__cpp__visitor_8hpp_source.html
index d8a397b13..399758742 100644
--- a/doxygen/codegen__cpp__visitor_8hpp_source.html
+++ b/doxygen/codegen__cpp__visitor_8hpp_source.html
@@ -1208,435 +1208,438 @@
1112 bool use_instance =
true)
const = 0;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1213 const std::string& function_name =
"") = 0;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1215 const std::string& function_name =
"") = 0;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
- 1478 template <
typename T>
-
- 1480 const std::string& name,
- 1481 const std::unordered_set<CppObjectSpecifier>& = {
-
-
-
-
- 1486 template <
typename T>
-
- 1488 const std::string& separator,
- 1489 const std::string& prefix) {
- 1490 for (
auto iter = elements.begin(); iter != elements.end(); iter++) {
-
- 1492 (*iter)->accept(*
this);
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1506 template <
typename T>
-
-
- 1509 const std::string& name,
- 1510 const std::unordered_set<CppObjectSpecifier>& specifiers) {
-
-
-
-
-
- 1516 const auto& params = node.get_parameters();
- 1517 for (
const auto& param: params) {
- 1518 internal_params.emplace_back(
"", type,
"", param.get()->get_node_name());
-
-
-
- 1522 const char* return_type =
"int";
- 1523 if (node.is_function_block()) {
-
-
-
-
- 1528 printer->fmt_text(
"{} {} {}({})",
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ 1480 template <
typename T>
+
+ 1482 const std::string& name,
+ 1483 const std::unordered_set<CppObjectSpecifier>& = {
+
+
+
+
+ 1488 template <
typename T>
+
+ 1490 const std::string& separator,
+ 1491 const std::string& prefix) {
+ 1492 for (
auto iter = elements.begin(); iter != elements.end(); iter++) {
+
+ 1494 (*iter)->accept(*
this);
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1508 template <
typename T>
+
+
+ 1511 const std::string& name,
+ 1512 const std::unordered_set<CppObjectSpecifier>& specifiers) {
+
+
+
+
+
+ 1518 const auto& params = node.get_parameters();
+ 1519 for (
const auto& param: params) {
+ 1520 internal_params.emplace_back(
"", type,
"", param.get()->get_node_name());
+
+
+
+ 1524 const char* return_type =
"int";
+ 1525 if (node.is_function_block()) {
+
+
+
+
+ 1530 printer->fmt_text(
"{} {} {}({})",
+
+
+
+
+
+
+
+
+
+
+
+
virtual void print_nrn_constructor()=0
Print nrn_constructor function definition.
+std::string table_update_function_name(const std::string &block_name) const
The name of the function that updates the table value if the parameters changed.
void visit_eigen_linear_solver_block(const ast::EigenLinearSolverBlock &node) override
visit node of type ast::EigenLinearSolverBlock
bool ion_variable_struct_required() const
Check if a structure for ion variables is required.
bool is_last(Iter iter, const Cont &cont)
Check if the iterator is pointing to last element in the container.
@@ -1704,7 +1707,7 @@
encapsulates code generation backend implementations
@ index
index / int variables
const std::string & float_data_type() const noexcept
Data type for floating point elements specified on command line.
-Represent ions used in mod file.
+Represent ions used in mod file.
virtual void print_function(const ast::FunctionBlock &node)=0
Print NMODL function in target backend code.
virtual void print_ion_variable()=0
Implement classes for representing symbol table at block and file scope.
@@ -1712,7 +1715,6 @@
bool range_variable_setup_required() const noexcept
Check if setup_range_variable function is required.
Represent MUTEXLOCK statement in NMODL.
void print_statement_block(const ast::StatementBlock &node, bool open_brace=true, bool close_brace=true)
Print any statement block in nmodl with option to (not) print braces.
-std::string table_function_prefix() const
Prefix used for the function that performs the lazy update.
virtual std::string global_variable_name(const SymbolType &symbol, bool use_instance=true) const =0
Determine the variable name for a global variable given its symbol.
Represents TABLE statement in NMODL.
@@ -1720,14 +1722,14 @@
Represents an integer variable.
@ BlockTypeEnd
fake ending block type for loops on the enums. Keep it at the end
-std::string get_object_specifiers(const std::unordered_set< CppObjectSpecifier > &)
+std::string get_object_specifiers(const std::unordered_set< CppObjectSpecifier > &)
std::vector< SymbolType > get_float_variables() const
Determine all float variables required during code generation.
virtual void print_net_move_call(const ast::FunctionCall &node)=0
Print call to net_move.
const char * default_int_data_type() const noexcept
Default data type for integer (offset) elements.
-std::string mod_suffix
name of the suffix
+std::string mod_suffix
name of the suffix
parser::NmodlParser::symbol_type SymbolType
-Represent information collected from AST for code generation.
+Represent information collected from AST for code generation.
void visit_paren_expression(const ast::ParenExpression &node) override
visit node of type ast::ParenExpression
const char * default_float_data_type() const noexcept
Default data type for floating point elements.
bool net_receive_buffering_required() const noexcept
Check if net receive/send buffering kernels required.
@@ -1738,10 +1740,10 @@
bool is_integer
if this is an integer (e.g.
virtual std::string int_variable_name(const IndexVariableInfo &symbol, const std::string &name, bool use_instance) const =0
Determine the name of an int variable given its symbol.
void visit_unit(const ast::Unit &node) override
visit node of type ast::Unit
-std::unordered_map< CppObjectSpecifier, std::string > object_specifier_map
+std::unordered_map< CppObjectSpecifier, std::string > object_specifier_map
Represent newton solver solution block based on Eigen.
void visit_update_dt(const ast::UpdateDt &node) override
visit node of type ast::UpdateDt
-void print_vector_elements(const std::vector< T > &elements, const std::string &separator, const std::string &prefix="")
Print the items in a vector as a list.
+void print_vector_elements(const std::vector< T > &elements, const std::string &separator, const std::string &prefix="")
Print the items in a vector as a list.
IndexVariableInfo(std::shared_ptr< symtab::Symbol > symbol, bool is_vdata=false, bool is_index=false, bool is_integer=false)
virtual void add_variable_point_process(std::vector< IndexVariableInfo > &variables)=0
Add the variable point_process during get_int_variables.
static constexpr char DEFAULT_FLOAT_TYPE[]
default float variable type
@@ -1815,12 +1817,12 @@
bool printing_net_receive
true if currently net_receive block being printed
virtual std::string process_verbatim_text(std::string const &text)=0
Process a verbatim block for possible variable renaming.
Statement to indicate a change in timestep in a given block.
-const ast::TableStatement * get_table_statement(const ast::Block &)
+const ast::TableStatement * get_table_statement(const ast::Block &)
virtual void print_global_variables_for_hoc()=0
Print byte arrays that register scalar and vector variables for hoc interface.
std::string format_float_string(const std::string &value)
Convert a given float value to its string representation.
-std::tuple< bool, int > check_if_var_is_array(const std::string &name)
Check if the given name exist in the symbol.
+std::tuple< bool, int > check_if_var_is_array(const std::string &name)
Check if the given name exist in the symbol.
bool is_functor_const(const ast::StatementBlock &variable_block, const ast::StatementBlock &functor_block)
Checks whether the functor_block generated by sympy solver modifies any variable outside its scope.
static std::string get_parameter_str(const ParamVector ¶ms)
Generate the string representing the procedure parameter declaration.
@@ -1833,7 +1835,7 @@
virtual std::string internal_method_arguments()=0
Arguments for functions that are defined and used internally.
std::string global_struct() const
Name of structure that wraps global variables.
-bool electrode_current
if electrode current specified
+bool electrode_current
if electrode current specified
void rename_function_arguments()
Rename function/procedure arguments that conflict with default arguments.
virtual ParamVector internal_method_parameters()=0
Parameters for internally defined functions.
virtual void print_nrn_destructor()=0
Print nrn_destructor function definition.
@@ -1905,7 +1907,7 @@
virtual void print_data_structures(bool print_initializers)=0
Print all classes.
std::string format_double_string(const std::string &value)
Convert a given double value to its string representation.
Represent token returned by scanner.
-void print_function_declaration(const T &node, const std::string &name, const std::unordered_set< CppObjectSpecifier > &={ CppObjectSpecifier::Inline})
Print prototype declarations of functions or procedures.
+void print_function_declaration(const T &node, const std::string &name, const std::unordered_set< CppObjectSpecifier > &={ CppObjectSpecifier::Inline})
Print prototype declarations of functions or procedures.
virtual void print_nrn_state()=0
Print nrn_state / state update function definition.
virtual std::string backend_name() const =0
Name of the code generation backend.
diff --git a/doxygen/codegen__helper__visitor_8cpp_source.html b/doxygen/codegen__helper__visitor_8cpp_source.html
index 3eee59c76..0a2dabefb 100644
--- a/doxygen/codegen__helper__visitor_8cpp_source.html
+++ b/doxygen/codegen__helper__visitor_8cpp_source.html
@@ -169,500 +169,500 @@
73 std::vector<std::string> ion_vars;
74 std::vector<std::string> read_ion_vars;
75 std::vector<std::string> write_ion_vars;
-
- 77 for (
const auto& ion_node: ion_nodes) {
- 78 const auto& ion = std::dynamic_pointer_cast<const ast::Useion>(ion_node);
- 79 ion_vars.push_back(ion->get_node_name());
- 80 for (
const auto& var: ion->get_readlist()) {
- 81 read_ion_vars.push_back(var->get_node_name());
-
- 83 for (
const auto& var: ion->get_writelist()) {
- 84 write_ion_vars.push_back(var->get_node_name());
-
-
-
-
-
-
-
-
- 93 auto ion_variable = [](
const std::string& var,
const std::string& ion) ->
bool {
- 94 auto len = var.size() - 1;
- 95 return (var.substr(1, len) == ion || var.substr(0, len) == ion);
-
-
-
- 99 for (
auto& ion_name: ion_vars) {
-
- 101 for (
auto& read_var: read_ion_vars) {
- 102 if (ion_variable(read_var, ion_name)) {
- 103 ion.
reads.push_back(read_var);
-
-
- 106 for (
auto& write_var: write_ion_vars) {
- 107 if (ion_variable(write_var, ion_name)) {
- 108 ion.
writes.push_back(write_var);
-
-
- 111 info.write_concentration =
true;
-
-
-
- 115 info.ions.push_back(std::move(ion));
-
-
-
- 119 auto vars = psymtab->get_variables_with_properties(NmodlType::nonspecific_cur_var);
- 120 for (
auto& var: vars) {
- 121 info.currents.push_back(var->get_name());
-
- 123 vars = psymtab->get_variables_with_properties(NmodlType::electrode_cur_var);
- 124 for (
auto& var: vars) {
- 125 info.currents.push_back(var->get_name());
+ 76 std::map<std::string, double> valences;
+
+ 78 for (
const auto& ion_node: ion_nodes) {
+ 79 const auto& ion = std::dynamic_pointer_cast<const ast::Useion>(ion_node);
+ 80 auto ion_name = ion->get_node_name();
+ 81 ion_vars.push_back(ion_name);
+ 82 for (
const auto& var: ion->get_readlist()) {
+ 83 read_ion_vars.push_back(var->get_node_name());
+
+ 85 for (
const auto& var: ion->get_writelist()) {
+ 86 write_ion_vars.push_back(var->get_node_name());
+
+
+ 89 if (ion->get_valence() !=
nullptr) {
+ 90 valences[ion_name] = ion->get_valence()->get_value()->to_double();
+
+
+
+
+
+
+
+
+ 99 auto ion_variable = [](
const std::string& var,
const std::string& ion) ->
bool {
+ 100 auto len = var.size() - 1;
+ 101 return (var.substr(1, len) == ion || var.substr(0, len) == ion);
+
+
+
+ 105 for (
auto& ion_name: ion_vars) {
+
+ 107 for (
auto& read_var: read_ion_vars) {
+ 108 if (ion_variable(read_var, ion_name)) {
+ 109 ion.
reads.push_back(read_var);
+
+
+ 112 for (
auto& write_var: write_ion_vars) {
+ 113 if (ion_variable(write_var, ion_name)) {
+ 114 ion.
writes.push_back(write_var);
+
+
+ 117 info.write_concentration =
true;
+
+
+
+ 121 if (
auto it = valences.find(ion_name); it != valences.end()) {
+
+
+
+ 125 info.ions.push_back(std::move(ion));
- 127 for (
auto& ion: info.ions) {
- 128 for (
auto& var: ion.writes) {
- 129 if (ion.is_ionic_current(var)) {
- 130 info.currents.push_back(var);
-
-
-
-
-
- 136 for (
const auto& ion: info.ions) {
- 137 for (
const auto& var: ion.writes) {
- 138 if (!ion.is_ionic_current(var) && !ion.is_rev_potential(var)) {
- 139 info.require_wrote_conc =
true;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 158 info.constant_variables = psymtab->get_variables_with_properties(NmodlType::constant_var);
- 159 info.top_local_variables = psymtab->get_variables_with_properties(NmodlType::local_var);
-
-
-
-
-
-
- 166 std::string variables;
-
- 168 auto vars = psymtab->get_variables_with_properties(NmodlType::global_var);
- 169 for (
auto& var: vars) {
- 170 if (info.thread_safe && var->get_write_count() > 0) {
- 171 var->mark_thread_safe();
- 172 info.thread_variables.push_back(var);
- 173 info.thread_var_data_size += var->get_length();
- 174 variables +=
" " + var->get_name();
-
- 176 info.global_variables.push_back(var);
-
-
-
-
-
-
-
-
-
-
-
- 188 auto with = NmodlType::param_assign;
- 189 auto without = NmodlType::range_var
- 190 | NmodlType::assigned_definition
- 191 | NmodlType::global_var
- 192 | NmodlType::pointer_var
- 193 | NmodlType::bbcore_pointer_var
- 194 | NmodlType::read_ion_var
- 195 | NmodlType::write_ion_var;
-
- 197 vars = psymtab->get_variables(with, without);
- 198 for (
auto& var: vars) {
-
-
-
- 202 var->has_any_property(NmodlType::extern_neuron_variable)) {
-
-
-
-
-
- 208 if (info.thread_safe && var->get_write_count() > 0) {
- 209 var->mark_thread_safe();
- 210 info.thread_variables.push_back(var);
- 211 info.thread_var_data_size += var->get_length();
-
- 213 info.global_variables.push_back(var);
+
+
+ 129 auto vars = psymtab->get_variables_with_properties(NmodlType::nonspecific_cur_var);
+ 130 for (
auto& var: vars) {
+ 131 info.currents.push_back(var->get_name());
+
+ 133 vars = psymtab->get_variables_with_properties(NmodlType::electrode_cur_var);
+ 134 for (
auto& var: vars) {
+ 135 info.currents.push_back(var->get_name());
+
+ 137 for (
auto& ion: info.ions) {
+ 138 for (
auto& var: ion.writes) {
+ 139 if (ion.is_ionic_current(var)) {
+ 140 info.currents.push_back(var);
+
+
+
+
+
+ 146 for (
const auto& ion: info.ions) {
+ 147 for (
const auto& var: ion.writes) {
+ 148 if (!ion.is_ionic_current(var) && !ion.is_rev_potential(var)) {
+ 149 info.require_wrote_conc =
true;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 168 info.constant_variables = psymtab->get_variables_with_properties(NmodlType::constant_var);
+ 169 info.top_local_variables = psymtab->get_variables_with_properties(NmodlType::local_var);
+
+
+
+
+
+
+ 176 std::string variables;
+
+ 178 auto vars = psymtab->get_variables_with_properties(NmodlType::global_var);
+ 179 for (
auto& var: vars) {
+ 180 if (info.thread_safe && var->get_write_count() > 0) {
+ 181 var->mark_thread_safe();
+ 182 info.thread_variables.push_back(var);
+ 183 info.thread_var_data_size += var->get_length();
+ 184 variables +=
" " + var->get_name();
+
+ 186 info.global_variables.push_back(var);
+
+
+
+
+
+
+
+
+
+
+
+ 198 auto with = NmodlType::param_assign;
+ 199 auto without = NmodlType::range_var
+ 200 | NmodlType::assigned_definition
+ 201 | NmodlType::global_var
+ 202 | NmodlType::pointer_var
+ 203 | NmodlType::bbcore_pointer_var
+ 204 | NmodlType::read_ion_var
+ 205 | NmodlType::write_ion_var;
+
+ 207 vars = psymtab->get_variables(with, without);
+ 208 for (
auto& var: vars) {
+
+
+
+ 212 var->has_any_property(NmodlType::extern_neuron_variable)) {
+
-
- 216 sort_with_mod2c_symbol_order(info.thread_variables);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 218 if (info.thread_safe && var->get_write_count() > 0) {
+ 219 var->mark_thread_safe();
+ 220 info.thread_variables.push_back(var);
+ 221 info.thread_var_data_size += var->get_length();
+
+ 223 info.global_variables.push_back(var);
+
+
+ 226 sort_with_mod2c_symbol_order(info.thread_variables);
+
+
+
+
+
+
- 234 if (info.derivimplicit_used()) {
- 235 info.derivimplicit_var_thread_id = 0;
- 236 info.thread_data_index = 3;
- 237 info.derivimplicit_list_num = 1;
- 238 info.thread_callback_register =
true;
-
-
-
- 242 if (info.vectorize && !info.top_local_variables.empty()) {
- 243 info.top_local_thread_id = info.thread_data_index++;
- 244 info.thread_callback_register =
true;
-
-
-
- 248 if (info.vectorize && !info.thread_variables.empty()) {
- 249 info.thread_var_thread_id = info.thread_data_index++;
- 250 info.thread_callback_register =
true;
-
-
-
- 254 for (
auto& var: info.top_local_variables) {
- 255 info.top_local_thread_size += var->get_length();
-
-
-
- 259 auto primes = psymtab->get_variables_with_properties(NmodlType::prime_name);
- 260 info.num_primes =
static_cast<int>(primes.size());
- 261 for (
auto& variable: primes) {
- 262 info.primes_size += variable->get_length();
-
-
-
-
- 267 auto properties = NmodlType::pointer_var
- 268 | NmodlType::bbcore_pointer_var;
-
- 270 info.pointer_variables = psymtab->get_variables_with_properties(properties);
-
-
-
- 274 properties = NmodlType::random_var;
-
- 276 info.random_variables = psymtab->get_variables_with_properties(properties);
-
-
-
- 280 properties = NmodlType::assigned_definition
- 281 | NmodlType::param_assign;
- 282 vars = psymtab->get_variables_with_properties(properties);
- 283 for (
auto& var : vars) {
-
- 285 info.area_used =
true;
-
-
- 288 info.diam_used =
true;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ 244 if (info.derivimplicit_used()) {
+ 245 info.derivimplicit_var_thread_id = 0;
+ 246 info.thread_data_index = 3;
+ 247 info.derivimplicit_list_num = 1;
+ 248 info.thread_callback_register =
true;
+
+
+
+ 252 if (info.vectorize && !info.top_local_variables.empty()) {
+ 253 info.top_local_thread_id = info.thread_data_index++;
+ 254 info.thread_callback_register =
true;
+
+
+
+ 258 if (info.vectorize && !info.thread_variables.empty()) {
+ 259 info.thread_var_thread_id = info.thread_data_index++;
+ 260 info.thread_callback_register =
true;
+
+
+
+ 264 for (
auto& var: info.top_local_variables) {
+ 265 info.top_local_thread_size += var->get_length();
+
+
+
+ 269 auto primes = psymtab->get_variables_with_properties(NmodlType::prime_name);
+ 270 info.num_primes =
static_cast<int>(primes.size());
+ 271 for (
auto& variable: primes) {
+ 272 info.primes_size += variable->get_length();
+
+
+
+
+ 277 auto properties = NmodlType::pointer_var
+ 278 | NmodlType::bbcore_pointer_var;
+
+ 280 info.pointer_variables = psymtab->get_variables_with_properties(properties);
+
+
+
+ 284 properties = NmodlType::random_var;
+
+ 286 info.random_variables = psymtab->get_variables_with_properties(properties);
+
+
+
+ 290 properties = NmodlType::assigned_definition
+ 291 | NmodlType::param_assign;
+ 292 vars = psymtab->get_variables_with_properties(properties);
+ 293 for (
auto& var : vars) {
+
+ 295 info.area_used =
true;
+
+
+ 298 info.diam_used =
true;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 349 return first->get_definition_order() < second->get_definition_order();
-
-
-
-
- 354 vars.erase(std::remove_if(vars.begin(),
-
-
- 357 return info.is_ion_variable(s->get_name()) &&
- 358 !info.is_ionic_current(s->get_name());
-
-
-
-
-
-
- 365 secondary.erase(std::remove_if(secondary.begin(),
-
-
- 368 return std::find_if(primary.begin(),
-
-
-
-
- 373 return tosearch->get_name() ==
-
-
-
-
-
-
-
-
-
-
- 384 auto with = NmodlType::range_var
- 385 | NmodlType::param_assign;
- 386 auto without = NmodlType::global_var
- 387 | NmodlType::pointer_var
- 388 | NmodlType::bbcore_pointer_var
- 389 | NmodlType::state_var;
-
-
- 392 info.range_parameter_vars = psymtab->get_variables(with, without);
- 393 remove_non_ioncur_vars(info.range_parameter_vars, info);
- 394 std::sort(info.range_parameter_vars.begin(), info.range_parameter_vars.end(), comparator);
-
-
-
-
-
- 400 with = NmodlType::range_var
- 401 | NmodlType::assigned_definition;
- 402 without = NmodlType::global_var
- 403 | NmodlType::pointer_var
- 404 | NmodlType::bbcore_pointer_var
- 405 | NmodlType::state_var
- 406 | NmodlType::param_assign;
-
-
- 409 info.range_assigned_vars = psymtab->get_variables(with, without);
- 410 remove_non_ioncur_vars(info.range_assigned_vars, info);
- 411 std::sort(info.range_assigned_vars.begin(), info.range_assigned_vars.end(), comparator);
-
-
-
-
-
-
-
-
-
- 421 with = NmodlType::state_var;
- 422 without = NmodlType::global_var
- 423 | NmodlType::pointer_var
- 424 | NmodlType::bbcore_pointer_var;
-
-
- 427 info.state_vars = psymtab->get_variables(with, without);
- 428 std::sort(info.state_vars.begin(), info.state_vars.end(), comparator);
-
-
- 431 info.range_state_vars = info.state_vars;
- 432 remove_non_ioncur_vars(info.range_state_vars, info);
-
-
-
-
- 437 with = NmodlType::assigned_definition
- 438 | NmodlType::read_ion_var
- 439 | NmodlType::write_ion_var;
- 440 without = NmodlType::global_var
- 441 | NmodlType::pointer_var
- 442 | NmodlType::bbcore_pointer_var
- 443 | NmodlType::extern_neuron_variable;
-
- 445 const auto& variables = psymtab->get_variables_with_properties(with,
false);
- 446 for (
const auto& variable: variables) {
- 447 if (!variable->has_any_property(without)) {
- 448 info.assigned_vars.push_back(variable);
-
-
-
-
-
- 454 remove_var_exist(info.range_parameter_vars, info.assigned_vars);
- 455 remove_var_exist(info.range_assigned_vars, info.assigned_vars);
- 456 remove_var_exist(info.range_state_vars, info.assigned_vars);
-
-
- 459 std::sort(info.assigned_vars.begin(), info.assigned_vars.end(), comparator);
-
-
-
-
- 464 auto property = NmodlType::table_statement_var;
- 465 info.table_statement_variables = psymtab->get_variables_with_properties(property);
- 466 property = NmodlType::table_assigned_var;
- 467 info.table_assigned_variables = psymtab->get_variables_with_properties(property);
-
-
-
-
- 472 using pair = std::pair<const char*, const char*>;
-
- 474 pair{
"secondorder",
"int"},
- 475 pair{
"pi",
"double"}}) {
- 476 auto sym = psymtab->lookup(var);
- 477 if (sym && (sym->get_read_count() || sym->get_write_count())) {
- 478 info.neuron_global_variables.emplace_back(std::move(sym), type);
-
-
-
-
-
-
- 485 const auto& type = node.
get_type()->get_node_name();
-
- 487 info.point_process =
true;
-
-
- 490 info.artificial_cell =
true;
- 491 info.point_process =
true;
-
-
-
-
-
- 497 info.electrode_current =
true;
-
-
-
-
- 502 if (under_net_receive_block) {
- 503 info.net_receive_initial_node = &node;
-
- 505 info.initial_node = &node;
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 359 return first->get_definition_order() < second->get_definition_order();
+
+
+
+
+ 364 vars.erase(std::remove_if(vars.begin(),
+
+
+ 367 return info.is_ion_variable(s->get_name()) &&
+ 368 !info.is_ionic_current(s->get_name());
+
+
+
+
+
+
+ 375 secondary.erase(std::remove_if(secondary.begin(),
+
+
+ 378 return std::find_if(primary.begin(),
+
+
+
+
+ 383 return tosearch->get_name() ==
+
+
+
+
+
+
+
+
+
+
+ 394 auto with = NmodlType::range_var
+ 395 | NmodlType::param_assign;
+ 396 auto without = NmodlType::global_var
+ 397 | NmodlType::pointer_var
+ 398 | NmodlType::bbcore_pointer_var
+ 399 | NmodlType::state_var;
+
+
+ 402 info.range_parameter_vars = psymtab->get_variables(with, without);
+ 403 remove_non_ioncur_vars(info.range_parameter_vars, info);
+ 404 std::sort(info.range_parameter_vars.begin(), info.range_parameter_vars.end(), comparator);
+
+
+
+
+
+ 410 with = NmodlType::range_var
+ 411 | NmodlType::assigned_definition;
+ 412 without = NmodlType::global_var
+ 413 | NmodlType::pointer_var
+ 414 | NmodlType::bbcore_pointer_var
+ 415 | NmodlType::state_var
+ 416 | NmodlType::param_assign;
+
+
+ 419 info.range_assigned_vars = psymtab->get_variables(with, without);
+ 420 remove_non_ioncur_vars(info.range_assigned_vars, info);
+ 421 std::sort(info.range_assigned_vars.begin(), info.range_assigned_vars.end(), comparator);
+
+
+
+
+
+
+
+
+
+ 431 with = NmodlType::state_var;
+ 432 without = NmodlType::global_var
+ 433 | NmodlType::pointer_var
+ 434 | NmodlType::bbcore_pointer_var;
+
+
+ 437 info.state_vars = psymtab->get_variables(with, without);
+ 438 std::sort(info.state_vars.begin(), info.state_vars.end(), comparator);
+
+
+ 441 info.range_state_vars = info.state_vars;
+ 442 remove_non_ioncur_vars(info.range_state_vars, info);
+
+
+
+
+ 447 with = NmodlType::assigned_definition
+ 448 | NmodlType::read_ion_var
+ 449 | NmodlType::write_ion_var;
+ 450 without = NmodlType::global_var
+ 451 | NmodlType::pointer_var
+ 452 | NmodlType::bbcore_pointer_var
+ 453 | NmodlType::extern_neuron_variable;
+
+ 455 const auto& variables = psymtab->get_variables_with_properties(with,
false);
+ 456 for (
const auto& variable: variables) {
+ 457 if (!variable->has_any_property(without)) {
+ 458 info.assigned_vars.push_back(variable);
+
+
+
+
+
+ 464 remove_var_exist(info.range_parameter_vars, info.assigned_vars);
+ 465 remove_var_exist(info.range_assigned_vars, info.assigned_vars);
+ 466 remove_var_exist(info.range_state_vars, info.assigned_vars);
+
+
+ 469 std::sort(info.assigned_vars.begin(), info.assigned_vars.end(), comparator);
+
+
+
+
+ 474 auto property = NmodlType::table_statement_var;
+ 475 info.table_statement_variables = psymtab->get_variables_with_properties(property);
+ 476 property = NmodlType::table_assigned_var;
+ 477 info.table_assigned_variables = psymtab->get_variables_with_properties(property);
+
+
+
+
+ 482 using pair = std::pair<const char*, const char*>;
+
+ 484 pair{
"secondorder",
"int"},
+ 485 pair{
"pi",
"double"}}) {
+ 486 auto sym = psymtab->lookup(var);
+ 487 if (sym && (sym->get_read_count() || sym->get_write_count())) {
+ 488 info.neuron_global_variables.emplace_back(std::move(sym), type);
+
+
+
+
+
+
+ 495 const auto& type = node.
get_type()->get_node_name();
+
+ 497 info.point_process =
true;
+
+
+ 500 info.artificial_cell =
true;
+ 501 info.point_process =
true;
+
+
+
+
+
+ 507 info.electrode_current =
true;
-
- 512 info.constructor_node = &node;
-
-
-
-
-
- 518 info.destructor_node = &node;
-
-
-
-
-
- 524 under_net_receive_block =
true;
- 525 info.net_receive_node = &node;
- 526 info.num_net_receive_parameters =
static_cast<int>(node.
get_parameters().size());
-
- 528 under_net_receive_block =
false;
-
-
+
+ 512 if (under_net_receive_block) {
+ 513 info.net_receive_initial_node = &node;
+
+ 515 info.initial_node = &node;
+
+
+
+
+
+
+ 522 info.constructor_node = &node;
+
+
+
+
+
+ 528 info.destructor_node = &node;
+
+
-
- 533 under_derivative_block =
true;
-
- 535 under_derivative_block =
false;
-
-
-
- 539 info.derivimplicit_callbacks.push_back(&node);
-
+
+
+ 534 under_net_receive_block =
true;
+ 535 info.net_receive_node = &node;
+ 536 info.num_net_receive_parameters =
static_cast<int>(node.
get_parameters().size());
+
+ 538 under_net_receive_block =
false;
+
+
-
-
- 544 under_breakpoint_block =
true;
- 545 info.breakpoint_node = &node;
-
- 547 under_breakpoint_block =
false;
-
-
-
-
- 552 info.nrn_state_block = &node;
-
-
-
-
-
- 558 info.procedures.push_back(&node);
-
- 560 if (table_statement_used) {
- 561 table_statement_used =
false;
- 562 info.functions_with_table.push_back(&node);
-
+
+ 543 under_derivative_block =
true;
+
+ 545 under_derivative_block =
false;
+
+
+
+ 549 info.derivimplicit_callbacks.push_back(&node);
+
+
+
+
+ 554 under_breakpoint_block =
true;
+ 555 info.breakpoint_node = &node;
+
+ 557 under_breakpoint_block =
false;
+
+
+
+
+ 562 info.nrn_state_block = &node;
+
-
- 568 info.functions.push_back(&node);
-
+
+ 568 info.procedures.push_back(&node);
+
570 if (table_statement_used) {
571 table_statement_used =
false;
572 info.functions_with_table.push_back(&node);
@@ -670,213 +670,223 @@
-
- 578 info.function_tables.push_back(&node);
-
-
-
-
-
- 584 info.eigen_newton_solver_exist =
true;
-
-
- 587 if (!under_derivative_block) {
- 588 const auto new_unique_functor_name =
"functor_" + info.mod_suffix +
"_" +
-
- 590 info.functor_names[&node] = new_unique_functor_name;
-
-
-
-
-
-
- 597 info.eigen_linear_solver_exist =
true;
-
-
-
-
-
-
- 604 info.net_send_used =
true;
-
-
- 607 info.net_event_used =
true;
-
+
+ 578 info.functions.push_back(&node);
+
+ 580 if (table_statement_used) {
+ 581 table_statement_used =
false;
+ 582 info.functions_with_table.push_back(&node);
+
+
+
+
+
+ 588 info.function_tables.push_back(&node);
+
+
+
+
+
+ 594 info.eigen_newton_solver_exist =
true;
+
+
+ 597 if (!under_derivative_block) {
+ 598 const auto new_unique_functor_name =
"functor_" + info.mod_suffix +
"_" +
+
+ 600 info.functor_names[&node] = new_unique_functor_name;
+
+
+
+
+
+
+ 607 info.eigen_linear_solver_exist =
true;
+
-
-
- 613 const auto& ion = node.
get_ion();
-
- 615 std::string ion_name;
-
- 617 ion_name = ion->get_node_name();
+
+
+
+ 614 info.net_send_used =
true;
+
+
+ 617 info.net_event_used =
true;
- 619 info.conductances.push_back({ion_name, variable->get_node_name()});
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 646 for (
auto& statement: statements) {
- 647 statement->accept(*
this);
- 648 if (under_derivative_block && assign_lhs &&
- 649 (assign_lhs->is_name() || assign_lhs->is_var_name())) {
- 650 auto name = assign_lhs->get_node_name();
- 651 auto symbol = psymtab->lookup(name);
- 652 if (symbol !=
nullptr) {
- 653 auto is_prime = symbol->has_any_property(NmodlType::prime_name);
- 654 auto from_state = symbol->has_any_status(Status::from_state);
- 655 if (is_prime || from_state) {
-
- 657 symbol = psymtab->lookup(name.substr(1, name.size()));
-
-
- 660 if (std::find_if(info.prime_variables_by_order.begin(),
- 661 info.prime_variables_by_order.end(),
- 662 [&](
auto const& sym) {
- 663 return sym->get_name() == symbol->get_name();
- 664 }) == info.prime_variables_by_order.end()) {
- 665 info.prime_variables_by_order.push_back(symbol);
- 666 info.num_equations++;
-
-
-
-
- 671 assign_lhs =
nullptr;
-
-
-
-
- 676 info.factor_definitions.push_back(&node);
-
-
-
-
-
-
-
-
-
-
-
+
+ 623 const auto& ion = node.
get_ion();
+
+ 625 std::string ion_name;
+
+ 627 ion_name = ion->get_node_name();
+
+ 629 info.conductances.push_back({ion_name, variable->get_node_name()});
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 656 for (
auto& statement: statements) {
+ 657 statement->accept(*
this);
+ 658 if (under_derivative_block && assign_lhs &&
+ 659 (assign_lhs->is_name() || assign_lhs->is_var_name())) {
+ 660 auto name = assign_lhs->get_node_name();
+ 661 auto symbol = psymtab->lookup(name);
+ 662 if (symbol !=
nullptr) {
+ 663 auto is_prime = symbol->has_any_property(NmodlType::prime_name);
+ 664 auto from_state = symbol->has_any_status(Status::from_state);
+ 665 if (is_prime || from_state) {
+
+ 667 symbol = psymtab->lookup(name.substr(1, name.size()));
+
+
+ 670 if (std::find_if(info.prime_variables_by_order.begin(),
+ 671 info.prime_variables_by_order.end(),
+ 672 [&](
auto const& sym) {
+ 673 return sym->get_name() == symbol->get_name();
+ 674 }) == info.prime_variables_by_order.end()) {
+ 675 info.prime_variables_by_order.push_back(symbol);
+ 676 info.num_equations++;
+
+
+
+
+ 681 assign_lhs =
nullptr;
+
+
+
+
+ 686 info.factor_definitions.push_back(&node);
+
-
- 690 info.bbcore_pointer_used =
true;
-
-
-
-
-
+
+
+
+
+
+
+
-
- 700 info.watch_statements.push_back(&node);
-
-
+
+ 700 info.bbcore_pointer_used =
true;
+
+
-
-
- 706 info.for_netcon_used =
true;
-
+
+
+
+
-
-
-
- 712 table_statement_used =
true;
-
+
+ 710 info.watch_statements.push_back(&node);
+
+
+
-
-
-
-
- 719 for (
auto& block: blocks) {
- 720 info.top_blocks.push_back(block.get());
- 721 if (block->is_verbatim()) {
- 722 info.top_verbatim_blocks.push_back(block.get());
-
-
-
- 726 find_ion_variables(node);
- 727 find_range_variables();
- 728 find_non_range_variables();
- 729 find_table_variables();
- 730 find_neuron_global_variables();
-
-
-
-
-
-
-
-
-
- 740 info.vectorize =
false;
+
+ 716 info.for_netcon_used =
true;
+
+
+
+
+
+ 722 table_statement_used =
true;
+
+
+
+
+
+
+ 729 for (
auto& block: blocks) {
+ 730 info.top_blocks.push_back(block.get());
+ 731 if (block->is_verbatim()) {
+ 732 info.top_verbatim_blocks.push_back(block.get());
+
+
+
+ 736 find_ion_variables(node);
+ 737 find_range_variables();
+ 738 find_non_range_variables();
+ 739 find_table_variables();
+ 740 find_neuron_global_variables();
-
- 744 info.vectorize =
false;
-
-
-
- 748 info.vectorize =
false;
-
-
-
- 752 info.changed_dt = node.
get_value()->eval();
-
-
-
-
-
-
-
-
- 761 const auto& tokens =
driver.all_tokens();
-
-
- 764 for (
auto& token: tokens) {
- 765 if (info.variables_in_verbatim.find(token) == info.variables_in_verbatim.end()) {
- 766 auto symbol = psymtab->lookup(token);
- 767 if (symbol !=
nullptr) {
- 768 info.variables_in_verbatim.insert(token);
-
-
-
-
-
-
- 775 info.before_after_blocks.push_back(&node);
-
-
-
- 779 info.before_after_blocks.push_back(&node);
-
-
-
-
+
+
+
+
+
+
+
+ 750 info.vectorize =
false;
+
+
+
+ 754 info.vectorize =
false;
+
+
+
+ 758 info.vectorize =
false;
+
+
+
+ 762 info.changed_dt = node.
get_value()->eval();
+
+
+
+
+
+
+
+
+ 771 const auto& tokens =
driver.all_tokens();
+
+
+ 774 for (
auto& token: tokens) {
+ 775 if (info.variables_in_verbatim.find(token) == info.variables_in_verbatim.end()) {
+ 776 auto symbol = psymtab->lookup(token);
+ 777 if (symbol !=
nullptr) {
+ 778 info.variables_in_verbatim.insert(token);
+
+
+
+
+
+
+ 785 info.before_after_blocks.push_back(&node);
+
+
+
+ 789 info.before_after_blocks.push_back(&node);
+
+
+
+
std::string get_node_name() const override
Return name of the node.
@@ -884,51 +894,52 @@
Represents a BEFORE block in NMODL.
Represents a C code block.
static constexpr char CELSIUS_VARIABLE[]
global temperature variable
-void visit_eigen_newton_solver_block(const ast::EigenNewtonSolverBlock &node) override
visit node of type ast::EigenNewtonSolverBlock
-void visit_eigen_linear_solver_block(const ast::EigenLinearSolverBlock &node) override
visit node of type ast::EigenLinearSolverBlock
-void find_neuron_global_variables()
-void visit_breakpoint_block(const ast::BreakpointBlock &node) override
visit node of type ast::BreakpointBlock
-void visit_update_dt(const ast::UpdateDt &node) override
visit node of type ast::UpdateDt
+void visit_eigen_newton_solver_block(const ast::EigenNewtonSolverBlock &node) override
visit node of type ast::EigenNewtonSolverBlock
+void visit_eigen_linear_solver_block(const ast::EigenLinearSolverBlock &node) override
visit node of type ast::EigenLinearSolverBlock
+void find_neuron_global_variables()
+void visit_breakpoint_block(const ast::BreakpointBlock &node) override
visit node of type ast::BreakpointBlock
+void visit_update_dt(const ast::UpdateDt &node) override
visit node of type ast::UpdateDt
std::shared_ptr< Name > get_ion() const noexcept
Getter for member variable ConductanceHint::ion.
-void visit_conductance_hint(const ast::ConductanceHint &node) override
visit node of type ast::ConductanceHint
+void visit_conductance_hint(const ast::ConductanceHint &node) override
visit node of type ast::ConductanceHint
-void visit_destructor_block(const ast::DestructorBlock &node) override
visit node of type ast::DestructorBlock
+void visit_destructor_block(const ast::DestructorBlock &node) override
visit node of type ast::DestructorBlock
const ArgumentVector & get_parameters() const noexcept override
Getter for member variable NetReceiveBlock::parameters.
-void visit_electrode_current(const ast::ElectrodeCurrent &node) override
visit node of type ast::ElectrodeCurrent
+void visit_electrode_current(const ast::ElectrodeCurrent &node) override
visit node of type ast::ElectrodeCurrent
Represents CONDUCTANCE statement in NMODL.
+std::optional< double > valence
ion valence
static constexpr char POINT_PROCESS[]
point process keyword in nmodl
std::vector< std::shared_ptr< symtab::Symbol > > SymbolVectorType
encapsulates code generation backend implementations
-void visit_program(const ast::Program &node) override
visit node of type ast::Program
-void visit_function_block(const ast::FunctionBlock &node) override
visit node of type ast::FunctionBlock
+void visit_program(const ast::Program &node) override
visit node of type ast::Program
+void visit_function_block(const ast::FunctionBlock &node) override
visit node of type ast::FunctionBlock
std::shared_ptr< Name > get_conductance() const noexcept
Getter for member variable ConductanceHint::conductance.
-Represent ions used in mod file.
+Represent ions used in mod file.
std::shared_ptr< symtab::Symbol > SymbolType
-void visit_discrete_block(const ast::DiscreteBlock &node) override
visit node of type ast::DiscreteBlock
-void visit_function_call(const ast::FunctionCall &node) override
visit node of type ast::FunctionCall
+void visit_discrete_block(const ast::DiscreteBlock &node) override
visit node of type ast::DiscreteBlock
+void visit_function_call(const ast::FunctionCall &node) override
visit node of type ast::FunctionCall
Represents TABLE statement in NMODL.
Status
state during various compiler passes
Represents SUFFIX statement in NMODL.
-void visit_factor_def(const ast::FactorDef &node) override
visit node of type ast::FactorDef
+void visit_factor_def(const ast::FactorDef &node) override
visit node of type ast::FactorDef
void accept(visitor::Visitor &v) override
accept (or visit) the current AST node using provided visitor
-Represent information collected from AST for code generation.
+Represent information collected from AST for code generation.
void visit_children(visitor::Visitor &v) override
visit children i.e.
void visit_children(visitor::Visitor &v) override
visit children i.e.
-void visit_for_netcon(const ast::ForNetcon &node) override
visit node of type ast::ForNetcon
+void visit_for_netcon(const ast::ForNetcon &node) override
visit node of type ast::ForNetcon
void visit_children(visitor::Visitor &v) override
visit children i.e.
-void visit_binary_expression(const ast::BinaryExpression &node) override
visit node of type ast::BinaryExpression
+void visit_binary_expression(const ast::BinaryExpression &node) override
visit node of type ast::BinaryExpression
std::shared_ptr< String > get_statement() const noexcept
Getter for member variable Verbatim::statement.
Class that binds all pieces together for parsing C verbatim blocks.
std::shared_ptr< Expression > get_rhs() const noexcept
Getter for member variable BinaryExpression::rhs.
static constexpr char ARTIFICIAL_CELL[]
artificial cell keyword in nmodl
Represent newton solver solution block based on Eigen.
Helper visitor to gather AST information to help code generation.
-std::vector< std::string > writes
ion variables that are being written
-void visit_statement_block(const ast::StatementBlock &node) override
Visit statement block and find prime symbols appear in derivative block.
+std::vector< std::string > writes
ion variables that are being written
+void visit_statement_block(const ast::StatementBlock &node) override
Visit statement block and find prime symbols appear in derivative block.
std::string get_node_name() const override
Return name of the node.
const StatementVector & get_statements() const noexcept
Getter for member variable StatementBlock::statements.
@@ -938,58 +949,58 @@
Represent WATCH statement in NMODL.
Represents a BREAKPOINT block in NMODL.
void visit_children(visitor::Visitor &v) override
visit children i.e.
-bool need_style
if style semantic needed
+bool need_style
if style semantic needed
nmodl::parser::UnitDriver driver
std::shared_ptr< Double > get_value() const noexcept
Getter for member variable UpdateDt::value.
-void visit_table_statement(const ast::TableStatement &node) override
visit node of type ast::TableStatement
+void visit_table_statement(const ast::TableStatement &node) override
visit node of type ast::TableStatement
Represents a DESTRUCTOR block in the NMODL.
Represents a CONSTRUCTOR block in the NMODL.
-void visit_non_linear_block(const ast::NonLinearBlock &node) override
visit node of type ast::NonLinearBlock
-void visit_after_block(const ast::AfterBlock &node) override
visit node of type ast::AfterBlock
-void find_range_variables()
Find range variables i.e.
+void visit_non_linear_block(const ast::NonLinearBlock &node) override
visit node of type ast::NonLinearBlock
+void visit_after_block(const ast::AfterBlock &node) override
visit node of type ast::AfterBlock
+void find_range_variables()
Find range variables i.e.
void visit_children(visitor::Visitor &v) override
visit children i.e.
-bool is_intra_cell_conc(const std::string &text) const
Check if variable name is internal cell concentration.
-void visit_watch(const ast::Watch &node) override
visit node of type ast::Watch
+bool is_intra_cell_conc(const std::string &text) const
Check if variable name is internal cell concentration.
+void visit_watch(const ast::Watch &node) override
visit node of type ast::Watch
std::string to_string(const T &obj)
void visit_children(visitor::Visitor &v) override
visit children i.e.
-bool is_extra_cell_conc(const std::string &text) const
Check if variable name is external cell concentration.
+bool is_extra_cell_conc(const std::string &text) const
Check if variable name is external cell concentration.
static void sort_with_mod2c_symbol_order(std::vector< SymbolType > &symbols)
How symbols are stored in NEURON? See notes written in markdown file.
-void visit_watch_statement(const ast::WatchStatement &node) override
visit node of type ast::WatchStatement
+void visit_watch_statement(const ast::WatchStatement &node) override
visit node of type ast::WatchStatement
const BinaryOperator & get_op() const noexcept
Getter for member variable BinaryExpression::op.
-void visit_procedure_block(const ast::ProcedureBlock &node) override
visit node of type ast::ProcedureBlock
-void visit_before_block(const ast::BeforeBlock &node) override
visit node of type ast::BeforeBlock
+void visit_procedure_block(const ast::ProcedureBlock &node) override
visit node of type ast::ProcedureBlock
+void visit_before_block(const ast::BeforeBlock &node) override
visit node of type ast::BeforeBlock
Represents DERIVATIVE block in the NMODL.
std::string eval() const
Return enum value in string form.
-codegen::CodegenInfo analyze(const ast::Program &node)
run visitor and return information for code generation
+codegen::CodegenInfo analyze(const ast::Program &node)
run visitor and return information for code generation
void visit_children(visitor::Visitor &v) override
visit children i.e.
Represent linear solver solution block based on Eigen.
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
Statement to indicate a change in timestep in a given block.
-void visit_net_receive_block(const ast::NetReceiveBlock &node) override
visit node of type ast::NetReceiveBlock
-void find_table_variables()
+void visit_net_receive_block(const ast::NetReceiveBlock &node) override
visit node of type ast::NetReceiveBlock
+void find_table_variables()
Represents the coreneuron nrn_state callback function.
Represents block encapsulating list of statements.
NmodlType
NMODL variable properties.
-void visit_linear_block(const ast::LinearBlock &node) override
visit node of type ast::LinearBlock
+void visit_linear_block(const ast::LinearBlock &node) override
visit node of type ast::LinearBlock
const NodeVector & get_blocks() const noexcept
Getter for member variable Program::blocks.
void visit_children(visitor::Visitor &v) override
visit children i.e.
Represents LINEAR block in the NMODL.
Represent a callback to NEURON's derivimplicit solver.
-void find_non_range_variables()
Find non-range variables i.e.
+void find_non_range_variables()
Find non-range variables i.e.
void visit_children(visitor::Visitor &v) override
visit children i.e.
-void visit_derivimplicit_callback(const ast::DerivimplicitCallback &node) override
visit node of type ast::DerivimplicitCallback
+void visit_derivimplicit_callback(const ast::DerivimplicitCallback &node) override
visit node of type ast::DerivimplicitCallback
void find_ion_variables(const ast::Program &node)
Find all ions used in mod file.
Represents NONLINEAR block in the NMODL.
-void visit_derivative_block(const ast::DerivativeBlock &node) override
visit node of type ast::DerivativeBlock
-void visit_function_table_block(const ast::FunctionTableBlock &node) override
visit node of type ast::FunctionTableBlock
-void visit_bbcore_pointer(const ast::BbcorePointer &node) override
visit node of type ast::BbcorePointer
+void visit_derivative_block(const ast::DerivativeBlock &node) override
visit node of type ast::DerivativeBlock
+void visit_function_table_block(const ast::FunctionTableBlock &node) override
visit node of type ast::FunctionTableBlock
+void visit_bbcore_pointer(const ast::BbcorePointer &node) override
visit node of type ast::BbcorePointer
static constexpr char NET_EVENT_METHOD[]
net_event function call in nmodl
symtab::SymbolTable * get_symbol_table() const override
Return associated symbol table for the current ast node.
-void visit_verbatim(const ast::Verbatim &node) override
visit verbatim block and find all symbols used
+void visit_verbatim(const ast::Verbatim &node) override
visit verbatim block and find all symbols used
Represents BBCOREPOINTER statement in NMODL.
std::shared_ptr< Expression > get_lhs() const noexcept
Getter for member variable BinaryExpression::lhs.
static constexpr char AREA_VARIABLE[]
similar to node_area but user can explicitly declare it as area
@@ -998,17 +1009,17 @@
Represents a AFTER block in NMODL.
static constexpr char DIAM_VARIABLE[]
inbuilt neuron variable for diameter of the compartment
Represents ELECTRODE_CURRENT variables statement in NMODL.
-void visit_initial_block(const ast::InitialBlock &node) override
visit node of type ast::InitialBlock
-void visit_nrn_state_block(const ast::NrnStateBlock &node) override
visit node of type ast::NrnStateBlock
+void visit_initial_block(const ast::InitialBlock &node) override
visit node of type ast::InitialBlock
+void visit_nrn_state_block(const ast::NrnStateBlock &node) override
visit node of type ast::NrnStateBlock
Represents binary expression in the NMODL.
-void visit_constructor_block(const ast::ConstructorBlock &node) override
visit node of type ast::ConstructorBlock
+void visit_constructor_block(const ast::ConstructorBlock &node) override
visit node of type ast::ConstructorBlock
void visit_children(visitor::Visitor &v) override
visit children i.e.
Auto generated AST classes declaration.
-std::vector< std::string > reads
ion variables that are being read
+std::vector< std::string > reads
ion variables that are being read
static constexpr char NET_SEND_METHOD[]
net_send function call in nmodl
void visit_children(visitor::Visitor &v) override
visit children i.e.
void visit_children(visitor::Visitor &v) override
visit children i.e.
-void visit_suffix(const ast::Suffix &node) override
visit node of type ast::Suffix
+void visit_suffix(const ast::Suffix &node) override
visit node of type ast::Suffix
diff --git a/doxygen/codegen__helper__visitor_8hpp_source.html b/doxygen/codegen__helper__visitor_8hpp_source.html
index f5e8be458..8c3857264 100644
--- a/doxygen/codegen__helper__visitor_8hpp_source.html
+++ b/doxygen/codegen__helper__visitor_8hpp_source.html
@@ -222,93 +222,93 @@