cmDefinitions: Implement MakeClosure in terms of a list of ancestors.

This commit is contained in:
Stephen Kelly 2015-04-26 16:00:18 +02:00
parent d858f36339
commit 60becdc65c
2 changed files with 17 additions and 13 deletions

View File

@ -11,8 +11,6 @@
============================================================================*/
#include "cmDefinitions.h"
#include <list>
//----------------------------------------------------------------------------
cmDefinitions::Def cmDefinitions::NoDef;
@ -81,22 +79,25 @@ cmDefinitions cmDefinitions::MakeClosure() const
{
std::set<std::string> undefined;
cmDefinitions closure;
closure.MakeClosure(undefined, this);
return closure;
}
//----------------------------------------------------------------------------
void cmDefinitions::MakeClosure(std::set<std::string>& undefined,
cmDefinitions const* defs)
{
cmDefinitions const* defs = this;
std::list<cmDefinitions const*> ups;
while(defs)
{
ups.push_back(defs);
defs = defs->Up;
}
for (std::list<cmDefinitions const*>::const_iterator it = ups.begin();
it != ups.end(); ++it)
closure.MakeClosure(undefined, ups.begin(), ups.end());
return closure;
}
//----------------------------------------------------------------------------
void
cmDefinitions::MakeClosure(std::set<std::string>& undefined,
std::list<cmDefinitions const*>::iterator begin,
std::list<cmDefinitions const*>::iterator end)
{
for (std::list<cmDefinitions const*>::const_iterator it = begin;
it != end; ++it)
{
// Consider local definitions.
for(MapType::const_iterator mi = (*it)->Map.begin();

View File

@ -17,6 +17,8 @@
#include "cmsys/hash_map.hxx"
#endif
#include <list>
/** \class cmDefinitions
* \brief Store a scope of variable definitions for CMake language.
*
@ -80,7 +82,8 @@ private:
Def const& GetInternal(const std::string& key);
void MakeClosure(std::set<std::string>& undefined,
cmDefinitions const* defs);
std::list<cmDefinitions const*>::iterator begin,
std::list<cmDefinitions const*>::iterator end);
};
#endif