|
|
@@ -11,6 +11,8 @@
|
|
|
============================================================================*/
|
|
|
#include "cmDefinitions.h"
|
|
|
|
|
|
+#include <assert.h>
|
|
|
+
|
|
|
//----------------------------------------------------------------------------
|
|
|
cmDefinitions::Def cmDefinitions::NoDef;
|
|
|
|
|
|
@@ -21,28 +23,33 @@ cmDefinitions::cmDefinitions(cmDefinitions* parent)
|
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
-cmDefinitions::Def const&
|
|
|
-cmDefinitions::GetInternal(const std::string& key)
|
|
|
+cmDefinitions::Def const& cmDefinitions::GetInternal(
|
|
|
+ const std::string& key,
|
|
|
+ std::list<cmDefinitions>::reverse_iterator rbegin,
|
|
|
+ std::list<cmDefinitions>::reverse_iterator rend)
|
|
|
{
|
|
|
+ assert(&*rbegin == this);
|
|
|
MapType::const_iterator i = this->Map.find(key);
|
|
|
if(i != this->Map.end())
|
|
|
{
|
|
|
return i->second;
|
|
|
}
|
|
|
- cmDefinitions* up = this->Up;
|
|
|
- if(!up)
|
|
|
+ ++rbegin;
|
|
|
+ if(rbegin == rend)
|
|
|
{
|
|
|
return this->NoDef;
|
|
|
}
|
|
|
// Query the parent scope and store the result locally.
|
|
|
- Def def = up->GetInternal(key);
|
|
|
+ Def def = rbegin->GetInternal(key, rbegin, rend);
|
|
|
return this->Map.insert(MapType::value_type(key, def)).first->second;
|
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
-const char* cmDefinitions::Get(const std::string& key)
|
|
|
+const char* cmDefinitions::Get(const std::string& key,
|
|
|
+ std::list<cmDefinitions>::reverse_iterator rbegin,
|
|
|
+ std::list<cmDefinitions>::reverse_iterator rend)
|
|
|
{
|
|
|
- Def const& def = this->GetInternal(key);
|
|
|
+ Def const& def = this->GetInternal(key, rbegin, rend);
|
|
|
return def.Exists? def.c_str() : 0;
|
|
|
}
|
|
|
|