Commit 29532a69 authored by Przemyslaw Gorszkowski's avatar Przemyslaw Gorszkowski Committed by Nikolai Kosjar
Browse files

C++: refactoring: extract finding anonymous as nested type



Change-Id: I73d50d7b51e6a4e9d2b20df487f871793a6a6889
Reviewed-by: default avatarPrzemyslaw Gorszkowski <pgorszkowski@gmail.com>
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent f08ff20e
......@@ -994,6 +994,22 @@ ClassOrNamespace *ClassOrNamespace::findSpecialization(const TemplateNameId *tem
return 0;
}
ClassOrNamespace *ClassOrNamespace::findOrCreateNestedAnonymousType(
const AnonymousNameId *anonymousNameId)
{
QHash<const AnonymousNameId *, ClassOrNamespace *>::const_iterator cit
= _anonymouses.find(anonymousNameId);
if (cit != _anonymouses.end()) {
return cit.value();
} else {
ClassOrNamespace *newAnonymous = _factory->allocClassOrNamespace(this);
if (Q_UNLIKELY(debug))
newAnonymous->_name = anonymousNameId;
_anonymouses[anonymousNameId] = newAnonymous;
return newAnonymous;
}
}
ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespace *origin)
{
Q_ASSERT(name != 0);
......@@ -1001,20 +1017,8 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespac
const_cast<ClassOrNamespace *>(this)->flush();
const AnonymousNameId *anonymousNameId = name->asAnonymousNameId();
if (anonymousNameId) {
QHash<const AnonymousNameId *, ClassOrNamespace *>::const_iterator cit
= _anonymouses.find(anonymousNameId);
if (cit != _anonymouses.end()) {
return cit.value();
} else {
ClassOrNamespace *newAnonymous = _factory->allocClassOrNamespace(this);
if (Q_UNLIKELY(debug))
newAnonymous->_name = anonymousNameId;
_anonymouses[anonymousNameId] = newAnonymous;
return newAnonymous;
}
}
if (const AnonymousNameId *anonymousNameId = name->asAnonymousNameId())
return findOrCreateNestedAnonymousType(anonymousNameId);
Table::const_iterator it = _classOrNamespaces.find(name);
if (it == _classOrNamespaces.end())
......
......@@ -105,6 +105,8 @@ private:
ClassOrNamespace *findOrCreateType(const Name *name, ClassOrNamespace *origin = 0,
Class *clazz = 0);
ClassOrNamespace *findOrCreateNestedAnonymousType(const AnonymousNameId *anonymousNameId);
void addTodo(Symbol *symbol);
void addSymbol(Symbol *symbol);
void addUnscopedEnum(Enum *e);
......
Markdown is supported
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