1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the test suite of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
40 ****************************************************************************/
44 #include <private/qabstractfloat_p.h>
45 #include <private/qandexpression_p.h>
46 #include <private/qanyuri_p.h>
47 #include <private/qapplytemplate_p.h>
48 #include <private/qargumentreference_p.h>
49 #include <private/qarithmeticexpression_p.h>
50 #include <private/qatomicstring_p.h>
51 #include <private/qatomizer_p.h>
52 #include <private/qattributeconstructor_p.h>
53 #include <private/qattributenamevalidator_p.h>
54 #include <private/qaxisstep_p.h>
55 #include <private/qbase64binary_p.h>
56 #include <private/qboolean_p.h>
57 #include <private/qcardinalityverifier_p.h>
58 #include <private/qcastableas_p.h>
59 #include <private/qcastas_p.h>
60 #include <private/qcombinenodes_p.h>
61 #include <private/qcontextitem_p.h>
62 #include <private/qdate_p.h>
63 #include <private/qdecimal_p.h>
64 #include <private/qdynamiccontextstore_p.h>
65 #include <private/qelementconstructor_p.h>
66 #include <private/qemptysequence_p.h>
67 #include <private/qevaluationcache_p.h>
68 #include <private/qexpressionsequence_p.h>
69 #include <private/qexpressionvariablereference_p.h>
70 #include <private/qfirstitempredicate_p.h>
71 #include <private/qforclause_p.h>
72 #include <private/qfunctioncall_p.h>
73 #include <private/qgday_p.h>
74 #include <private/qgeneralcomparison_p.h>
75 #include <private/qgenericpredicate_p.h>
76 #include <private/qgmonthday_p.h>
77 #include <private/qgmonth_p.h>
78 #include <private/qgyearmonth_p.h>
79 #include <private/qgyear_p.h>
80 #include <private/qhexbinary_p.h>
81 #include <private/qifthenclause_p.h>
82 #include <private/qinstanceof_p.h>
83 #include <private/qinteger_p.h>
84 #include <private/qitem_p.h>
85 #include <private/qitemverifier_p.h>
86 #include <private/qliteral_p.h>
87 #include <private/qnamespaceconstructor_p.h>
88 #include <private/qncnameconstructor_p.h>
89 #include <private/qnodecomparison_p.h>
90 #include <private/qorexpression_p.h>
91 #include <private/qpath_p.h>
92 #include <private/qpositionalvariablereference_p.h>
93 #include <private/qqnameconstructor_p.h>
94 #include <private/qqnamevalue_p.h>
95 #include <private/qquantifiedexpression_p.h>
96 #include <private/qrangeexpression_p.h>
97 #include <private/qrangevariablereference_p.h>
98 #include <private/qschemadatetime_p.h>
99 #include <private/qschematime_p.h>
100 #include <private/qsimplecontentconstructor_p.h>
101 #include <private/qtreatas_p.h>
102 #include <private/qtruthpredicate_p.h>
103 #include <private/quntypedatomicconverter_p.h>
104 #include <private/quntypedatomic_p.h>
105 #include <private/quserfunctioncallsite_p.h>
106 #include <private/qvalidationerror_p.h>
107 #include <private/qvaluecomparison_p.h>
109 #include "ExpressionInfo.h"
112 #include "ExpressionNamer.h"
114 using namespace QPatternistSDK;
116 /* Simple ones, they have no additional data. */
117 #define implClass(cls) \
118 QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::cls *) const \
120 return QPatternist::ExpressionVisitorResult::Ptr \
121 (new ExpressionInfo(QLatin1String(#cls), QString())); \
124 implClass(AndExpression)
125 implClass(ArgumentConverter)
127 implClass(AttributeConstructor)
128 implClass(AttributeNameValidator)
129 implClass(CallTemplate)
130 implClass(CardinalityVerifier)
131 implClass(CollationChecker)
132 implClass(CommentConstructor)
133 implClass(ComputedNamespaceConstructor)
134 implClass(ContextItem)
136 implClass(CurrentItemStore)
137 implClass(DocumentConstructor)
138 implClass(DynamicContextStore)
139 implClass(EBVExtractor)
140 implClass(ElementConstructor)
141 implClass(EmptySequence)
142 implClass(ExpressionSequence)
143 implClass(ExternalVariableReference)
144 implClass(FirstItemPredicate)
146 implClass(GenericPredicate)
147 implClass(IfThenClause)
148 implClass(ItemVerifier)
150 implClass(LiteralSequence)
151 implClass(NCNameConstructor)
152 implClass(NodeSortExpression)
154 implClass(OrExpression)
155 implClass(ParentNodeAxis)
156 implClass(ProcessingInstructionConstructor)
157 implClass(QNameConstructor)
158 implClass(RangeExpression)
159 implClass(ReturnOrderBy)
160 implClass(SimpleContentConstructor)
161 implClass(StaticBaseURIStore)
162 implClass(StaticCompatibilityStore)
163 implClass(TemplateParameterReference)
164 implClass(TextNodeConstructor)
166 implClass(TruthPredicate)
167 implClass(UnresolvedVariableReference)
168 implClass(UntypedAtomicConverter)
169 implClass(UserFunctionCallsite)
170 implClass(ValidationError)
173 /** Variable references. */
174 #define implVarRef(name) \
175 QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::name *i) const \
177 return QPatternist::ExpressionVisitorResult::Ptr \
178 (new ExpressionInfo(QLatin1String(#name), \
179 QString(QLatin1String("Slot: %1")).arg(i->slot()))); \
181 implVarRef(RangeVariableReference)
182 implVarRef(ArgumentReference)
183 implVarRef(ExpressionVariableReference)
184 implVarRef(PositionalVariableReference)
187 /* Type related classes which have a targetType() function. */
188 #define implTypeClass(cls) \
189 QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::cls *i) const \
191 return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(QLatin1String(#cls), \
192 i->targetType()->displayName(Global::namePool()))); \
195 implTypeClass(InstanceOf)
196 implTypeClass(CastableAs)
199 /* Type related classes which have a targetType() function. */
200 QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::CastAs *i) const
202 return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(QLatin1String("CastAs"),
203 i->targetSequenceType()->displayName(Global::namePool())));
206 /* Classes which represent operators. */
207 #define implOPClass(cls, compClass) \
208 QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::cls *i) const \
210 return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(QLatin1String(#cls), \
211 QPatternist::compClass::displayName(i->operatorID()))); \
214 implOPClass(ArithmeticExpression, AtomicMathematician)
215 implOPClass(NodeComparison, NodeComparison)
216 implOPClass(QuantifiedExpression, QuantifiedExpression)
217 implOPClass(CombineNodes, CombineNodes)
220 /* Classes which represent operators. */
221 #define implCompClass(cls, type) \
222 QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::cls *i) const \
224 return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(QLatin1String(#cls), \
225 QPatternist::AtomicComparator::displayName(i->operatorID(), \
226 QPatternist::AtomicComparator::type))); \
229 implCompClass(GeneralComparison, AsGeneralComparison)
230 implCompClass(ValueComparison, AsValueComparison)
233 QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::FunctionCall *i) const
235 return QPatternist::ExpressionVisitorResult::Ptr
236 (new ExpressionInfo(QLatin1String("FunctionCall"),
237 Global::namePool()->displayName(i->signature()->name())));
240 QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::Literal *i) const
242 return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(
243 i->item().type()->displayName(Global::namePool()),
244 i->item().stringValue()));
247 QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::AxisStep *i) const
249 return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(QLatin1String("AxisStep"),
250 QPatternist::AxisStep::axisName(i->axis()) +
251 QLatin1String("::") +
252 i->nodeTest()->displayName(Global::namePool())));
257 QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::EvaluationCache<true> *i) const
259 return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(QLatin1String("EvaluationCache<IsForGlobal=true>"),
260 QLatin1String("Slot: ") + QString::number(i->slot())));
264 QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::EvaluationCache<false> *i) const
266 return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(QLatin1String("EvaluationCache<IsForGlobal=false>"),
267 QLatin1String("Slot: ") + QString::number(i->slot())));
271 QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::NamespaceConstructor *i) const
273 return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(QLatin1String("NamespaceConstructor"),
274 Global::namePool()->stringForPrefix(i->namespaceBinding().prefix()) +
276 Global::namePool()->stringForNamespace(i->namespaceBinding().namespaceURI())));
280 QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::Path *path) const
283 QPatternist::Path::Kind k = path->kind();
288 case QPatternist::Path::XSLTForEach:
290 type = QLatin1String("XSLTForEach");
293 case QPatternist::Path::RegularPath:
295 type = QLatin1String("RegularPath");
298 case QPatternist::Path::ForApplyTemplate:
300 type = QLatin1String("ForApplyTemplate");
305 return QPatternist::ExpressionVisitorResult::Ptr(new ExpressionInfo(QLatin1String("Path"), type));
308 QPatternist::ExpressionVisitorResult::Ptr ExpressionNamer::visit(const QPatternist::ApplyTemplate *path) const
310 const QPatternist::TemplateMode::Ptr mode(path->mode());
311 return QPatternist::ExpressionVisitorResult::Ptr
312 (new ExpressionInfo(QLatin1String("ApplyTemplate"), mode ? Global::namePool()->displayName(mode->name()) : QString::fromLatin1("#current")));
315 // vim: et:ts=4:sw=4:sts=4