Commit 4b96b35d authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Preprocessor: changed the prototype of DataTree::AddLocalVariable()

parent 208210c6
......@@ -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<int, NodeID>::iterator it = local_variables_table.find(id);
map<int, NodeID>::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
......
......@@ -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<NodeID> &arguments);
//! Adds an external function node
......
......@@ -2455,7 +2455,7 @@ DynamicModel::toStatic(StaticModel &static_model) const
// Convert model local variables (need to be done first)
for (map<int, NodeID>::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<BinaryOpNode *>::const_iterator it = equations.begin();
......
......@@ -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;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment