ResolveType for compound literals.
[qt-creator-color-themes.git] / src / libs / cplusplus / ResolveExpression.h
blob7648705194a73f41f321cf8d3df14aeb51f6e69a
1 /***************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Qt Software Information (qt-info@nokia.com)
8 **
9 **
10 ** Non-Open Source Usage
12 ** Licensees may use this file in accordance with the Qt Beta Version
13 ** License Agreement, Agreement version 2.2 provided with the Software or,
14 ** alternatively, in accordance with the terms contained in a written
15 ** agreement between you and Nokia.
17 ** GNU General Public License Usage
19 ** Alternatively, this file may be used under the terms of the GNU General
20 ** Public License versions 2.0 or 3.0 as published by the Free Software
21 ** Foundation and appearing in the file LICENSE.GPL included in the packaging
22 ** of this file. Please review the following information to ensure GNU
23 ** General Public Licensing requirements will be met:
25 ** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
26 ** http://www.gnu.org/copyleft/gpl.html.
28 ** In addition, as a special exception, Nokia gives you certain additional
29 ** rights. These rights are described in the Nokia Qt GPL Exception
30 ** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
32 ***************************************************************************/
34 #ifndef CPLUSPLUS_RESOLVEEXPRESSION_H
35 #define CPLUSPLUS_RESOLVEEXPRESSION_H
37 #include "LookupContext.h"
39 #include <ASTVisitor.h>
40 #include <Semantic.h>
41 #include <FullySpecifiedType.h>
43 namespace CPlusPlus {
45 class CPLUSPLUS_EXPORT ResolveExpression: protected ASTVisitor
47 public:
48 typedef QPair<FullySpecifiedType, Symbol *> Result;
50 public:
51 ResolveExpression(const LookupContext &context);
52 virtual ~ResolveExpression();
54 QList<Result> operator()(ExpressionAST *ast);
56 QList<Result> resolveMemberExpression(const QList<Result> &baseResults,
57 unsigned accessOp,
58 Name *memberName) const;
60 QList<Result> resolveMember(const Result &result,
61 Name *memberName,
62 NamedType *namedTy) const;
64 QList<Result> resolveMember(const Result &result,
65 Name *memberName,
66 NamedType *namedTy,
67 Class *klass) const;
69 QList<Result> resolveArrowOperator(const Result &result,
70 NamedType *namedTy,
71 Class *klass) const;
73 QList<Result> resolveArrayOperator(const Result &result,
74 NamedType *namedTy,
75 Class *klass) const;
77 protected:
78 QList<Result> switchResults(const QList<Result> &symbols);
80 void addResult(const FullySpecifiedType &ty, Symbol *symbol = 0);
81 void addResult(const Result &result);
82 void addResults(const QList<Result> &results);
84 using ASTVisitor::visit;
86 virtual bool visit(ExpressionListAST *ast);
87 virtual bool visit(BinaryExpressionAST *ast);
88 virtual bool visit(CastExpressionAST *ast);
89 virtual bool visit(ConditionAST *ast);
90 virtual bool visit(ConditionalExpressionAST *ast);
91 virtual bool visit(CppCastExpressionAST *ast);
92 virtual bool visit(DeleteExpressionAST *ast);
93 virtual bool visit(ArrayInitializerAST *ast);
94 virtual bool visit(NewExpressionAST *ast);
95 virtual bool visit(TypeidExpressionAST *ast);
96 virtual bool visit(TypenameCallExpressionAST *ast);
97 virtual bool visit(TypeConstructorCallAST *ast);
98 virtual bool visit(PostfixExpressionAST *ast);
99 virtual bool visit(SizeofExpressionAST *ast);
100 virtual bool visit(NumericLiteralAST *ast);
101 virtual bool visit(BoolLiteralAST *ast);
102 virtual bool visit(ThisExpressionAST *ast);
103 virtual bool visit(NestedExpressionAST *ast);
104 virtual bool visit(StringLiteralAST *ast);
105 virtual bool visit(ThrowExpressionAST *ast);
106 virtual bool visit(TypeIdAST *ast);
107 virtual bool visit(UnaryExpressionAST *ast);
108 virtual bool visit(CompoundLiteralAST *ast);
110 //names
111 virtual bool visit(QualifiedNameAST *ast);
112 virtual bool visit(OperatorFunctionIdAST *ast);
113 virtual bool visit(ConversionFunctionIdAST *ast);
114 virtual bool visit(SimpleNameAST *ast);
115 virtual bool visit(DestructorNameAST *ast);
116 virtual bool visit(TemplateIdAST *ast);
118 // postfix expressions
119 virtual bool visit(CallAST *ast);
120 virtual bool visit(ArrayAccessAST *ast);
121 virtual bool visit(PostIncrDecrAST *ast);
122 virtual bool visit(MemberAccessAST *ast);
124 QList<Scope *> visibleScopes(const Result &result) const;
126 private:
127 LookupContext _context;
128 Semantic sem;
129 QList<Result> _results;
132 class CPLUSPLUS_EXPORT ResolveClass
134 public:
135 ResolveClass();
137 QList<Symbol *> operator()(NamedType *namedTy,
138 ResolveExpression::Result p,
139 const LookupContext &context);
141 QList<Symbol *> operator()(ResolveExpression::Result p,
142 const LookupContext &context);
144 private:
145 QList<Symbol *> resolveClass(NamedType *namedTy,
146 ResolveExpression::Result p,
147 const LookupContext &context);
149 QList<Symbol *> resolveClass(ResolveExpression::Result p,
150 const LookupContext &context);
152 private:
153 QList<ResolveExpression::Result> _blackList;
157 } // end of namespace CPlusPlus
159 #endif // CPLUSPLUS_RESOLVEEXPRESSION_H