2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
|
|
|
|
** Contact: http://www.qt-project.org/legal
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, 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.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02: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
|