8 #include <catch2/catch_test_macros.hpp>
18 using namespace nmodl;
19 using namespace visitor;
20 using namespace test_utils;
30 std::map<std::string, std::string> rval;
41 SCENARIO(
"LOCAL to ASSIGNED variable transformer",
"[visitor][localtoassigned]") {
42 GIVEN(
"mod file with LOCAL variables that are written") {
43 std::string input_nmodl = R
"(
60 auto symtab = ast->get_symbol_table();
62 THEN(
"LOCAL variables that are written are turned to ASSIGNED") {
64 auto vars = symtab->get_variables_with_properties(NmodlType::assigned_definition);
65 REQUIRE(vars.size() == 2);
68 auto x = symtab->lookup(
"x");
69 REQUIRE(x !=
nullptr);
70 REQUIRE(x->has_any_property(NmodlType::assigned_definition) ==
true);
71 REQUIRE(x->has_any_property(NmodlType::local_var) ==
false);
73 auto z = symtab->lookup(
"z");
74 REQUIRE(z !=
nullptr);
75 REQUIRE(z->has_any_property(NmodlType::assigned_definition) ==
true);
76 REQUIRE(z->has_any_property(NmodlType::local_var) ==
false);
79 THEN(
"LOCAL variables that are read only remain LOCAL") {
80 auto vars = symtab->get_variables_with_properties(NmodlType::local_var);
81 REQUIRE(vars.size() == 1);
Class that binds all pieces together for parsing nmodl file.
Visitor to convert top level LOCAL variables to ASSIGNED variables.
void visit_program(ast::Program &node) override
Visit ast::Program node to transform top level LOCAL variables to ASSIGNED if they are written in the...
Visitor for measuring performance related information
void visit_program(const ast::Program &node) override
visit node of type ast::Program
Concrete visitor for constructing symbol table from AST.
void visit_program(ast::Program &node) override
visit node of type ast::Program
bool parse_string(const std::string &input)
parser Units provided as string (used for testing)
SCENARIO("LOCAL to ASSIGNED variable transformer", "[visitor][localtoassigned]")
std::shared_ptr< ast::Program > run_local_to_assigned_visitor(const std::string &text)
Visitor to convert top level LOCAL variables to ASSIGNED variables.
auto get_name(Tag const &tag, int field_index)
Get the nicest available name for the field_index-th instance of Tag.
NmodlType
NMODL variable properties.
encapsulates code generation backend implementations
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
Visitor for measuring performance related information
Auto generated AST classes declaration.
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::parser::UnitDriver driver