Merge topic 'refactor-RaiseScope'
e8ae46e5
cmMakefile: Implement RaiseScope without relying on Parent.30a021cc
cmMakefile: Implement RaiseScope in terms of local Get method.
This commit is contained in:
commit
514640411a
|
@ -117,34 +117,38 @@ public:
|
||||||
|
|
||||||
bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf)
|
bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf)
|
||||||
{
|
{
|
||||||
cmDefinitions& cur = this->VarStack.back();
|
assert(this->VarStack.size() > 0);
|
||||||
if(cmDefinitions* up = cur.GetParent())
|
|
||||||
{
|
|
||||||
// First localize the definition in the current scope.
|
|
||||||
cur.Get(var);
|
|
||||||
|
|
||||||
// Now update the definition in the parent scope.
|
std::list<cmDefinitions>::reverse_iterator it = this->VarStack.rbegin();
|
||||||
up->Set(var, varDef);
|
++it;
|
||||||
}
|
if(it == this->VarStack.rend())
|
||||||
else if(cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent())
|
|
||||||
{
|
{
|
||||||
// Update the definition in the parent directory top scope. This
|
if(cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent())
|
||||||
// directory's scope was initialized by the closure of the parent
|
|
||||||
// scope, so we do not need to localize the definition first.
|
|
||||||
cmMakefile* parent = plg->GetMakefile();
|
|
||||||
if (varDef)
|
|
||||||
{
|
{
|
||||||
parent->AddDefinition(var, varDef);
|
// Update the definition in the parent directory top scope. This
|
||||||
|
// directory's scope was initialized by the closure of the parent
|
||||||
|
// scope, so we do not need to localize the definition first.
|
||||||
|
cmMakefile* parent = plg->GetMakefile();
|
||||||
|
if (varDef)
|
||||||
|
{
|
||||||
|
parent->AddDefinition(var, varDef);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
parent->RemoveDefinition(var);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parent->RemoveDefinition(var);
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
// First localize the definition in the current scope.
|
||||||
{
|
this->GetDefinition(var);
|
||||||
return false;
|
|
||||||
}
|
// Now update the definition in the parent scope.
|
||||||
|
it->Set(var, varDef);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue