From aaaa65b6a5cdf227282a9d04bf5287413757ff03 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 25 Apr 2015 17:21:51 +0200 Subject: cmMakefile: Remove stack adaptor for the VarStack. The purpose of the stack is to allow access only to the top of it. Access to items which are not at the top is needed, so cmDefinitions objects get a Parent pointer. The existence of the Parent pointer is a workaround for the inappropriate use of stack in the first place. Remove it now. --- Source/cmMakefile.cxx | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index dbb355c..8cfb83a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -46,7 +46,7 @@ class cmMakefile::Internals { public: - std::stack > VarStack; + std::list VarStack; std::stack > VarInitStack; std::stack > VarUsageStack; bool IsSourceFileTryCompile; @@ -56,24 +56,24 @@ public: cmDefinitions* parent = 0; if (!this->VarStack.empty()) { - parent = &this->VarStack.top(); + parent = &this->VarStack.back(); } - this->VarStack.push(cmDefinitions(parent)); + this->VarStack.push_back(cmDefinitions(parent)); } void InitializeDefinitions(cmMakefile* parent) { - this->VarStack.top() = parent->Internal->VarStack.top().MakeClosure(); + this->VarStack.back() = parent->Internal->VarStack.back().MakeClosure(); } const char* GetDefinition(std::string const& name) { - return this->VarStack.top().Get(name); + return this->VarStack.back().Get(name); } void SetDefinition(std::string const& name, std::string const& value) { - this->VarStack.top().Set(name, value.c_str()); + this->VarStack.back().Set(name, value.c_str()); } void RemoveDefinition(std::string const& name) @@ -81,32 +81,32 @@ public: if (this->VarStack.size() > 1) { // In lower scopes we store keys, defined or not. - this->VarStack.top().Set(name, 0); + this->VarStack.back().Set(name, 0); } else { - this->VarStack.top().Erase(name); + this->VarStack.back().Erase(name); } } std::vector LocalKeys() const { - return this->VarStack.top().LocalKeys(); + return this->VarStack.back().LocalKeys(); } std::vector ClosureKeys() const { - return this->VarStack.top().ClosureKeys(); + return this->VarStack.back().ClosureKeys(); } void PopDefinitions() { - this->VarStack.pop(); + this->VarStack.pop_back(); } bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf) { - cmDefinitions& cur = this->VarStack.top(); + cmDefinitions& cur = this->VarStack.back(); if(cmDefinitions* up = cur.GetParent()) { // First localize the definition in the current scope. -- cgit v0.12