Mercurial > projects > qtd
annotate generator/parser/codemodel_finder.cpp @ 86:bee1446909c5
minor spelling fix
author | maxter |
---|---|
date | Tue, 26 May 2009 06:25:44 +0000 |
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 #include "codemodel_finder.h" | |
46 #include "codemodel.h" | |
47 #include "binder.h" | |
48 | |
49 CodeModelFinder::CodeModelFinder(CodeModel *model, Binder *binder) | |
50 : _M_model(model), | |
51 _M_binder (binder), | |
52 _M_token_stream(binder->tokenStream ()), | |
53 name_cc(_M_binder), | |
54 _M_resolve_policy(ResolveItem) | |
55 { | |
56 } | |
57 | |
58 CodeModelFinder::~CodeModelFinder() | |
59 { | |
60 } | |
61 | |
62 ScopeModelItem CodeModelFinder::resolveScope(NameAST *name, ScopeModelItem scope) | |
63 { | |
64 Q_ASSERT(scope != 0); | |
65 | |
66 ResolvePolicy saved_resolve_policy = _M_resolve_policy; | |
67 _M_resolve_policy = ResolveScope; | |
68 | |
69 ScopeModelItem old = changeCurrentScope(scope); | |
70 | |
71 visit(name); | |
72 ScopeModelItem result = _M_current_scope; | |
73 | |
74 changeCurrentScope(old); // restore | |
75 | |
76 _M_resolve_policy = saved_resolve_policy; | |
77 | |
78 return result; | |
79 } | |
80 | |
81 ScopeModelItem CodeModelFinder::changeCurrentScope(ScopeModelItem scope) | |
82 { | |
83 ScopeModelItem old = _M_current_scope; | |
84 _M_current_scope = scope; | |
85 return old; | |
86 } | |
87 | |
88 void CodeModelFinder::visitName(NameAST *node) | |
89 { | |
90 visitNodes(this, node->qualified_names); | |
91 | |
92 if (_M_resolve_policy == ResolveItem) | |
93 visit(node->unqualified_name); | |
94 } | |
95 | |
96 void CodeModelFinder::visitUnqualifiedName(UnqualifiedNameAST *node) | |
97 { | |
98 if (!_M_current_scope) | |
99 { | |
100 // nothing to do | |
101 return; | |
102 } | |
103 | |
104 name_cc.run(node); | |
105 QString id = name_cc.name(); | |
106 | |
107 if (ClassModelItem klass = _M_current_scope->findClass(id)) | |
108 { | |
109 _M_current_scope = klass; | |
110 } | |
111 else if (NamespaceModelItem parentNamespace = model_safe_cast<NamespaceModelItem>(_M_current_scope)) | |
112 { | |
113 NamespaceModelItem ns = parentNamespace->findNamespace(id); | |
114 _M_current_scope = model_static_cast<ScopeModelItem>(ns); | |
115 } | |
116 else if (FileModelItem file = model_safe_cast<FileModelItem>(_M_current_scope)) | |
117 { | |
118 NamespaceModelItem ns = file->findNamespace(id); | |
119 _M_current_scope = model_static_cast<ScopeModelItem>(ns); | |
120 } | |
121 } | |
122 | |
123 // kate: space-indent on; indent-width 2; replace-tabs on; | |
124 |