Skip to content
Snippets Groups Projects
Commit faaab90a authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Added LookupContext::resolveOperatorNameId() with the bits needed to resolve operator name ids.

parent da91a048
No related branches found
No related tags found
No related merge requests found
...@@ -181,20 +181,45 @@ QList<Symbol *> LookupContext::resolveQualifiedNameId(QualifiedNameId *q, ...@@ -181,20 +181,45 @@ QList<Symbol *> LookupContext::resolveQualifiedNameId(QualifiedNameId *q,
return candidates; return candidates;
} }
QList<Symbol *> LookupContext::resolveOperatorNameId(OperatorNameId *opId,
const QList<Scope *> &visibleScopes,
ResolveMode) const
{
QList<Symbol *> candidates;
for (int scopeIndex = 0; scopeIndex < visibleScopes.size(); ++scopeIndex) {
Scope *scope = visibleScopes.at(scopeIndex);
for (Symbol *symbol = scope->lookat(opId->kind()); symbol; symbol = symbol->next()) {
if (! opId->isEqualTo(symbol->name()))
continue;
if (! candidates.contains(symbol))
candidates.append(symbol);
}
}
return candidates;
}
QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visibleScopes, QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visibleScopes,
ResolveMode mode) const ResolveMode mode) const
{ {
QList<Symbol *> candidates; QList<Symbol *> candidates;
if (!name) if (!name)
return candidates; return candidates; // nothing to do, the symbol is anonymous.
if (QualifiedNameId *q = name->asQualifiedNameId()) else if (QualifiedNameId *q = name->asQualifiedNameId())
return resolveQualifiedNameId(q, visibleScopes, mode); return resolveQualifiedNameId(q, visibleScopes, mode);
if (Identifier *id = identifier(name)) { else if (OperatorNameId *opId = name->asOperatorNameId())
return resolveOperatorNameId(opId, visibleScopes, mode);
else if (Identifier *id = identifier(name)) {
for (int scopeIndex = 0; scopeIndex < visibleScopes.size(); ++scopeIndex) { for (int scopeIndex = 0; scopeIndex < visibleScopes.size(); ++scopeIndex) {
Scope *scope = visibleScopes.at(scopeIndex); Scope *scope = visibleScopes.at(scopeIndex);
for (Symbol *symbol = scope->lookat(id); symbol; symbol = symbol->next()) { for (Symbol *symbol = scope->lookat(id); symbol; symbol = symbol->next()) {
if (! symbol->name()) { if (! symbol->name()) {
continue; continue;
...@@ -237,16 +262,6 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible ...@@ -237,16 +262,6 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
candidates.append(symbol); candidates.append(symbol);
} }
} }
} else if (OperatorNameId *opId = name->asOperatorNameId()) {
for (int scopeIndex = 0; scopeIndex < visibleScopes.size(); ++scopeIndex) {
Scope *scope = visibleScopes.at(scopeIndex);
for (Symbol *symbol = scope->lookat(opId->kind()); symbol; symbol = symbol->next()) {
if (! opId->isEqualTo(symbol->name()))
continue;
else if (! candidates.contains(symbol))
candidates.append(symbol);
}
}
} }
return candidates; return candidates;
......
...@@ -119,6 +119,10 @@ private: ...@@ -119,6 +119,10 @@ private:
const QList<Scope *> &visibleScopes, const QList<Scope *> &visibleScopes,
ResolveMode mode) const; ResolveMode mode) const;
QList<Symbol *> resolveOperatorNameId(OperatorNameId *opId,
const QList<Scope *> &visibleScopes,
ResolveMode mode) const;
Identifier *identifier(const Name *name) const; Identifier *identifier(const Name *name) const;
QList<Scope *> buildVisibleScopes(); QList<Scope *> buildVisibleScopes();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment