summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmDefinitions.cxx14
-rw-r--r--Source/cmDefinitions.h17
-rw-r--r--Source/cmMakefile.cxx41
3 files changed, 39 insertions, 33 deletions
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 2dab169..b06fb5c 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -56,9 +56,9 @@ void cmDefinitions::Raise(const std::string& key,
}
bool cmDefinitions::HasKey(const std::string& key,
- StackConstIter begin, StackConstIter end)
+ StackIter begin, StackIter end)
{
- for (StackConstIter it = begin; it != end; ++it)
+ for (StackIter it = begin; it != end; ++it)
{
MapType::const_iterator i = it->Map.find(key);
if (i != it->Map.end())
@@ -94,12 +94,12 @@ std::vector<std::string> cmDefinitions::UnusedKeys() const
}
//----------------------------------------------------------------------------
-cmDefinitions cmDefinitions::MakeClosure(StackConstIter begin,
- StackConstIter end)
+cmDefinitions cmDefinitions::MakeClosure(StackIter begin,
+ StackIter end)
{
cmDefinitions closure;
std::set<std::string> undefined;
- for (StackConstIter it = begin; it != end; ++it)
+ for (StackIter it = begin; it != end; ++it)
{
// Consider local definitions.
for(MapType::const_iterator mi = it->Map.begin();
@@ -125,12 +125,12 @@ cmDefinitions cmDefinitions::MakeClosure(StackConstIter begin,
//----------------------------------------------------------------------------
std::vector<std::string>
-cmDefinitions::ClosureKeys(StackConstIter begin, StackConstIter end)
+cmDefinitions::ClosureKeys(StackIter begin, StackIter end)
{
std::set<std::string> bound;
std::vector<std::string> defined;
- for (StackConstIter it = begin; it != end; ++it)
+ for (StackIter it = begin; it != end; ++it)
{
defined.reserve(defined.size() + it->Map.size());
for(MapType::const_iterator mi = it->Map.begin();
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 5fdcaab..411867c 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -13,6 +13,9 @@
#define cmDefinitions_h
#include "cmStandardIncludes.h"
+
+#include "cmLinkedTree.h"
+
#if defined(CMAKE_BUILD_WITH_CMAKE)
#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
#include <unordered_map>
@@ -32,26 +35,26 @@
*/
class cmDefinitions
{
- typedef std::list<cmDefinitions>::reverse_iterator StackIter;
- typedef std::list<cmDefinitions>::const_reverse_iterator StackConstIter;
+ typedef cmLinkedTree<cmDefinitions>::iterator StackIter;
public:
static const char* Get(const std::string& key,
StackIter begin, StackIter end);
- static void Raise(const std::string& key, StackIter begin, StackIter end);
+ static void Raise(const std::string& key,
+ StackIter begin, StackIter end);
static bool HasKey(const std::string& key,
- StackConstIter begin, StackConstIter end);
+ StackIter begin, StackIter end);
/** Set (or unset if null) a value associated with a key. */
void Set(const std::string& key, const char* value);
std::vector<std::string> UnusedKeys() const;
- static std::vector<std::string> ClosureKeys(StackConstIter begin,
- StackConstIter end);
+ static std::vector<std::string> ClosureKeys(StackIter begin,
+ StackIter end);
- static cmDefinitions MakeClosure(StackConstIter begin, StackConstIter end);
+ static cmDefinitions MakeClosure(StackIter begin, StackIter end);
private:
// String with existence boolean.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 5b2499b..afb0166 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -47,70 +47,73 @@
class cmMakefile::Internals
{
public:
- std::list<cmDefinitions> VarStack;
+ cmLinkedTree<cmDefinitions> VarTree;
+ cmLinkedTree<cmDefinitions>::iterator VarTreeIter;
bool IsSourceFileTryCompile;
void PushDefinitions()
{
- this->VarStack.push_back(cmDefinitions());
+ assert(this->VarTreeIter.IsValid());
+ this->VarTreeIter = this->VarTree.Extend(this->VarTreeIter);
}
void InitializeVarScope()
{
+ this->VarTreeIter = this->VarTree.Root();
this->PushDefinitions();
}
void InitializeDefinitions(cmMakefile* parent)
{
- this->VarStack.back() =
- cmDefinitions::MakeClosure(parent->Internal->VarStack.rbegin(),
- parent->Internal->VarStack.rend());
+ *this->VarTreeIter =
+ cmDefinitions::MakeClosure(parent->Internal->VarTreeIter,
+ parent->Internal->VarTree.Root());
}
const char* GetDefinition(std::string const& name)
{
- return cmDefinitions::Get(name, this->VarStack.rbegin(),
- this->VarStack.rend());
+ assert(this->VarTreeIter != this->VarTree.Root());
+ return cmDefinitions::Get(name,
+ this->VarTreeIter, this->VarTree.Root());
}
bool IsInitialized(std::string const& name)
{
- return cmDefinitions::HasKey(name, this->VarStack.rbegin(),
- this->VarStack.rend());
+ return cmDefinitions::HasKey(name,
+ this->VarTreeIter, this->VarTree.Root());
}
void SetDefinition(std::string const& name, std::string const& value)
{
- this->VarStack.back().Set(name, value.c_str());
+ this->VarTreeIter->Set(name, value.c_str());
}
void RemoveDefinition(std::string const& name)
{
- this->VarStack.back().Set(name, 0);
+ this->VarTreeIter->Set(name, 0);
}
std::vector<std::string> UnusedKeys() const
{
- return this->VarStack.back().UnusedKeys();
+ return this->VarTreeIter->UnusedKeys();
}
std::vector<std::string> ClosureKeys() const
{
- return cmDefinitions::ClosureKeys(this->VarStack.rbegin(),
- this->VarStack.rend());
+ return cmDefinitions::ClosureKeys(this->VarTreeIter, this->VarTree.Root());
}
void PopDefinitions()
{
- this->VarStack.pop_back();
+ ++this->VarTreeIter;
}
bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf)
{
- std::list<cmDefinitions>::reverse_iterator it = this->VarStack.rbegin();
- assert(it != this->VarStack.rend());
+ cmLinkedTree<cmDefinitions>::iterator it = this->VarTreeIter;
+ assert(it != this->VarTree.Root());
++it;
- if(it == this->VarStack.rend())
+ if(it == this->VarTree.Root())
{
cmLocalGenerator* plg = mf->LocalGenerator->GetParent();
if(!plg)
@@ -132,7 +135,7 @@ public:
return true;
}
// First localize the definition in the current scope.
- cmDefinitions::Raise(var, this->VarStack.rbegin(), this->VarStack.rend());
+ cmDefinitions::Raise(var, this->VarTreeIter, this->VarTree.Root());
// Now update the definition in the parent scope.
it->Set(var, varDef);