Split LookupContext::lookup() in lookup() and find().

lookup() searches for symbols in the given binding and the enclosing scopes,
while find() searches for symbols only in the given binding.
This commit is contained in:
Roberto Raggi
2010-05-11 10:20:51 +02:00
parent 7446f5cae2
commit 37fde0c9d4
3 changed files with 20 additions and 7 deletions

View File

@@ -304,7 +304,17 @@ ClassOrNamespace *ClassOrNamespace::globalNamespace() const
return e;
}
QList<Symbol *> ClassOrNamespace::find(const Name *name)
{
return lookup_helper(name, false);
}
QList<Symbol *> ClassOrNamespace::lookup(const Name *name)
{
return lookup_helper(name, true);
}
QList<Symbol *> ClassOrNamespace::lookup_helper(const Name *name, bool searchInEnclosingScope)
{
QList<Symbol *> result;
if (! name)
@@ -317,7 +327,7 @@ QList<Symbol *> ClassOrNamespace::lookup(const Name *name)
binding = globalNamespace();
if (q->nameCount() == 1)
return binding->lookup(q->unqualifiedNameId());
return binding->find(q->unqualifiedNameId());
binding = binding->lookupClassOrNamespace(q->nameAt(0));
@@ -325,7 +335,7 @@ QList<Symbol *> ClassOrNamespace::lookup(const Name *name)
binding = binding->findClassOrNamespace(q->nameAt(index));
if (binding)
result = binding->lookup(q->unqualifiedNameId());
result = binding->find(q->unqualifiedNameId());
return result;
}
@@ -335,7 +345,7 @@ QList<Symbol *> ClassOrNamespace::lookup(const Name *name)
do {
lookup_helper(name, binding, &result, &processed, /*templateId = */ 0);
binding = binding->_parent;
} while (binding);
} while (searchInEnclosingScope && binding);
return result;
}