Commit 3c6ad0d8 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Instiate overloads of operator->().

parent 1f3ce810
......@@ -263,6 +263,11 @@ ClassOrNamespace::ClassOrNamespace(CreateBindings *factory, ClassOrNamespace *pa
{
}
const TemplateNameId *ClassOrNamespace::templateId() const
{
return _templateId;
}
ClassOrNamespace *ClassOrNamespace::parent() const
{
return _parent;
......@@ -316,35 +321,35 @@ QList<Symbol *> ClassOrNamespace::lookup(const Name *name)
QList<Symbol *> ClassOrNamespace::lookup_helper(const Name *name, bool searchInEnclosingScope)
{
QList<Symbol *> result;
if (! name)
return result;
if (const QualifiedNameId *q = name->asQualifiedNameId()) {
ClassOrNamespace *binding = this;
if (name) {
if (const QualifiedNameId *q = name->asQualifiedNameId()) {
ClassOrNamespace *binding = this;
if (q->isGlobal())
binding = globalNamespace();
if (q->isGlobal())
binding = globalNamespace();
if (q->nameCount() == 1)
return binding->find(q->unqualifiedNameId());
if (q->nameCount() == 1)
return binding->find(q->unqualifiedNameId());
binding = binding->lookupClassOrNamespace(q->nameAt(0));
binding = binding->lookupClassOrNamespace(q->nameAt(0));
for (unsigned index = 1; binding && index < q->nameCount() - 1; ++index)
binding = binding->findClassOrNamespace(q->nameAt(index));
for (unsigned index = 1; binding && index < q->nameCount() - 1; ++index)
binding = binding->findClassOrNamespace(q->nameAt(index));
if (binding)
result = binding->find(q->unqualifiedNameId());
if (binding)
result = binding->find(q->unqualifiedNameId());
return result;
}
return result;
}
QSet<ClassOrNamespace *> processed;
ClassOrNamespace *binding = this;
do {
lookup_helper(name, binding, &result, &processed, /*templateId = */ 0);
binding = binding->_parent;
} while (searchInEnclosingScope && binding);
QSet<ClassOrNamespace *> processed;
ClassOrNamespace *binding = this;
do {
lookup_helper(name, binding, &result, &processed, /*templateId = */ 0);
binding = binding->_parent;
} while (searchInEnclosingScope && binding);
}
return result;
}
......@@ -404,7 +409,7 @@ void CreateBindings::lookupInScope(const Name *name, Scope *scope,
else if (s->name()->isQualifiedNameId())
continue; // skip qualified ids.
#if 0
#if 1
if (templateId && (s->isDeclaration() || s->isFunction())) {
FullySpecifiedType ty = GenTemplateInstance::instantiate(templateId, s, _control);
......@@ -416,6 +421,7 @@ void CreateBindings::lookupInScope(const Name *name, Scope *scope,
qDebug() << "TODO: instantiate:" << oo(s->type(), s->name()) << "using:" << oo(templateId)
<< oo(ty);
#if 0
if (Declaration *decl = s->asDeclaration()) {
qDebug() << "instantiate declaration";
Declaration *d = _control->newDeclaration(0, 0);
......@@ -430,6 +436,8 @@ void CreateBindings::lookupInScope(const Name *name, Scope *scope,
result->append(d);
continue;
}
#endif
}
#endif
......
......@@ -48,6 +48,7 @@ class CPLUSPLUS_EXPORT ClassOrNamespace
public:
ClassOrNamespace(CreateBindings *factory, ClassOrNamespace *parent);
const TemplateNameId *templateId() const;
ClassOrNamespace *parent() const;
QList<ClassOrNamespace *> usings() const;
QList<Enum *> enums() const;
......
......@@ -603,10 +603,23 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
const OperatorNameId *arrowOp = control()->operatorNameId(OperatorNameId::ArrowOp);
foreach (Symbol *overload, binding->find(arrowOp)) {
FullySpecifiedType overloadTy = overload->type();
if (Function *funTy = overload->type()->asFunctionType()) {
FullySpecifiedType overloadTy = GenTemplateInstance::instantiate(binding->templateId(), overload, control());
Function *instantiatedFunction = overloadTy->asFunctionType();
Q_ASSERT(instantiatedFunction != 0);
FullySpecifiedType retTy = instantiatedFunction->returnType().simplified();
if (PointerType *ptrTy = retTy->asPointerType()) {
if (ClassOrNamespace *retBinding = findClass(ptrTy->elementType(), overload->scope()))
return retBinding;
if (ClassOrNamespace *retBinding = findClass(overloadTy, overload->scope()))
return retBinding;
else if (debug) {
Overview oo;
qDebug() << "no class for:" << oo(ptrTy->elementType());
}
}
}
}
}
} else if (accessOp == T_DOT) {
......
......@@ -1095,6 +1095,11 @@ bool CppCodeCompletion::completeMember(const QList<LookupItem> &baseResults,
return ! m_completions.isEmpty();
}
if (debug) {
Overview oo;
qDebug() << "hmm, got:" << oo(baseResults.first().type()) << typeid(*baseResults.first().type().type()).name();
}
return false;
}
......
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