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

time-shift
Sébastien Villemot 2010-03-16 12:16:07 +01:00
parent 208210c6fd
commit 4b96b35dad
4 changed files with 9 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -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;
}