2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/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
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company 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
|
|
|
|
2013-03-27 18:54:03 +01:00
|
|
|
#include <cplusplus/ASTVisitor.h>
|
|
|
|
|
#include <cplusplus/FullySpecifiedType.h>
|
|
|
|
|
#include <cplusplus/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:
|
2013-06-11 09:22:18 +02:00
|
|
|
ResolveExpression(const LookupContext &context,
|
|
|
|
|
const QSet<const Declaration *> &autoDeclarationsBeingResolved
|
|
|
|
|
= QSet<const Declaration *>());
|
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
|
|
|
|
2015-04-20 17:42:34 +03:00
|
|
|
LookupScope *baseExpression(const QList<LookupItem> &baseResults,
|
2010-05-12 14:52:24 +02:00
|
|
|
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:
|
2015-04-20 17:42:34 +03:00
|
|
|
LookupScope *findClass(const FullySpecifiedType &ty, Scope *scope,
|
|
|
|
|
LookupScope *enclosingBinding = 0) const;
|
2010-05-12 15:25:16 +02:00
|
|
|
|
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);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-04-20 17:42:34 +03:00
|
|
|
QList<LookupItem> getMembers(LookupScope *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
|
|
|
|
2015-04-20 17:42:34 +03:00
|
|
|
void addResult(const FullySpecifiedType &ty, Scope *scope, LookupScope *binding = 0);
|
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);
|
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);
|
2013-06-25 15:41:17 +02:00
|
|
|
virtual bool visit(LambdaExpressionAST *ast);
|
|
|
|
|
virtual bool visit(ReturnStatementAST *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:
|
2015-04-20 17:42:34 +03:00
|
|
|
LookupScope *findClassForTemplateParameterInExpressionScope(
|
|
|
|
|
LookupScope *resultBinding,
|
2013-06-18 23:05:57 +02:00
|
|
|
const FullySpecifiedType &ty) const;
|
|
|
|
|
|
2010-05-05 12:06:38 +02:00
|
|
|
Scope *_scope;
|
2013-05-19 07:23:57 +02:00
|
|
|
const LookupContext& _context;
|
2010-08-13 16:17:44 +02:00
|
|
|
Bind bind;
|
2009-11-17 14:21:46 +01:00
|
|
|
QList<LookupItem> _results;
|
2013-06-11 09:22:18 +02:00
|
|
|
QSet<const Declaration *> _autoDeclarationsBeingResolved;
|
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
|