cmMakefile: Implement RaiseScope without relying on Parent.

This commit is contained in:
Stephen Kelly 2015-04-30 00:19:55 +02:00
parent 30a021cc22
commit e8ae46e5e2

View File

@ -117,16 +117,13 @@ 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.
this->GetDefinition(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()) {
if(cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent())
{ {
// Update the definition in the parent directory top scope. This // Update the definition in the parent directory top scope. This
// directory's scope was initialized by the closure of the parent // directory's scope was initialized by the closure of the parent
@ -140,11 +137,18 @@ public:
{ {
parent->RemoveDefinition(var); parent->RemoveDefinition(var);
} }
return true;
} }
else else
{ {
return false; return false;
} }
}
// First localize the definition in the current scope.
this->GetDefinition(var);
// Now update the definition in the parent scope.
it->Set(var, varDef);
return true; return true;
} }
}; };