2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-07-19 12:26:56 +02:00
|
|
|
** Contact: http://www.qt-project.org/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#ifndef CPLUSPLUS_RESOLVEEXPRESSION_H
|
|
|
|
|
#define CPLUSPLUS_RESOLVEEXPRESSION_H
|
|
|
|
|
|
2010-05-05 12:06:38 +02:00
|
|
|
#include "LookupContext.h"
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <ASTVisitor.h>
|
|
|
|
|
#include <FullySpecifiedType.h>
|
2010-08-13 16:17:44 +02:00
|
|
|
#include <Bind.h>
|
2012-09-04 15:21:03 +02:00
|
|
|
#include <set>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
namespace CPlusPlus {
|
|
|
|
|
|
|
|
|
|
class CPLUSPLUS_EXPORT ResolveExpression: protected ASTVisitor
|
|
|
|
|
{
|
|
|
|
|
public:
|
2010-05-12 12:53:16 +02:00
|
|
|
ResolveExpression(const LookupContext &context);
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual ~ResolveExpression();
|
|
|
|
|
|
2010-05-12 12:53:16 +02:00
|
|
|
QList<LookupItem> operator()(ExpressionAST *ast, Scope *scope);
|
2010-12-10 10:32:46 +01:00
|
|
|
QList<LookupItem> resolve(ExpressionAST *ast, Scope *scope, bool ref = false);
|
|
|
|
|
QList<LookupItem> reference(ExpressionAST *ast, Scope *scope);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-05-12 14:52:24 +02:00
|
|
|
ClassOrNamespace *baseExpression(const QList<LookupItem> &baseResults,
|
|
|
|
|
int accessOp,
|
|
|
|
|
bool *replacedDotOperator = 0) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-09-22 11:38:04 +02:00
|
|
|
const LookupContext &context() const;
|
|
|
|
|
|
2010-05-12 15:27:13 +02:00
|
|
|
protected:
|
2010-05-12 15:25:16 +02:00
|
|
|
ClassOrNamespace *findClass(const FullySpecifiedType &ty, Scope *scope) const;
|
|
|
|
|
|
2010-12-10 10:32:46 +01:00
|
|
|
QList<LookupItem> expression(ExpressionAST *ast);
|
2010-05-12 12:53:16 +02:00
|
|
|
|
2009-11-17 14:21:46 +01:00
|
|
|
QList<LookupItem> switchResults(const QList<LookupItem> &symbols);
|
2010-05-05 12:06:38 +02:00
|
|
|
FullySpecifiedType instantiate(const Name *className, Symbol *candidate) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-07-19 15:10:06 +02:00
|
|
|
QList<LookupItem> getMembers(ClassOrNamespace *binding, const Name *memberName) const;
|
2010-07-16 11:03:39 +02:00
|
|
|
|
2010-03-29 15:30:53 +02:00
|
|
|
void thisObject();
|
2010-05-11 11:26:27 +02:00
|
|
|
|
2010-05-12 12:53:16 +02:00
|
|
|
void addResult(const FullySpecifiedType &ty, Scope *scope);
|
2010-05-11 11:26:27 +02:00
|
|
|
void addResults(const QList<Symbol *> &symbols);
|
2010-07-16 11:03:39 +02:00
|
|
|
void addResults(const QList<LookupItem> &items);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-12-10 10:32:46 +01:00
|
|
|
static bool maybeValidPrototype(Function *funTy, unsigned actualArgumentCount);
|
|
|
|
|
bool implicitConversion(const FullySpecifiedType &sourceTy, const FullySpecifiedType &targetTy) const;
|
2009-10-16 12:22:33 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
using ASTVisitor::visit;
|
|
|
|
|
|
2010-08-02 12:04:59 +02:00
|
|
|
virtual bool visit(IdExpressionAST *ast);
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual bool visit(BinaryExpressionAST *ast);
|
|
|
|
|
virtual bool visit(CastExpressionAST *ast);
|
|
|
|
|
virtual bool visit(ConditionAST *ast);
|
|
|
|
|
virtual bool visit(ConditionalExpressionAST *ast);
|
|
|
|
|
virtual bool visit(CppCastExpressionAST *ast);
|
|
|
|
|
virtual bool visit(DeleteExpressionAST *ast);
|
|
|
|
|
virtual bool visit(ArrayInitializerAST *ast);
|
|
|
|
|
virtual bool visit(NewExpressionAST *ast);
|
|
|
|
|
virtual bool visit(TypeidExpressionAST *ast);
|
|
|
|
|
virtual bool visit(TypenameCallExpressionAST *ast);
|
|
|
|
|
virtual bool visit(TypeConstructorCallAST *ast);
|
|
|
|
|
virtual bool visit(SizeofExpressionAST *ast);
|
2011-11-18 13:33:26 +01:00
|
|
|
virtual bool visit(PointerLiteralAST *ast);
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual bool visit(NumericLiteralAST *ast);
|
|
|
|
|
virtual bool visit(BoolLiteralAST *ast);
|
|
|
|
|
virtual bool visit(ThisExpressionAST *ast);
|
|
|
|
|
virtual bool visit(NestedExpressionAST *ast);
|
|
|
|
|
virtual bool visit(StringLiteralAST *ast);
|
|
|
|
|
virtual bool visit(ThrowExpressionAST *ast);
|
|
|
|
|
virtual bool visit(TypeIdAST *ast);
|
|
|
|
|
virtual bool visit(UnaryExpressionAST *ast);
|
2009-01-13 16:03:46 +01:00
|
|
|
virtual bool visit(CompoundLiteralAST *ast);
|
2010-02-04 14:55:18 +01:00
|
|
|
virtual bool visit(CompoundExpressionAST *ast);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
//names
|
|
|
|
|
virtual bool visit(QualifiedNameAST *ast);
|
|
|
|
|
virtual bool visit(OperatorFunctionIdAST *ast);
|
|
|
|
|
virtual bool visit(ConversionFunctionIdAST *ast);
|
|
|
|
|
virtual bool visit(SimpleNameAST *ast);
|
|
|
|
|
virtual bool visit(DestructorNameAST *ast);
|
|
|
|
|
virtual bool visit(TemplateIdAST *ast);
|
|
|
|
|
|
|
|
|
|
// postfix expressions
|
|
|
|
|
virtual bool visit(CallAST *ast);
|
|
|
|
|
virtual bool visit(ArrayAccessAST *ast);
|
|
|
|
|
virtual bool visit(PostIncrDecrAST *ast);
|
|
|
|
|
virtual bool visit(MemberAccessAST *ast);
|
|
|
|
|
|
2009-11-11 09:21:06 +01:00
|
|
|
// Objective-C expressions
|
|
|
|
|
virtual bool visit(ObjCMessageExpressionAST *ast);
|
|
|
|
|
|
2012-09-04 15:21:03 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
2010-05-05 12:06:38 +02:00
|
|
|
Scope *_scope;
|
|
|
|
|
LookupContext _context;
|
2010-08-13 16:17:44 +02:00
|
|
|
Bind bind;
|
2009-11-17 14:21:46 +01:00
|
|
|
QList<LookupItem> _results;
|
2010-12-10 10:32:46 +01:00
|
|
|
bool _reference;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2011-02-04 09:52:39 +01:00
|
|
|
} // namespace CPlusPlus
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#endif // CPLUSPLUS_RESOLVEEXPRESSION_H
|