Commit 873838fe authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Simplified TypeOf/ResolveExpression.

parent ddef96ec
......@@ -329,6 +329,8 @@ void Document::check()
for (DeclarationAST *decl = ast->declarations; decl; decl = decl->next) {
semantic.check(decl, globals);
}
} else if (ExpressionAST *ast = _translationUnit->ast()->asExpression()) {
semantic.check(ast, globals);
}
}
......
......@@ -259,8 +259,7 @@ bool ResolveExpression::visit(BinaryExpressionAST *ast)
bool ResolveExpression::visit(CastExpressionAST *ast)
{
Scope dummy;
addResult(sem.check(ast->type_id, &dummy));
addResult(sem.check(ast->type_id, _context.expressionDocument()->globalSymbols()));
return false;
}
......@@ -278,8 +277,7 @@ bool ResolveExpression::visit(ConditionalExpressionAST *)
bool ResolveExpression::visit(CppCastExpressionAST *ast)
{
Scope dummy;
addResult(sem.check(ast->type_id, &dummy));
addResult(sem.check(ast->type_id, _context.expressionDocument()->globalSymbols()));
return false;
}
......@@ -450,8 +448,7 @@ bool ResolveExpression::visit(CompoundLiteralAST *ast)
bool ResolveExpression::visit(QualifiedNameAST *ast)
{
ResolveClass resolveClass;
Scope dummy;
Name *name = sem.check(ast, &dummy);
Name *name = ast->name;
QList<Symbol *> symbols = _context.resolve(name);
foreach (Symbol *symbol, symbols) {
......@@ -485,10 +482,7 @@ bool ResolveExpression::visit(ConversionFunctionIdAST *)
bool ResolveExpression::visit(SimpleNameAST *ast)
{
Scope dummy;
Name *name = sem.check(ast, &dummy);
QList<Symbol *> symbols = _context.resolve(name);
QList<Symbol *> symbols = _context.resolve(ast->name);
foreach (Symbol *symbol, symbols)
addResult(symbol->type(), symbol);
......@@ -504,10 +498,7 @@ bool ResolveExpression::visit(DestructorNameAST *)
bool ResolveExpression::visit(TemplateIdAST *ast)
{
Scope dummy;
Name *name = sem.check(ast, &dummy);
QList<Symbol *> symbols = _context.resolve(name);
QList<Symbol *> symbols = _context.resolve(ast->name);
foreach (Symbol *symbol, symbols)
addResult(symbol->type(), symbol);
......@@ -601,8 +592,9 @@ bool ResolveExpression::visit(MemberAccessAST *ast)
QList<Result> baseResults = _results;
// Evaluate the expression-id that follows the access operator.
Scope dummy;
Name *memberName = sem.check(ast->member_name, &dummy);
Name *memberName = 0;
if (ast->member_name)
memberName = ast->member_name->name;
// Remember the access operator.
const unsigned accessOp = tokenKind(ast->access_token);
......
......@@ -63,6 +63,7 @@ QList<TypeOfExpression::Result> TypeOfExpression::operator()(const QString &expr
if (mode == Preprocess)
code = preprocessedExpression(expression, m_snapshot, document);
Document::Ptr expressionDoc = documentForExpression(code);
expressionDoc->check();
m_ast = extractExpressionAST(expressionDoc);
m_lookupContext = LookupContext(lastVisibleSymbol, expressionDoc,
......
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