Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.
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
11 changes: 8 additions & 3 deletions src/codegen/codegen_c_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1606,12 +1606,17 @@ void CodegenCVisitor::print_table_replacement_function(const ast::Block& node) {
print_function_declaration(node, name);
printer->start_block();
{
printer->add_line("if ( {} == 0) {}"_format(use_table_var, "{"));
printer->add_line(" {}({}, arg_v);"_format(function_name, internal_method_arguments()));
const auto& params = node.get_parameters();
printer->add_line("if ( {} == 0) {{"_format(use_table_var));
printer->add_line(" {}({}, {});"_format(function_name,
internal_method_arguments(),
params[0].get()->get_node_name()));
printer->add_line(" return 0;");
printer->add_line("}");

printer->add_line("double xi = {} * (arg_v - {});"_format(mfac_name, tmin_name));
printer->add_line("double xi = {} * ({} - {});"_format(mfac_name,
params[0].get()->get_node_name(),
tmin_name));
printer->add_line("if (isnan(xi)) {");
for (const auto& var: table_variables) {
auto name = get_variable_name(var->get_node_name());
Expand Down
21 changes: 8 additions & 13 deletions test/integration/mod/cabpump.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ NEURON {
RANGE ca
GLOBAL depth,cainf,taur
RANGE var

RANGE ainf
}

UNITS {
Expand All @@ -18,18 +18,6 @@ UNITS {
FARADAY = (faraday) (coul)
}

CONSTRUCTOR {
VERBATIM
// Nothing only to verify that it is well handled
ENDVERBATIM
}

DESTRUCTOR {
VERBATIM
// Nothing only to verify that it is well handled
ENDVERBATIM
}

PARAMETER {
depth = .1 (um)
taur = 200 (ms) : rate of calcium removal for stress conditions
Expand All @@ -41,6 +29,7 @@ ASSIGNED {
ica (mA/cm2)
drive_channel (mM/ms)
var (mV)
ainf
}

STATE {
Expand All @@ -64,6 +53,12 @@ DERIVATIVE state {
cai = ca
}

: to test code generation for TABLE statement
PROCEDURE test_table(br) {
TABLE ainf FROM 0 TO 1 WITH 1
ainf = 1
}

INITIAL {
var_init(var)
ca = cainf
Expand Down
12 changes: 12 additions & 0 deletions test/integration/mod/watch_test.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ ASSIGNED {
g (umho)
}

CONSTRUCTOR {
VERBATIM
// only to verify that it is well handled
ENDVERBATIM
}

DESTRUCTOR {
VERBATIM
// only to verify that it is well handled
ENDVERBATIM
}

DEFINE init 1
DEFINE rise 2
DEFINE fall 3
Expand Down