mirror of
https://github.com/jezhiggins/arabica
synced 2024-11-17 07:48:50 +01:00
When declaring a parameter, only create a new variable closure if a parameter
hasn't been passed.
This commit is contained in:
parent
2ea1ab8971
commit
29f73f285b
2 changed files with 12 additions and 6 deletions
|
@ -178,7 +178,8 @@ void ExecutionContext::unpassParam(const std::string& name)
|
|||
|
||||
void ExecutionContext::declareParam(const DOM::Node<std::string>& node, const Variable_declaration& param)
|
||||
{
|
||||
stack_.declareParam(VariableClosure::create(param, node, *this));
|
||||
if(!stack_.findPassedParam(param.name()))
|
||||
stack_.declareParam(VariableClosure::create(param, node, *this));
|
||||
} // declareParam
|
||||
|
||||
void ExecutionContext::declareVariable(const DOM::Node<std::string>& node, const Variable_declaration& variable)
|
||||
|
|
|
@ -89,14 +89,19 @@ public:
|
|||
params_.back().erase(name);
|
||||
} // unpassParam
|
||||
|
||||
void declareParam(Variable_instance_ptr param)
|
||||
bool findPassedParam(const std::string& name)
|
||||
{
|
||||
ScopeStack::reverse_iterator p = params_.rbegin()+1;
|
||||
Scope::iterator i = p->find(param->name());
|
||||
Scope::iterator i = p->find(name);
|
||||
if(i == p->end())
|
||||
declareVariable(param);
|
||||
else
|
||||
declareVariable(i->second);
|
||||
return false;
|
||||
declareVariable(i->second);
|
||||
return true;
|
||||
} // findPassedParam
|
||||
|
||||
void declareParam(Variable_instance_ptr param)
|
||||
{
|
||||
declareVariable(param);
|
||||
} // declareParam
|
||||
|
||||
void declareVariable(Variable_instance_ptr var)
|
||||
|
|
Loading…
Reference in a new issue