Mercurial > projects > qtd
annotate generator/parser/control.h @ 397:590dcfc85873
Quick const-correctness fix for QModelIndex.
This probably deserves a more in-depth look later.
author | David Nadlinger <code@klickverbot.at> |
---|---|
date | Mon, 03 Jan 2011 08:30:59 +0100 |
parents | 09a0f1d048f2 |
children |
rev | line source |
---|---|
1 | 1 /**************************************************************************** |
2 ** | |
52
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
3 ** Copyright (C) 1992-2009 Nokia. All rights reserved. |
1 | 4 ** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org> |
5 ** | |
6 ** This file is part of Qt Jambi. | |
7 ** | |
52
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
8 ** Commercial Usage |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
9 Licensees holding valid Qt Commercial licenses may use this file in |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
10 accordance with the Qt Commercial License Agreement provided with the |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
11 Software or, alternatively, in accordance with the terms contained in |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
12 a written agreement between you and Nokia. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
13 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
14 GNU Lesser General Public License Usage |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
15 Alternatively, this file may be used under the terms of the GNU Lesser |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
16 General Public License version 2.1 as published by the Free Software |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
17 Foundation and appearing in the file LICENSE.LGPL included in the |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
18 packaging of this file. Please review the following information to |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
19 ensure the GNU Lesser General Public License version 2.1 requirements |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
20 will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
21 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
22 In addition, as a special exception, Nokia gives you certain |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
23 additional rights. These rights are described in the Nokia Qt LGPL |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
24 Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
25 package. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
26 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
27 GNU General Public License Usage |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
28 Alternatively, this file may be used under the terms of the GNU |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
29 General Public License version 3.0 as published by the Free Software |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
30 Foundation and appearing in the file LICENSE.GPL included in the |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
31 packaging of this file. Please review the following information to |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
32 ensure the GNU General Public License version 3.0 requirements will be |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
33 met: http://www.gnu.org/copyleft/gpl.html. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
34 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
35 If you are unsure which license is appropriate for your use, please |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
36 contact the sales department at qt-sales@nokia.com. |
1 | 37 |
38 ** | |
39 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |
40 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
41 ** | |
42 ****************************************************************************/ | |
43 | |
44 | |
45 #ifndef CONTROL_H | |
46 #define CONTROL_H | |
47 | |
48 #include "symbol.h" | |
49 #include "smallobject.h" | |
50 | |
51 #include <QtCore/QHash> | |
52 | |
53 struct Declarator; | |
54 struct Type; | |
55 class Lexer; | |
56 class Parser; | |
57 | |
58 struct Context | |
59 { | |
60 Context *parent; | |
61 | |
62 inline void bind(const NameSymbol *name, Type *type) | |
63 { symbol_table.insert(name, type); } | |
64 | |
65 inline Type *resolve(const NameSymbol *name) const | |
66 { | |
67 if (Type *type = symbol_table.value(name)) | |
68 return type; | |
69 else if (parent) | |
70 return parent->resolve(name); | |
71 | |
72 return 0; | |
73 } | |
74 | |
75 typedef QHash<const NameSymbol*, Type*> symbol_table_t; | |
76 | |
77 symbol_table_t symbol_table; | |
78 }; | |
79 | |
80 class Control | |
81 { | |
82 public: | |
83 class ErrorMessage | |
84 { | |
85 public: | |
86 ErrorMessage (): | |
87 _M_line (0), | |
88 _M_column (0) {} | |
89 | |
90 inline int line () const { return _M_line; } | |
91 inline void setLine (int line) { _M_line = line; } | |
92 | |
93 inline int column () const { return _M_column; } | |
94 inline void setColumn (int column) { _M_column = column; } | |
95 | |
96 inline QString fileName () const { return _M_fileName; } | |
97 inline void setFileName (const QString &fileName) { _M_fileName = fileName; } | |
98 | |
99 inline QString message () const { return _M_message; } | |
100 inline void setMessage (const QString &message) { _M_message = message; } | |
101 | |
102 private: | |
103 int _M_line; | |
104 int _M_column; | |
105 QString _M_fileName; | |
106 QString _M_message; | |
107 }; | |
108 | |
109 Control(); | |
110 ~Control(); | |
111 | |
112 inline bool skipFunctionBody() const { return _M_skipFunctionBody; } | |
113 inline void setSkipFunctionBody(bool skip) { _M_skipFunctionBody = skip; } | |
114 | |
115 Lexer *changeLexer(Lexer *lexer); | |
116 Parser *changeParser(Parser *parser); | |
117 | |
118 Lexer *currentLexer() const { return _M_lexer; } | |
119 Parser *currentParser() const { return _M_parser; } | |
120 | |
121 Context *current_context; | |
122 | |
123 inline Context *currentContext() const | |
124 { return current_context; } | |
125 | |
126 void pushContext(); | |
127 void popContext(); | |
128 | |
129 Type *lookupType(const NameSymbol *name) const; | |
130 void declare(const NameSymbol *name, Type *type); | |
131 | |
132 inline const NameSymbol *findOrInsertName(const char *data, size_t count) | |
133 { return name_table.findOrInsert(data, count); } | |
134 | |
135 void declareTypedef(const NameSymbol *name, Declarator *d); | |
136 bool isTypedef(const NameSymbol *name) const; | |
137 | |
138 void reportError (const ErrorMessage &errmsg); | |
139 QList<ErrorMessage> errorMessages () const; | |
140 void clearErrorMessages (); | |
141 | |
142 private: | |
143 NameTable name_table; | |
144 QHash<const NameSymbol*, Declarator*> stl_typedef_table; | |
145 bool _M_skipFunctionBody; | |
146 Lexer *_M_lexer; | |
147 Parser *_M_parser; | |
148 | |
149 QList<ErrorMessage> _M_error_messages; | |
150 }; | |
151 | |
152 #endif // CONTROL_H | |
153 | |
154 // kate: space-indent on; indent-width 2; replace-tabs on; |