1818namespace nmodl {
1919namespace codegen {
2020
21- using namespace fmt ::literals;
22-
2321using symtab::syminfo::Status;
2422
2523// / initialize static member variables
@@ -148,7 +146,7 @@ void CodegenLLVMHelperVisitor::create_function_for_node(ast::Block& node) {
148146 auto name = new ast::Name (new ast::String (function_name));
149147
150148 // / return variable name has "ret_" prefix
151- std::string return_var_name = " ret_{}" _format ( function_name);
149+ std::string return_var_name = fmt::format ( " ret_{}" , function_name);
152150 auto return_var = new ast::Name (new ast::String (return_var_name));
153151
154152 // / return type based on node type
@@ -337,11 +335,12 @@ void CodegenLLVMHelperVisitor::ion_read_statements(BlockType type,
337335 // ion variable to be read
338336 std::string& ion_varname = variable_names.second ;
339337 // index for reading ion variable
340- std::string index_varname = " {}_id" _format ( varname);
338+ std::string index_varname = fmt::format ( " {}_id" , varname);
341339 // first load the index
342- std::string index_statement = " {} = {}_index[id]" _format ( index_varname, ion_varname);
340+ std::string index_statement = fmt::format ( " {} = {}_index[id]" , index_varname, ion_varname);
343341 // now assign the value
344- std::string read_statement = " {} = {}[{}]" _format (varname, ion_varname, index_varname);
342+ std::string read_statement =
343+ fmt::format (" {} = {}[{}]" , varname, ion_varname, index_varname);
345344 // push index definition, index statement and actual read statement
346345 int_variables.push_back (index_varname);
347346 index_statements.push_back (visitor::create_statement (index_statement));
@@ -398,9 +397,9 @@ void CodegenLLVMHelperVisitor::ion_write_statements(BlockType type,
398397 // / create write ion and corresponding index statements
399398 auto create_write_statements = [&](std::string ion_varname, std::string op, std::string rhs) {
400399 // index for writing ion variable
401- std::string index_varname = " {}_id" _format ( ion_varname);
400+ std::string index_varname = fmt::format ( " {}_id" , ion_varname);
402401 // load index
403- std::string index_statement = " {} = {}_index[id]" _format ( index_varname, ion_varname);
402+ std::string index_statement = fmt::format ( " {} = {}_index[id]" , index_varname, ion_varname);
404403 // push index definition, index statement and actual write statement
405404 int_variables.push_back (index_varname);
406405 index_statements.push_back (visitor::create_statement (index_statement));
@@ -425,7 +424,7 @@ void CodegenLLVMHelperVisitor::ion_write_statements(BlockType type,
425424 // for synapse type
426425 if (info.point_process ) {
427426 auto area = codegen::naming::NODE_AREA_VARIABLE;
428- rhs += " *(1.e2/{0}[{0}_id])" _format ( area);
427+ rhs += fmt::format ( " *(1.e2/{0}[{0}_id])" , area);
429428 }
430429 create_write_statements (lhs, op, rhs);
431430 }
@@ -449,10 +448,10 @@ void CodegenLLVMHelperVisitor::ion_write_statements(BlockType type,
449448 index = 2 ;
450449 } else {
451450 // / \todo Unhandled case also in neuron implementation
452- throw std::logic_error (" codegen error for {} ion" _format ( ion.name ));
451+ throw std::logic_error (fmt::format ( " codegen error for {} ion" , ion.name ));
453452 }
454- std::string ion_type_name = " {}_type" _format ( ion.name );
455- std::string lhs = " int {}" _format ( ion_type_name);
453+ std::string ion_type_name = fmt::format ( " {}_type" , ion.name );
454+ std::string lhs = fmt::format ( " int {}" , ion_type_name);
456455 std::string op = " =" ;
457456 std::string rhs = ion_type_name;
458457 create_write_statements (lhs, op, rhs);
@@ -557,7 +556,7 @@ void CodegenLLVMHelperVisitor::rename_local_variables(ast::StatementBlock& node)
557556 // / rename local variable in entire statement block
558557 for (auto & var: local_statement->get_variables ()) {
559558 std::string old_name = var->get_node_name ();
560- std::string new_name = " {}_{}" _format ( old_name, local_block_counter);
559+ std::string new_name = fmt::format ( " {}_{}" , old_name, local_block_counter);
561560 visitor::RenameVisitor (old_name, new_name).visit_statement_block (node);
562561 }
563562 }
@@ -668,9 +667,10 @@ void CodegenLLVMHelperVisitor::visit_nrn_state_block(ast::NrnStateBlock& node) {
668667 // prepare main body of the compute function
669668 {
670669 // / access node index and corresponding voltage
671- index_statements.push_back (
672- visitor::create_statement (" node_id = node_index[{}]" _format (naming::INDUCTION_VAR)));
673- body_statements.push_back (visitor::create_statement (" v = {}[node_id]" _format (VOLTAGE_VAR)));
670+ index_statements.push_back (visitor::create_statement (
671+ fmt::format (" node_id = node_index[{}]" , naming::INDUCTION_VAR)));
672+ body_statements.push_back (
673+ visitor::create_statement (fmt::format (" v = {}[node_id]" , VOLTAGE_VAR)));
674674
675675 // / read ion variables
676676 ion_read_statements (
@@ -870,11 +870,11 @@ void CodegenLLVMHelperVisitor::print_nrn_current_body(const ast::BreakpointBlock
870870 // sum now all currents
871871 for (auto & current: info.currents ) {
872872 statements.emplace_back (
873- visitor::create_statement (" current = current + {}" _format ( current)));
873+ visitor::create_statement (fmt::format ( " current = current + {}" , current)));
874874 }
875875
876876 // assign computed current to the given variable
877- statements.emplace_back (visitor::create_statement (" {} = current" _format ( variable)));
877+ statements.emplace_back (visitor::create_statement (fmt::format ( " {} = current" , variable)));
878878
879879 // create StatementBlock for better readability of the generated code and add that to the main
880880 // body statements
@@ -913,10 +913,10 @@ void CodegenLLVMHelperVisitor::print_nrn_cur_non_conductance_kernel(
913913 for (const auto & var: ion.writes ) {
914914 if (ion.is_ionic_current (var)) {
915915 // also create local variable
916- std::string name{" di{}" _format ( ion.name )};
916+ std::string name{fmt::format ( " di{}" , ion.name )};
917917 double_variables.emplace_back (name);
918918 body_statements.emplace_back (
919- visitor::create_statement (" {} = {}" _format ( name, var)));
919+ visitor::create_statement (fmt::format ( " {} = {}" , name, var)));
920920 }
921921 }
922922 }
@@ -931,32 +931,32 @@ void CodegenLLVMHelperVisitor::print_nrn_cur_non_conductance_kernel(
931931 // in case of point process we need to load area from another vector.
932932 if (info.point_process ) {
933933 // create integer variable for index and then load value from area_index vector
934- int_variables.emplace_back (" {}_id" _format ( naming::NODE_AREA_VARIABLE));
934+ int_variables.emplace_back (fmt::format ( " {}_id" , naming::NODE_AREA_VARIABLE));
935935 index_statements.emplace_back (visitor::create_statement (
936- " {0}_id = {0}_index[id]" _format ( naming::NODE_AREA_VARIABLE)));
936+ fmt::format ( " {0}_id = {0}_index[id]" , naming::NODE_AREA_VARIABLE)));
937937 }
938938
939939 // update all ionic currents now
940940 for (const auto & ion: info.ions ) {
941941 for (const auto & var: ion.writes ) {
942942 if (ion.is_ionic_current (var)) {
943943 // variable on the lhs
944- std::string lhs{" {}di{}dv" _format ( naming::ION_VARNAME_PREFIX, ion.name )};
944+ std::string lhs{fmt::format ( " {}di{}dv" , naming::ION_VARNAME_PREFIX, ion.name )};
945945
946946 // expression on the rhs
947- std::string rhs{" (di{}-{})/0.001" _format ( ion.name , var)};
947+ std::string rhs{fmt::format ( " (di{}-{})/0.001" , ion.name , var)};
948948 if (info.point_process ) {
949- rhs += " *1.e2/{0}[{0}_id]" _format ( naming::NODE_AREA_VARIABLE);
949+ rhs += fmt::format ( " *1.e2/{0}[{0}_id]" , naming::NODE_AREA_VARIABLE);
950950 }
951951
952952 // load the index for lhs variable
953953 int_variables.emplace_back (lhs + " _id" );
954- std::string index_statement{" {}_id = {}_index[id]" _format ( lhs, lhs)};
954+ std::string index_statement{fmt::format ( " {}_id = {}_index[id]" , lhs, lhs)};
955955 index_statements.emplace_back (visitor::create_statement (index_statement));
956956
957957 // add statement that actually updates the
958- body_statements.emplace_back (
959- visitor::create_statement (" {0}[{0}_id] = {0}[{0}_id] + {1}" _format ( lhs, rhs)));
958+ body_statements.emplace_back (visitor::create_statement (
959+ fmt::format (" {0}[{0}_id] = {0}[{0}_id] + {1}" , lhs, rhs)));
960960 }
961961 }
962962 }
@@ -989,9 +989,10 @@ void CodegenLLVMHelperVisitor::visit_breakpoint_block(ast::BreakpointBlock& node
989989 // / prepare all function statements
990990 {
991991 // / access node index and corresponding voltage
992- index_statements.push_back (
993- visitor::create_statement (" node_id = node_index[{}]" _format (naming::INDUCTION_VAR)));
994- body_statements.push_back (visitor::create_statement (" v = {}[node_id]" _format (VOLTAGE_VAR)));
992+ index_statements.push_back (visitor::create_statement (
993+ fmt::format (" node_id = node_index[{}]" , naming::INDUCTION_VAR)));
994+ body_statements.push_back (
995+ visitor::create_statement (fmt::format (" v = {}[node_id]" , VOLTAGE_VAR)));
995996
996997 // / read ion variables
997998 ion_read_statements (BlockType::Equation,
@@ -1020,7 +1021,7 @@ void CodegenLLVMHelperVisitor::visit_breakpoint_block(ast::BreakpointBlock& node
10201021 if (info.point_process ) {
10211022 double_variables.emplace_back (" mfactor" );
10221023 body_statements.emplace_back (visitor::create_statement (
1023- " mfactor = 1.e2/{0}[{0}_id]" _format ( naming::NODE_AREA_VARIABLE)));
1024+ fmt::format ( " mfactor = 1.e2/{0}[{0}_id]" , naming::NODE_AREA_VARIABLE)));
10241025 body_statements.emplace_back (visitor::create_statement (" g = g*mfactor" ));
10251026 body_statements.emplace_back (visitor::create_statement (" rhs = rhs*mfactor" ));
10261027 }
@@ -1046,9 +1047,9 @@ void CodegenLLVMHelperVisitor::visit_breakpoint_block(ast::BreakpointBlock& node
10461047 stringutils::remove_character (d_op, ' =' );
10471048
10481049 body_statements.emplace_back (visitor::create_statement (
1049- " vec_rhs[node_id] = vec_rhs[node_id] {} rhs" _format ( rhs_op)));
1050- body_statements.emplace_back (
1051- visitor::create_statement (" vec_d[node_id] = vec_d[node_id] {} g" _format ( d_op)));
1050+ fmt::format ( " vec_rhs[node_id] = vec_rhs[node_id] {} rhs" , rhs_op)));
1051+ body_statements.emplace_back (visitor::create_statement (
1052+ fmt::format (" vec_d[node_id] = vec_d[node_id] {} g" , d_op)));
10521053 }
10531054 }
10541055
0 commit comments