C++: rename enclosingTemplateInstantiation to enclosingBinding

Change-Id: I6989cd0e62e9587824737b756a37607dfdcf5ebf
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Przemyslaw Gorszkowski
2015-02-11 07:55:06 +01:00
committed by Orgad Shaneh
parent 1a239bd3e9
commit 168d9201d5
4 changed files with 24 additions and 24 deletions

View File

@@ -324,7 +324,7 @@ ClassOrNamespace *LookupContext::globalNamespace() const
} }
ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope, ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
ClassOrNamespace* enclosingTemplateInstantiation, ClassOrNamespace *enclosingBinding,
QSet<const Declaration *> typedefsBeingResolved) const QSet<const Declaration *> typedefsBeingResolved) const
{ {
if (! scope || ! name) { if (! scope || ! name) {
@@ -367,7 +367,7 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
} }
// try to find it in block (rare case but has priority before enclosing scope) // try to find it in block (rare case but has priority before enclosing scope)
// e.g.: void foo() { struct S {}; S s; } // e.g.: void foo() { struct S {}; S s; }
if (ClassOrNamespace *b = bindings()->lookupType(scope, enclosingTemplateInstantiation)) { if (ClassOrNamespace *b = bindings()->lookupType(scope, enclosingBinding)) {
if (ClassOrNamespace *classOrNamespaceNestedInNestedBlock = b->lookupType(name, block)) if (ClassOrNamespace *classOrNamespaceNestedInNestedBlock = b->lookupType(name, block))
return classOrNamespaceNestedInNestedBlock; return classOrNamespaceNestedInNestedBlock;
} }
@@ -376,13 +376,13 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
if (ClassOrNamespace *found = lookupType(name, scope->enclosingScope())) if (ClassOrNamespace *found = lookupType(name, scope->enclosingScope()))
return found; return found;
} else if (ClassOrNamespace *b = bindings()->lookupType(scope, enclosingTemplateInstantiation)) { } else if (ClassOrNamespace *b = bindings()->lookupType(scope, enclosingBinding)) {
return b->lookupType(name); return b->lookupType(name);
} else if (Class *scopeAsClass = scope->asClass()) { } else if (Class *scopeAsClass = scope->asClass()) {
if (scopeAsClass->enclosingScope()->isBlock()) { if (scopeAsClass->enclosingScope()->isBlock()) {
if (ClassOrNamespace *b = lookupType(scopeAsClass->name(), if (ClassOrNamespace *b = lookupType(scopeAsClass->name(),
scopeAsClass->enclosingScope(), scopeAsClass->enclosingScope(),
enclosingTemplateInstantiation, enclosingBinding,
typedefsBeingResolved)) { typedefsBeingResolved)) {
return b->lookupType(name); return b->lookupType(name);
} }
@@ -393,9 +393,9 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
} }
ClassOrNamespace *LookupContext::lookupType(Symbol *symbol, ClassOrNamespace *LookupContext::lookupType(Symbol *symbol,
ClassOrNamespace* enclosingTemplateInstantiation) const ClassOrNamespace *enclosingBinding) const
{ {
return bindings()->lookupType(symbol, enclosingTemplateInstantiation); return bindings()->lookupType(symbol, enclosingBinding);
} }
QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
@@ -1521,19 +1521,20 @@ ClassOrNamespace *CreateBindings::globalNamespace() const
return _globalNamespace; return _globalNamespace;
} }
ClassOrNamespace *CreateBindings::lookupType(Symbol *symbol, ClassOrNamespace* enclosingTemplateInstantiation) ClassOrNamespace *CreateBindings::lookupType(Symbol *symbol, ClassOrNamespace *enclosingBinding)
{ {
const QList<const Name *> path = LookupContext::path(symbol); const QList<const Name *> path = LookupContext::path(symbol);
return lookupType(path, enclosingTemplateInstantiation); return lookupType(path, enclosingBinding);
} }
ClassOrNamespace *CreateBindings::lookupType(const QList<const Name *> &path, ClassOrNamespace* enclosingTemplateInstantiation) ClassOrNamespace *CreateBindings::lookupType(const QList<const Name *> &path,
ClassOrNamespace *enclosingBinding)
{ {
if (path.isEmpty()) if (path.isEmpty())
return _globalNamespace; return _globalNamespace;
if (enclosingTemplateInstantiation) { if (enclosingBinding) {
if (ClassOrNamespace *b = enclosingTemplateInstantiation->lookupType(path.last())) if (ClassOrNamespace *b = enclosingBinding->lookupType(path.last()))
return b; return b;
} }

View File

@@ -202,10 +202,9 @@ public:
ClassOrNamespace *globalNamespace() const; ClassOrNamespace *globalNamespace() const;
/// Finds the binding associated to the given symbol. /// Finds the binding associated to the given symbol.
ClassOrNamespace *lookupType(Symbol *symbol, ClassOrNamespace *lookupType(Symbol *symbol, ClassOrNamespace *enclosingBinding = 0);
ClassOrNamespace* enclosingTemplateInstantiation = 0);
ClassOrNamespace *lookupType(const QList<const Name *> &path, ClassOrNamespace *lookupType(const QList<const Name *> &path,
ClassOrNamespace* enclosingTemplateInstantiation = 0); ClassOrNamespace *enclosingBinding = 0);
/// Returns the Control that must be used to create temporary symbols. /// Returns the Control that must be used to create temporary symbols.
/// \internal /// \internal
@@ -310,11 +309,11 @@ public:
QList<LookupItem> lookup(const Name *name, Scope *scope) const; QList<LookupItem> lookup(const Name *name, Scope *scope) const;
ClassOrNamespace *lookupType(const Name *name, Scope *scope, ClassOrNamespace *lookupType(const Name *name, Scope *scope,
ClassOrNamespace* enclosingTemplateInstantiation = 0, ClassOrNamespace *enclosingBinding = 0,
QSet<const Declaration *> typedefsBeingResolved QSet<const Declaration *> typedefsBeingResolved
= QSet<const Declaration *>()) const; = QSet<const Declaration *>()) const;
ClassOrNamespace *lookupType(Symbol *symbol, ClassOrNamespace *lookupType(Symbol *symbol,
ClassOrNamespace* enclosingTemplateInstantiation = 0) const; ClassOrNamespace *enclosingBinding = 0) const;
ClassOrNamespace *lookupParent(Symbol *symbol) const; ClassOrNamespace *lookupParent(Symbol *symbol) const;
/// \internal /// \internal

View File

@@ -1015,20 +1015,20 @@ bool ResolveExpression::visit(MemberAccessAST *ast)
} }
ClassOrNamespace *ResolveExpression::findClass(const FullySpecifiedType &originalTy, Scope *scope, ClassOrNamespace *ResolveExpression::findClass(const FullySpecifiedType &originalTy, Scope *scope,
ClassOrNamespace* enclosingTemplateInstantiation) const ClassOrNamespace *enclosingBinding) const
{ {
FullySpecifiedType ty = originalTy.simplified(); FullySpecifiedType ty = originalTy.simplified();
ClassOrNamespace *binding = 0; ClassOrNamespace *binding = 0;
if (Class *klass = ty->asClassType()) { if (Class *klass = ty->asClassType()) {
if (scope->isBlock()) if (scope->isBlock())
binding = _context.lookupType(klass->name(), scope, enclosingTemplateInstantiation); binding = _context.lookupType(klass->name(), scope, enclosingBinding);
if (!binding) if (!binding)
binding = _context.lookupType(klass, enclosingTemplateInstantiation); binding = _context.lookupType(klass, enclosingBinding);
} }
else if (NamedType *namedTy = ty->asNamedType()) else if (NamedType *namedTy = ty->asNamedType())
binding = _context.lookupType(namedTy->name(), scope, enclosingTemplateInstantiation); binding = _context.lookupType(namedTy->name(), scope, enclosingBinding);
else if (Function *funTy = ty->asFunctionType()) else if (Function *funTy = ty->asFunctionType())
return findClass(funTy->returnType(), scope); return findClass(funTy->returnType(), scope);
@@ -1146,13 +1146,13 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
return binding; return binding;
} }
ClassOrNamespace *enclosingTemplateInstantiation = 0; ClassOrNamespace *enclosingBinding = 0;
if (ClassOrNamespace *binding = r.binding()) { if (ClassOrNamespace *binding = r.binding()) {
if (binding->instantiationOrigin()) if (binding->instantiationOrigin())
enclosingTemplateInstantiation = binding; enclosingBinding = binding;
} }
if (ClassOrNamespace *binding = findClass(ty, scope, enclosingTemplateInstantiation)) if (ClassOrNamespace *binding = findClass(ty, scope, enclosingBinding))
return binding; return binding;
} }
} }

View File

@@ -61,7 +61,7 @@ public:
protected: protected:
ClassOrNamespace *findClass(const FullySpecifiedType &ty, Scope *scope, ClassOrNamespace *findClass(const FullySpecifiedType &ty, Scope *scope,
ClassOrNamespace* enclosingTemplateInstantiation = 0) const; ClassOrNamespace *enclosingBinding = 0) const;
QList<LookupItem> expression(ExpressionAST *ast); QList<LookupItem> expression(ExpressionAST *ast);