Commit 13625c21 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Removed ClassOrNamespace::findType_helper() & co.

parent 8eac2fcd
......@@ -441,13 +441,13 @@ ClassOrNamespace *ClassOrNamespace::lookupType(const Name *name)
return 0;
QSet<ClassOrNamespace *> processed;
return lookupType_helper(name, &processed);
return lookupType_helper(name, &processed, /*searchInEnclosingScope =*/ true);
}
ClassOrNamespace *ClassOrNamespace::findType(const Name *name)
{
QSet<ClassOrNamespace *> processed;
return findType_helper(name, &processed);
return lookupType_helper(name, &processed, /*searchInEnclosingScope =*/ false);
}
ClassOrNamespace *ClassOrNamespace::findType(const QList<const Name *> &path)
......@@ -459,14 +459,15 @@ ClassOrNamespace *ClassOrNamespace::findType(const QList<const Name *> &path)
for (int i = 0; e && i < path.size(); ++i) {
QSet<ClassOrNamespace *> processed;
e = e->findType_helper(path.at(i), &processed);
e = e->lookupType_helper(path.at(i), &processed, /*searchInEnclosingScope =*/ false);
}
return e;
}
ClassOrNamespace *ClassOrNamespace::lookupType_helper(const Name *name,
QSet<ClassOrNamespace *> *processed)
QSet<ClassOrNamespace *> *processed,
bool searchInEnclosingScope)
{
Q_ASSERT(name != 0);
......@@ -483,7 +484,7 @@ ClassOrNamespace *ClassOrNamespace::lookupType_helper(const Name *name,
for (unsigned index = 1; e && index < q->nameCount(); ++index) {
QSet<ClassOrNamespace *> processed;
e = e->findType_helper(q->nameAt(index), &processed);
e = e->lookupType_helper(q->nameAt(index), &processed, /*searchInEnclosingScope =*/ false);
}
return e;
......@@ -493,50 +494,13 @@ ClassOrNamespace *ClassOrNamespace::lookupType_helper(const Name *name,
return e;
foreach (ClassOrNamespace *u, usings()) {
if (ClassOrNamespace *r = u->lookupType_helper(name, processed))
if (ClassOrNamespace *r = u->lookupType_helper(name, processed, /*searchInEnclosingScope =*/ false))
return r;
}
}
if (_parent)
return _parent->lookupType_helper(name, processed);
}
return 0;
}
ClassOrNamespace *ClassOrNamespace::findType_helper(const Name *name,
QSet<ClassOrNamespace *> *processed)
{
if (! name) {
return 0;
} else if (const QualifiedNameId *q = name->asQualifiedNameId()) {
ClassOrNamespace *e = this;
if (q->isGlobal())
e = globalNamespace();
for (unsigned i = 0; e && i < q->nameCount(); ++i) {
QSet<ClassOrNamespace *> processed;
e = e->findType_helper(q->nameAt(i), &processed);
}
return e;
} else if (name->isNameId() || name->isTemplateNameId()) {
if (ClassOrNamespace *e = nestedType(name))
return e;
else if (! processed->contains(this)) {
processed->insert(this);
foreach (ClassOrNamespace *u, usings()) {
if (ClassOrNamespace *e = u->findType_helper(name, processed))
return e;
}
}
if (_parent && searchInEnclosingScope)
return _parent->lookupType_helper(name, processed, searchInEnclosingScope);
}
return 0;
......@@ -608,7 +572,7 @@ void ClassOrNamespace::addNestedType(const Name *alias, ClassOrNamespace *e)
_classOrNamespaces[alias] = e;
}
ClassOrNamespace *ClassOrNamespace::findOrCreate(const Name *name)
ClassOrNamespace *ClassOrNamespace::findOrCreateType(const Name *name)
{
if (! name)
return this;
......@@ -617,7 +581,7 @@ ClassOrNamespace *ClassOrNamespace::findOrCreate(const Name *name)
ClassOrNamespace *e = this;
for (unsigned i = 0; e && i < q->nameCount(); ++i)
e = e->findOrCreate(q->nameAt(i));
e = e->findOrCreateType(q->nameAt(i));
return e;
......@@ -729,7 +693,7 @@ void CreateBindings::process(Document::Ptr doc)
ClassOrNamespace *CreateBindings::enterClassOrNamespaceBinding(Symbol *symbol)
{
ClassOrNamespace *entity = _currentClassOrNamespace->findOrCreate(symbol->name());
ClassOrNamespace *entity = _currentClassOrNamespace->findOrCreateType(symbol->name());
entity->addSymbol(symbol);
return switchCurrentClassOrNamespace(entity);
......@@ -737,7 +701,7 @@ ClassOrNamespace *CreateBindings::enterClassOrNamespaceBinding(Symbol *symbol)
ClassOrNamespace *CreateBindings::enterGlobalClassOrNamespace(Symbol *symbol)
{
ClassOrNamespace *entity = _globalNamespace->findOrCreate(symbol->name());
ClassOrNamespace *entity = _globalNamespace->findOrCreateType(symbol->name());
entity->addSymbol(symbol);
return switchCurrentClassOrNamespace(entity);
......@@ -763,7 +727,7 @@ bool CreateBindings::visit(Class *klass)
binding = _currentClassOrNamespace->lookupType(klass->name());
if (! binding)
binding = _currentClassOrNamespace->findOrCreate(klass->name());
binding = _currentClassOrNamespace->findOrCreateType(klass->name());
_currentClassOrNamespace = binding;
_currentClassOrNamespace->addSymbol(klass);
......
......@@ -68,9 +68,7 @@ private:
void flush();
/// \internal
ClassOrNamespace *findOrCreate(const Name *name);
QList<Symbol *> lookup_helper(const Name *name, bool searchInEnclosingScope);
ClassOrNamespace *findOrCreateType(const Name *name);
void addTodo(Symbol *symbol);
void addSymbol(Symbol *symbol);
......@@ -78,13 +76,16 @@ private:
void addUsing(ClassOrNamespace *u);
void addNestedType(const Name *alias, ClassOrNamespace *e);
QList<Symbol *> lookup_helper(const Name *name, bool searchInEnclosingScope);
void lookup_helper(const Name *name, ClassOrNamespace *binding,
QList<Symbol *> *result,
QSet<ClassOrNamespace *> *processed,
const TemplateNameId *templateId);
ClassOrNamespace *lookupType_helper(const Name *name, QSet<ClassOrNamespace *> *processed);
ClassOrNamespace *findType_helper(const Name *name, QSet<ClassOrNamespace *> *processed);
ClassOrNamespace *lookupType_helper(const Name *name, QSet<ClassOrNamespace *> *processed,
bool searchInEnclosingScope);
ClassOrNamespace *nestedType(const Name *name) const;
private:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment