diff --git a/preprocessor/DataTree.cc b/preprocessor/DataTree.cc index 6eba15a0f..c38d16ac4 100644 --- a/preprocessor/DataTree.cc +++ b/preprocessor/DataTree.cc @@ -457,18 +457,16 @@ DataTree::AddEqual(NodeID iArg1, NodeID iArg2) } void -DataTree::AddLocalVariable(const string &name, NodeID value) throw (LocalVariableException) +DataTree::AddLocalVariable(int symb_id, NodeID value) throw (LocalVariableException) { - int id = symbol_table.getID(name); - - assert(symbol_table.getType(id) == eModelLocalVariable); + assert(symbol_table.getType(symb_id) == eModelLocalVariable); // Throw an exception if symbol already declared - map::iterator it = local_variables_table.find(id); + map::iterator it = local_variables_table.find(symb_id); if (it != local_variables_table.end()) - throw LocalVariableException(name); + throw LocalVariableException(symbol_table.getName(symb_id)); - local_variables_table[id] = value; + local_variables_table[symb_id] = value; } NodeID diff --git a/preprocessor/DataTree.hh b/preprocessor/DataTree.hh index 8072ba59e..de50a52b7 100644 --- a/preprocessor/DataTree.hh +++ b/preprocessor/DataTree.hh @@ -189,7 +189,7 @@ public: //! Adds "arg1=arg2" to model tree NodeID AddEqual(NodeID iArg1, NodeID iArg2); //! Adds a model local variable with its value - void AddLocalVariable(const string &name, NodeID value) throw (LocalVariableException); + void AddLocalVariable(int symb_id, NodeID value) throw (LocalVariableException); //! Adds an external function node NodeID AddExternalFunction(const string &function_name, const vector &arguments); //! Adds an external function node diff --git a/preprocessor/DynamicModel.cc b/preprocessor/DynamicModel.cc index 28812b20e..7bd7795c9 100644 --- a/preprocessor/DynamicModel.cc +++ b/preprocessor/DynamicModel.cc @@ -2455,7 +2455,7 @@ DynamicModel::toStatic(StaticModel &static_model) const // Convert model local variables (need to be done first) for (map::const_iterator it = local_variables_table.begin(); it != local_variables_table.end(); it++) - static_model.AddLocalVariable(symbol_table.getName(it->first), it->second->toStatic(static_model)); + static_model.AddLocalVariable(it->first, it->second->toStatic(static_model)); // Convert equations for (vector::const_iterator it = equations.begin(); diff --git a/preprocessor/ParsingDriver.cc b/preprocessor/ParsingDriver.cc index 33cd1e765..0582eba3d 100644 --- a/preprocessor/ParsingDriver.cc +++ b/preprocessor/ParsingDriver.cc @@ -1399,7 +1399,8 @@ ParsingDriver::declare_and_init_model_local_variable(string *name, NodeID rhs) error("Local model variable " + *name + " declared twice."); } - model_tree->AddLocalVariable(*name, rhs); + int symb_id = mod_file->symbol_table.getID(*name); + model_tree->AddLocalVariable(symb_id, rhs); delete name; }