1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the test suite of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | #include <QtDebug> |
30 | |
31 | #include <private/qabstractfloat_p.h> |
32 | #include <private/qandexpression_p.h> |
33 | #include <private/qanyuri_p.h> |
34 | #include <private/qapplytemplate_p.h> |
35 | #include <private/qargumentreference_p.h> |
36 | #include <private/qarithmeticexpression_p.h> |
37 | #include <private/qatomicstring_p.h> |
38 | #include <private/qatomizer_p.h> |
39 | #include <private/qattributeconstructor_p.h> |
40 | #include <private/qattributenamevalidator_p.h> |
41 | #include <private/qaxisstep_p.h> |
42 | #include <private/qbase64binary_p.h> |
43 | #include <private/qboolean_p.h> |
44 | #include <private/qcardinalityverifier_p.h> |
45 | #include <private/qcastableas_p.h> |
46 | #include <private/qcastas_p.h> |
47 | #include <private/qcombinenodes_p.h> |
48 | #include <private/qcontextitem_p.h> |
49 | #include <private/qdate_p.h> |
50 | #include <private/qdecimal_p.h> |
51 | #include <private/qdynamiccontextstore_p.h> |
52 | #include <private/qelementconstructor_p.h> |
53 | #include <private/qemptysequence_p.h> |
54 | #include <private/qevaluationcache_p.h> |
55 | #include <private/qexpressionsequence_p.h> |
56 | #include <private/qexpressionvariablereference_p.h> |
57 | #include <private/qfirstitempredicate_p.h> |
58 | #include <private/qforclause_p.h> |
59 | #include <private/qfunctioncall_p.h> |
60 | #include <private/qgday_p.h> |
61 | #include <private/qgeneralcomparison_p.h> |
62 | #include <private/qgenericpredicate_p.h> |
63 | #include <private/qgmonthday_p.h> |
64 | #include <private/qgmonth_p.h> |
65 | #include <private/qgyearmonth_p.h> |
66 | #include <private/qgyear_p.h> |
67 | #include <private/qhexbinary_p.h> |
68 | #include <private/qifthenclause_p.h> |
69 | #include <private/qinstanceof_p.h> |
70 | #include <private/qinteger_p.h> |
71 | #include <private/qitem_p.h> |
72 | #include <private/qitemverifier_p.h> |
73 | #include <private/qliteral_p.h> |
74 | #include <private/qnamespaceconstructor_p.h> |
75 | #include <private/qncnameconstructor_p.h> |
76 | #include <private/qnodecomparison_p.h> |
77 | #include <private/qorexpression_p.h> |
78 | #include <private/qpath_p.h> |
79 | #include <private/qpositionalvariablereference_p.h> |
80 | #include <private/qqnameconstructor_p.h> |
81 | #include <private/qqnamevalue_p.h> |
82 | #include <private/qquantifiedexpression_p.h> |
83 | #include <private/qrangeexpression_p.h> |
84 | #include <private/qrangevariablereference_p.h> |
85 | #include <private/qschemadatetime_p.h> |
86 | #include <private/qschematime_p.h> |
87 | #include <private/qsimplecontentconstructor_p.h> |
88 | #include <private/qtreatas_p.h> |
89 | #include <private/qtruthpredicate_p.h> |
90 | #include <private/quntypedatomicconverter_p.h> |
91 | #include <private/quntypedatomic_p.h> |
92 | #include <private/quserfunctioncallsite_p.h> |
93 | #include <private/qvalidationerror_p.h> |
94 | #include <private/qvaluecomparison_p.h> |
95 | |
96 | #include "ExpressionInfo.h" |
97 | #include "Global.h" |
98 | |
99 | #include "ExpressionNamer.h" |
100 | |
101 | using namespace QPatternistSDK; |
102 | |
103 | /* Simple ones, they have no additional data. */ |
104 | #define implClass(cls) \ |
105 | QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::(const QPatternist::cls *) const \ |
106 | { \ |
107 | return QPatternist::ExpressionVisitorResult::Ptr \ |
108 | (new ExpressionInfo(QLatin1String(#cls), QString())); \ |
109 | } |
110 | |
111 | implClass(AndExpression) |
112 | implClass(ArgumentConverter) |
113 | implClass(Atomizer) |
114 | implClass(AttributeConstructor) |
115 | implClass(AttributeNameValidator) |
116 | implClass(CallTemplate) |
117 | implClass(CardinalityVerifier) |
118 | implClass(CollationChecker) |
119 | implClass(CommentConstructor) |
120 | implClass(ComputedNamespaceConstructor) |
121 | implClass(ContextItem) |
122 | implClass(CopyOf) |
123 | implClass(CurrentItemStore) |
124 | implClass(DocumentConstructor) |
125 | implClass(DynamicContextStore) |
126 | implClass(EBVExtractor) |
127 | implClass(ElementConstructor) |
128 | implClass(EmptySequence) |
129 | implClass(ExpressionSequence) |
130 | implClass(ExternalVariableReference) |
131 | implClass(FirstItemPredicate) |
132 | implClass(ForClause) |
133 | implClass(GenericPredicate) |
134 | implClass(IfThenClause) |
135 | implClass(ItemVerifier) |
136 | implClass(LetClause) |
137 | implClass(LiteralSequence) |
138 | implClass(NCNameConstructor) |
139 | implClass(NodeSortExpression) |
140 | implClass(OrderBy) |
141 | implClass(OrExpression) |
142 | implClass(ParentNodeAxis) |
143 | implClass(ProcessingInstructionConstructor) |
144 | implClass(QNameConstructor) |
145 | implClass(RangeExpression) |
146 | implClass(ReturnOrderBy) |
147 | implClass(SimpleContentConstructor) |
148 | implClass(StaticBaseURIStore) |
149 | implClass(StaticCompatibilityStore) |
150 | implClass(TemplateParameterReference) |
151 | implClass(TextNodeConstructor) |
152 | implClass(TreatAs) |
153 | implClass(TruthPredicate) |
154 | implClass(UnresolvedVariableReference) |
155 | implClass(UntypedAtomicConverter) |
156 | implClass(UserFunctionCallsite) |
157 | implClass(ValidationError) |
158 | #undef implClass |
159 | |
160 | /** Variable references. */ |
161 | #define implVarRef(name) \ |
162 | QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::name *i) const \ |
163 | { \ |
164 | return QPatternist::ExpressionVisitorResult::Ptr \ |
165 | (new ExpressionInfo(QLatin1String(#name), \ |
166 | QString(QLatin1String("Slot: %1")).arg(i->slot()))); \ |
167 | } |
168 | implVarRef(RangeVariableReference) |
169 | implVarRef(ArgumentReference) |
170 | implVarRef(ExpressionVariableReference) |
171 | implVarRef(PositionalVariableReference) |
172 | #undef implVarRef |
173 | |
174 | /* Type related classes which have a targetType() function. */ |
175 | #define implTypeClass(cls) \ |
176 | QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::cls *i) const \ |
177 | { \ |
178 | return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(QLatin1String(#cls), \ |
179 | i->targetType()->displayName(Global::namePool()))); \ |
180 | } |
181 | |
182 | implTypeClass(InstanceOf) |
183 | implTypeClass(CastableAs) |
184 | #undef implTypeClass |
185 | |
186 | /* Type related classes which have a targetType() function. */ |
187 | QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::CastAs *i) const |
188 | { |
189 | return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(QLatin1String("CastAs" ), |
190 | i->targetSequenceType()->displayName(np: Global::namePool()))); |
191 | } |
192 | |
193 | /* Classes which represent operators. */ |
194 | #define implOPClass(cls, compClass) \ |
195 | QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::cls *i) const \ |
196 | { \ |
197 | return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(QLatin1String(#cls), \ |
198 | QPatternist::compClass::displayName(i->operatorID()))); \ |
199 | } |
200 | |
201 | implOPClass(ArithmeticExpression, AtomicMathematician) |
202 | implOPClass(NodeComparison, NodeComparison) |
203 | implOPClass(QuantifiedExpression, QuantifiedExpression) |
204 | implOPClass(CombineNodes, CombineNodes) |
205 | #undef implOPClass |
206 | |
207 | /* Classes which represent operators. */ |
208 | #define implCompClass(cls, type) \ |
209 | QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::cls *i) const \ |
210 | { \ |
211 | return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(QLatin1String(#cls), \ |
212 | QPatternist::AtomicComparator::displayName(i->operatorID(), \ |
213 | QPatternist::AtomicComparator::type))); \ |
214 | } |
215 | |
216 | implCompClass(GeneralComparison, AsGeneralComparison) |
217 | implCompClass(ValueComparison, AsValueComparison) |
218 | #undef implCompClass |
219 | |
220 | QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::FunctionCall *i) const |
221 | { |
222 | return QPatternist::ExpressionVisitorResult::Ptr |
223 | (new ExpressionInfo(QLatin1String("FunctionCall" ), |
224 | Global::namePool()->displayName(qName: i->signature()->name()))); |
225 | } |
226 | |
227 | QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::Literal *i) const |
228 | { |
229 | return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo( |
230 | i->item().type()->displayName(np: Global::namePool()), |
231 | i->item().stringValue())); |
232 | } |
233 | |
234 | QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::AxisStep *i) const |
235 | { |
236 | return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(QLatin1String("AxisStep" ), |
237 | QPatternist::AxisStep::axisName(axis: i->axis()) + |
238 | QLatin1String("::" ) + |
239 | i->nodeTest()->displayName(np: Global::namePool()))); |
240 | |
241 | } |
242 | |
243 | |
244 | QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::EvaluationCache<true> *i) const |
245 | { |
246 | return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(QLatin1String("EvaluationCache<IsForGlobal=true>" ), |
247 | QLatin1String("Slot: " ) + QString::number(i->slot()))); |
248 | |
249 | } |
250 | |
251 | QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::EvaluationCache<false> *i) const |
252 | { |
253 | return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(QLatin1String("EvaluationCache<IsForGlobal=false>" ), |
254 | QLatin1String("Slot: " ) + QString::number(i->slot()))); |
255 | |
256 | } |
257 | |
258 | QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::NamespaceConstructor *i) const |
259 | { |
260 | return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(QLatin1String("NamespaceConstructor" ), |
261 | Global::namePool()->stringForPrefix(code: i->namespaceBinding().prefix()) + |
262 | QLatin1Char('=') + |
263 | Global::namePool()->stringForNamespace(code: i->namespaceBinding().namespaceURI()))); |
264 | |
265 | } |
266 | |
267 | QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::Path *path) const |
268 | { |
269 | |
270 | QPatternist::Path::Kind k = path->kind(); |
271 | QString type; |
272 | |
273 | switch(k) |
274 | { |
275 | case QPatternist::Path::XSLTForEach: |
276 | { |
277 | type = QLatin1String("XSLTForEach" ); |
278 | break; |
279 | } |
280 | case QPatternist::Path::RegularPath: |
281 | { |
282 | type = QLatin1String("RegularPath" ); |
283 | break; |
284 | } |
285 | case QPatternist::Path::ForApplyTemplate: |
286 | { |
287 | type = QLatin1String("ForApplyTemplate" ); |
288 | break; |
289 | } |
290 | } |
291 | |
292 | return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(QLatin1String("Path" ), type)); |
293 | } |
294 | |
295 | QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::ApplyTemplate *path) const |
296 | { |
297 | const QPatternist::TemplateMode::Ptr mode(path->mode()); |
298 | return QPatternist::ExpressionVisitorResult::Ptr |
299 | (new ExpressionInfo(QLatin1String("ApplyTemplate" ), mode ? Global::namePool()->displayName(qName: mode->name()) : QString::fromLatin1(str: "#current" ))); |
300 | } |
301 | |
302 | // vim: et:ts=4:sw=4:sts=4 |
303 | |
304 | |