1
|
1 /****************************************************************************
|
|
2 **
|
|
3 ** Copyright (C) 1992-2008 Nokia. All rights reserved.
|
|
4 ** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
|
|
5 **
|
|
6 ** This file is part of Qt Jambi.
|
|
7 **
|
|
8 ** * Commercial Usage
|
|
9 * Licensees holding valid Qt Commercial licenses may use this file in
|
|
10 * accordance with the Qt Commercial License Agreement provided with the
|
|
11 * Software or, alternatively, in accordance with the terms contained in
|
|
12 * a written agreement between you and Nokia.
|
|
13 *
|
|
14 *
|
|
15 * GNU General Public License Usage
|
|
16 * Alternatively, this file may be used under the terms of the GNU
|
|
17 * General Public License versions 2.0 or 3.0 as published by the Free
|
|
18 * Software Foundation and appearing in the file LICENSE.GPL included in
|
|
19 * the packaging of this file. Please review the following information
|
|
20 * to ensure GNU General Public Licensing requirements will be met:
|
|
21 * http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
|
22 * http://www.gnu.org/copyleft/gpl.html. In addition, as a special
|
|
23 * exception, Nokia gives you certain additional rights. These rights
|
|
24 * are described in the Nokia Qt GPL Exception version 1.2, included in
|
|
25 * the file GPL_EXCEPTION.txt in this package.
|
|
26 *
|
|
27 * Qt for Windows(R) Licensees
|
|
28 * As a special exception, Nokia, as the sole copyright holder for Qt
|
|
29 * Designer, grants users of the Qt/Eclipse Integration plug-in the
|
|
30 * right for the Qt/Eclipse Integration to link to functionality
|
|
31 * provided by Qt Designer and its related libraries.
|
|
32 *
|
|
33 *
|
|
34 * If you are unsure which license is appropriate for your use, please
|
|
35 * contact the sales department at qt-sales@nokia.com.
|
|
36
|
|
37 **
|
|
38 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
39 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
40 **
|
|
41 ****************************************************************************/
|
|
42
|
|
43
|
|
44 #ifndef BINDER_H
|
|
45 #define BINDER_H
|
|
46
|
|
47 #include "default_visitor.h"
|
|
48 #include "codemodel.h"
|
|
49 #include "type_compiler.h"
|
|
50 #include "name_compiler.h"
|
|
51 #include "declarator_compiler.h"
|
|
52
|
|
53 class TokenStream;
|
|
54 class LocationManager;
|
|
55 class Control;
|
|
56 struct NameSymbol;
|
|
57
|
|
58 typedef void (*MessageHandler)(const std::string &s);
|
|
59
|
|
60 class Binder: protected DefaultVisitor
|
|
61 {
|
|
62 public:
|
|
63 Binder(CodeModel *__model, LocationManager &__location, Control *__control = 0);
|
|
64 virtual ~Binder();
|
|
65
|
|
66 inline TokenStream *tokenStream() const { return _M_token_stream; }
|
|
67 inline CodeModel *model() const { return _M_model; }
|
|
68 ScopeModelItem currentScope();
|
|
69
|
|
70 FileModelItem run(AST *node);
|
|
71
|
|
72 // utils
|
|
73 TypeInfo qualifyType(const TypeInfo &type, const QStringList &context) const;
|
|
74
|
|
75 static void installMessageHandler(MessageHandler handler);
|
|
76
|
|
77 protected:
|
|
78 virtual void visitAccessSpecifier(AccessSpecifierAST *);
|
|
79 virtual void visitClassSpecifier(ClassSpecifierAST *);
|
|
80 virtual void visitEnumSpecifier(EnumSpecifierAST *);
|
|
81 virtual void visitEnumerator(EnumeratorAST *);
|
|
82 virtual void visitFunctionDefinition(FunctionDefinitionAST *);
|
|
83 virtual void visitLinkageSpecification(LinkageSpecificationAST *);
|
|
84 virtual void visitNamespace(NamespaceAST *);
|
|
85 virtual void visitSimpleDeclaration(SimpleDeclarationAST *);
|
|
86 virtual void visitTemplateDeclaration(TemplateDeclarationAST *);
|
|
87 virtual void visitTypedef(TypedefAST *);
|
|
88 virtual void visitUsing(UsingAST *);
|
|
89 virtual void visitUsingDirective(UsingDirectiveAST *);
|
|
90 virtual void visitQProperty(QPropertyAST *);
|
|
91 virtual void visitForwardDeclarationSpecifier(ForwardDeclarationSpecifierAST *);
|
|
92 virtual void visitQEnums(QEnumsAST *);
|
|
93
|
|
94 private:
|
|
95
|
|
96 int decode_token(std::size_t index) const;
|
|
97 const NameSymbol *decode_symbol(std::size_t index) const;
|
|
98 CodeModel::AccessPolicy decode_access_policy(std::size_t index) const;
|
|
99 CodeModel::ClassType decode_class_type(std::size_t index) const;
|
|
100
|
|
101 CodeModel::FunctionType changeCurrentFunctionType(CodeModel::FunctionType functionType);
|
|
102 CodeModel::AccessPolicy changeCurrentAccess(CodeModel::AccessPolicy accessPolicy);
|
|
103 NamespaceModelItem changeCurrentNamespace(NamespaceModelItem item);
|
|
104 ClassModelItem changeCurrentClass(ClassModelItem item);
|
|
105 FunctionDefinitionModelItem changeCurrentFunction(FunctionDefinitionModelItem item);
|
|
106 TemplateParameterList changeTemplateParameters(TemplateParameterList templateParameters);
|
|
107
|
|
108 void declare_symbol(SimpleDeclarationAST *node, InitDeclaratorAST *init_declarator);
|
|
109
|
|
110 void applyStorageSpecifiers(const ListNode<std::size_t> *storage_specifiers, MemberModelItem item);
|
|
111 void applyFunctionSpecifiers(const ListNode<std::size_t> *it, FunctionModelItem item);
|
|
112
|
|
113 void updateItemPosition(CodeModelItem item, AST *node);
|
|
114
|
|
115 private:
|
|
116 CodeModel *_M_model;
|
|
117 LocationManager &_M_location;
|
|
118 TokenStream *_M_token_stream;
|
|
119 Control *_M_control;
|
|
120
|
|
121 CodeModel::FunctionType _M_current_function_type;
|
|
122 CodeModel::AccessPolicy _M_current_access;
|
|
123 FileModelItem _M_current_file;
|
|
124 NamespaceModelItem _M_current_namespace;
|
|
125 ClassModelItem _M_current_class;
|
|
126 FunctionDefinitionModelItem _M_current_function;
|
|
127 EnumModelItem _M_current_enum;
|
|
128 QStringList _M_context;
|
|
129 TemplateParameterList _M_current_template_parameters; // ### check me
|
|
130 QHash<QString, QString> _M_qualified_types;
|
|
131 QHash<QString, int> _M_anonymous_enums;
|
|
132
|
|
133 static MessageHandler _M_message_handler;
|
|
134
|
|
135 protected:
|
|
136 TypeCompiler type_cc;
|
|
137 NameCompiler name_cc;
|
|
138 DeclaratorCompiler decl_cc;
|
|
139 };
|
|
140
|
|
141 #endif // BINDER_H
|
|
142
|
|
143 // kate: space-indent on; indent-width 2; replace-tabs on;
|