diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-04-29 22:19:55 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-04-30 21:45:06 (GMT) |
commit | e8ae46e5e228cc3008e64766e6c8da48b1835545 (patch) | |
tree | ca07a9e66661fc14f3cba7618b3f0745a71f4f8a | |
parent | 30a021cc224d420725bd7e88277cc3cca7c67ae4 (diff) | |
download | CMake-e8ae46e5e228cc3008e64766e6c8da48b1835545.zip CMake-e8ae46e5e228cc3008e64766e6c8da48b1835545.tar.gz CMake-e8ae46e5e228cc3008e64766e6c8da48b1835545.tar.bz2 |
cmMakefile: Implement RaiseScope without relying on Parent.
-rw-r--r-- | Source/cmMakefile.cxx | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 4bbd5f1..5686b1b 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -117,34 +117,38 @@ public: bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf) { - cmDefinitions& cur = this->VarStack.back(); - if(cmDefinitions* up = cur.GetParent()) - { - // First localize the definition in the current scope. - this->GetDefinition(var); + assert(this->VarStack.size() > 0); - // Now update the definition in the parent scope. - up->Set(var, varDef); - } - else if(cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent()) + std::list<cmDefinitions>::reverse_iterator it = this->VarStack.rbegin(); + ++it; + if(it == this->VarStack.rend()) { - // 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) + if(cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent()) { - 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 { - parent->RemoveDefinition(var); + return false; } } - else - { - 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; } }; |