1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2020 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtQml module of the Qt Toolkit. |
7 | ** |
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 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 Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | **/ |
38 | #include "qqmljsastdumper.h" |
39 | #include <private/qqmljsast_p.h> |
40 | #include <QtCore/QDebug> |
41 | #include <QtCore/QString> |
42 | #include <QtCore/QTextStream> |
43 | |
44 | QT_BEGIN_NAMESPACE |
45 | |
46 | namespace QQmlJS { |
47 | using namespace AST; |
48 | /*! |
49 | \internal |
50 | \enum QQmlJS::DumperOptions |
51 | |
52 | This enum type specifies the options for the AstDumper. |
53 | The values can be combined with the '|' operator, and checked using the '&' operator. |
54 | |
55 | \value None |
56 | Default dumping options |
57 | \value NoLocations |
58 | Does not dump SourceLocations, allowing one to compare equivalent AST |
59 | generated by code formatted differently |
60 | \value NoAnnotations |
61 | Does not dump annotations |
62 | \value DumpNode |
63 | Does dump a <Node></Node> in preVisit/postVisit |
64 | */ |
65 | |
66 | /*! |
67 | \internal |
68 | \class QQmlJS::AstDumper |
69 | \brief Dumps or compares AST in an xml like format, mostly for testing/debugging |
70 | |
71 | Initialize it with a lambda that dumps a string, and configure it with .setX methods. |
72 | If \l{indent} is set to a non zero value the xml is indented by that amount, and |
73 | \l{baseIndent} is the initial indent. |
74 | If \l{emitNode} is true the node tag is emitted in the preVisit/postVisit. |
75 | If \l{emitLocation} is true the SourceLocations are emitted. |
76 | If \l{emitAnnotations} is true annotations are emitted |
77 | |
78 | The implementation has unnecessary roundtrips to QString, but it is supposed to be used |
79 | for debugging purposes... |
80 | |
81 | Probably you will not use the visitor at all but rather the static method diff or |
82 | the qDebug() and ostream operator << that use the visitor... |
83 | |
84 | \fn AstDumper::diff(AST::Node *n1, AST::Node *n2, int nContext, DumperOptions opt, int indent) |
85 | |
86 | \brief compares the two AST::Node n1 and n2 and returns a string describing their first difference |
87 | |
88 | If there are no differences the empty string is returned, so .isEmpty() can be use to check |
89 | for no differences. |
90 | \l{nContext} decides how much context is printed out. |
91 | |
92 | */ |
93 | |
94 | |
95 | QDebug operator<<(QDebug d, AST::Node *n) { |
96 | QDebug noQuote = d.noquote().nospace(); |
97 | AstDumper visitor([&noQuote](const QString &s){ noQuote << s; }); |
98 | Node::accept(node: n, visitor: &visitor); |
99 | return d; |
100 | } |
101 | |
102 | |
103 | std::ostream &operator<<(std::ostream &stream, AST::Node *n) { |
104 | AstDumper visitor([&stream](const QString &s){ stream << s.toStdString(); }); |
105 | Node::accept(node: n, visitor: &visitor); |
106 | return stream; |
107 | } |
108 | |
109 | bool operator & (DumperOptions lhs, DumperOptions rhs) { |
110 | return bool(static_cast<int>(lhs) & static_cast<int>(rhs)); |
111 | } |
112 | |
113 | DumperOptions operator | (DumperOptions lhs, DumperOptions rhs) { |
114 | return DumperOptions(static_cast<int>(lhs) | static_cast<int>(rhs)); |
115 | } |
116 | |
117 | QString AstDumper::diff(AST::Node *n1, AST::Node *n2, int nContext, DumperOptions opt, int indent) { |
118 | QString s1, s2; |
119 | QTextStream d1(&s1), d2(&s2); |
120 | AstDumper visitor1=AstDumper([&d1](const QString &s){ d1 << s; }, opt, indent); |
121 | AstDumper visitor2=AstDumper([&d2](const QString &s){ d2 << s; }, opt, indent); |
122 | Node::accept(node: n1, visitor: &visitor1); |
123 | Node::accept(node: n2, visitor: &visitor2); |
124 | d1.seek(pos: 0); |
125 | d2.seek(pos: 0); |
126 | std::vector<QString> preLines(nContext); |
127 | int nLine = 0; |
128 | bool same = true; |
129 | QString l1, l2; |
130 | while (same && !d1.atEnd() && !d2.atEnd()) { |
131 | l1=d1.readLine(); |
132 | l2=d2.readLine(); |
133 | if (l1 == l2) |
134 | preLines[nLine++ % nContext] = l1; |
135 | else |
136 | same = false; |
137 | } |
138 | QString res; |
139 | QTextStream ss(&res); |
140 | if (!same || !d1.atEnd() || !d2.atEnd()) { |
141 | for (int iline = qMin(a: nLine, b: nContext); iline > 0; --iline) { |
142 | ss << QLatin1String(" " ) << preLines[(nLine - iline) % nContext] << QLatin1String("\n" ); |
143 | } |
144 | int iline = 0; |
145 | if (!same) { |
146 | ss << QLatin1String("-" ) << l1 << QLatin1String("\n" ); |
147 | ++iline; |
148 | } |
149 | if (same && nContext == 0) |
150 | nContext = 1; |
151 | for (;iline < nContext && !d1.atEnd(); iline ++) { |
152 | l1 = d1.readLine(); |
153 | ss << QLatin1String("-" ) << l1 << QLatin1String("\n" ); |
154 | } |
155 | iline = 0; |
156 | if (!same) { |
157 | ss << QLatin1String("+" ) << l2 << QLatin1String("\n" ); |
158 | ++iline; |
159 | } |
160 | for (;iline < nContext && !d2.atEnd(); iline ++) { |
161 | l2 = d2.readLine(); |
162 | ss << QLatin1String("+" ) << l2 << QLatin1String("\n" ); |
163 | } |
164 | } |
165 | return res; |
166 | } |
167 | |
168 | QString AstDumper::printNode(Node *n, DumperOptions opt, int indent, int baseIndent) |
169 | { |
170 | QString res; |
171 | QTextStream d(&res); |
172 | AstDumper visitor=AstDumper([&d](const QString &s){ d << s; }, opt, indent, baseIndent); |
173 | Node::accept(node: n, visitor: &visitor); |
174 | return res; |
175 | } |
176 | |
177 | AstDumper::AstDumper(const std::function<void(const QString &)> &dumper, DumperOptions options, int indent, int baseIndent): |
178 | dumper(dumper), options(options), indent(indent), baseIndent(baseIndent) {} |
179 | |
180 | void AstDumper::start(const QString &str) { |
181 | dumper(QString::fromLatin1(str: " " ).repeated(times: baseIndent)); |
182 | dumper(QLatin1String("<" )); |
183 | dumper(str); |
184 | dumper(QLatin1String(">\n" )); |
185 | baseIndent += indent; |
186 | } |
187 | |
188 | void AstDumper::start(const char *str) { |
189 | start(str: QLatin1String(str)); |
190 | } |
191 | |
192 | void AstDumper::stop(const QString &str) { |
193 | baseIndent -= indent; |
194 | dumper(QString::fromLatin1(str: " " ).repeated(times: baseIndent)); |
195 | dumper(QLatin1String("</" )); |
196 | dumper(str); |
197 | dumper(QLatin1String(">\n" )); |
198 | } |
199 | |
200 | void AstDumper::stop(const char *str) { |
201 | stop(str: QLatin1String(str)); |
202 | } |
203 | |
204 | QString AstDumper::qs(const QString &s) { |
205 | QString res(s); |
206 | return QLatin1String("\"" ) + res |
207 | .replace(before: QLatin1String("\\" ), after: QLatin1String("\\\\" )) |
208 | .replace(before: QLatin1String("\"" ), after: QLatin1String("\\\"" )) + QLatin1String("\"" ); |
209 | } |
210 | |
211 | QString AstDumper::qs(const char *s) { |
212 | return qs(s: QLatin1String(s)); |
213 | } |
214 | |
215 | QString AstDumper::qs(const QStringRef &s) { |
216 | return qs(s: s.toString()); |
217 | } |
218 | |
219 | QString AstDumper::loc(const SourceLocation &s) { |
220 | if (noLocations() || !s.isValid()) |
221 | return QLatin1String("\"\"" ); |
222 | else { |
223 | return QLatin1String("\"off:%1 len:%2 l:%3 c:%4\"" ).arg(args: QString::number(s.offset), args: QString::number(s.length), args: QString::number(s.startLine), args: QString::number(s.startColumn)); |
224 | } |
225 | } |
226 | |
227 | QString AstDumper::boolStr(bool v) { return (v ? qs(s: "true" ): qs(s: "false" )); } |
228 | |
229 | bool AstDumper::preVisit(Node *) { if (dumpNode()) start(str: "Node" ); return true; } |
230 | |
231 | void AstDumper::postVisit(Node *) { if (dumpNode()) stop(str: "Node" ); } |
232 | |
233 | bool AstDumper::visit(UiProgram *) { start(str: "UiProgram" ); return true; } |
234 | |
235 | bool AstDumper::(UiHeaderItemList *) { start(str: "UiHeaderItemList" ); return true; } |
236 | |
237 | bool AstDumper::visit(UiPragma *el) { |
238 | start(str: QLatin1String("UiPragma name=%1 pragmaToken=%2 semicolonToken=%3" ) |
239 | .arg(args: qs(s: el->name), args: loc(s: el->pragmaToken), args: loc(s: el->semicolonToken))); |
240 | return true; |
241 | } |
242 | |
243 | bool AstDumper::visit(UiImport *el) |
244 | { |
245 | start(str: QLatin1String("UiImport fileName=%1 importId=%2 importToken=%3 fileNameToken=%4 asToken=%5 importIdToken=%6 semicolonToken=%7" ) |
246 | .arg(args: qs(s: el->fileName), args: qs(s: el->importId), args: loc(s: el->importToken), args: loc(s: el->fileNameToken), args: loc(s: el->asToken), args: loc(s: el->importIdToken), args: loc(s: el->semicolonToken))); |
247 | return true; |
248 | } |
249 | |
250 | bool AstDumper::visit(UiPublicMember *el) { |
251 | QString typeStr = ((el->type == UiPublicMember::Signal) ? QLatin1String("Signal" ) : |
252 | (el->type == UiPublicMember::Property) ? QLatin1String("Property" ) : QLatin1String("Unexpected(%1)" ).arg(args&: el->type)); |
253 | start(str: QLatin1String("UiPublicMember type=%1 typeModifier=%2 name=%3 isDefaultMember=%4 isReadonlyMember=%5 isRequired=%6 " |
254 | "defaultToken=%7 readonlyToken=%8 propertyToken=%9 requiredToken=%10 typeModifierToken=%11 typeToken=%12 " |
255 | "identifierToken=%13 colonToken=%14 semicolonToken=%15" ) |
256 | .arg(args: qs(s: typeStr), args: qs(s: el->typeModifier), args: qs(s: el->name), |
257 | args&: el->isDefaultMember, args&: el->isReadonlyMember, args&: el->isRequired, |
258 | args: loc(s: el->defaultToken), args: loc(s: el->readonlyToken), args: loc(s: el->propertyToken), |
259 | args: loc(s: el->requiredToken), args: loc(s: el->typeModifierToken), args: loc(s: el->typeToken), |
260 | args: loc(s: el->identifierToken), args: loc(s: el->colonToken), args: loc(s: el->semicolonToken) |
261 | )); |
262 | if (!noAnnotations()) // put annotations inside the node they refer to |
263 | Node::accept(node: el->annotations, visitor: this); |
264 | Node::accept(node: el->memberType, visitor: this); |
265 | return true; |
266 | } |
267 | |
268 | bool AstDumper::visit(AST::UiSourceElement *el) { |
269 | start(str: QLatin1String("UiSourceElement" )); |
270 | if (!noAnnotations()) // put annotations inside the node they refer to |
271 | Node::accept(node: el->annotations, visitor: this); |
272 | return true; |
273 | } |
274 | |
275 | bool AstDumper::visit(AST::UiObjectDefinition *el) { |
276 | start(str: "UiObjectDefinition" ); |
277 | if (!noAnnotations()) // put annotations inside the node they refer to |
278 | Node::accept(node: el->annotations, visitor: this); |
279 | return true; |
280 | } |
281 | |
282 | bool AstDumper::visit(AST::UiObjectInitializer *el) { |
283 | start(str: QLatin1String("UiObjectInitializer lbraceToken=%1 rbraceToken=%2" ) |
284 | .arg(args: loc(s: el->lbraceToken), args: loc(s: el->rbraceToken))); |
285 | return true; |
286 | } |
287 | |
288 | bool AstDumper::visit(AST::UiObjectBinding *el) { |
289 | start(str: QLatin1String("UiObjectBinding colonToken=%1 hasOnToken=%2" ) |
290 | .arg(args: loc(s: el->colonToken), args: boolStr(v: el->hasOnToken))); |
291 | if (!noAnnotations()) // put annotations inside the node they refer to |
292 | Node::accept(node: el->annotations, visitor: this); |
293 | return true; |
294 | } |
295 | |
296 | bool AstDumper::visit(AST::UiScriptBinding *el) { |
297 | start(str: QLatin1String("UiScriptBinding colonToken=%1" ) |
298 | .arg(args: loc(s: el->colonToken))); |
299 | if (!noAnnotations()) // put annotations inside the node they refer to |
300 | Node::accept(node: el->annotations, visitor: this); |
301 | return true; |
302 | } |
303 | |
304 | bool AstDumper::visit(AST::UiArrayBinding *el) { |
305 | start(str: QLatin1String("UiArrayBinding colonToken=%1 lbracketToken=%2 rbracketToken=%3" ) |
306 | .arg(args: loc(s: el->colonToken), args: loc(s: el->lbracketToken), args: loc(s: el->rbracketToken))); |
307 | if (!noAnnotations()) // put annotations inside the node they refer to |
308 | Node::accept(node: el->annotations, visitor: this); |
309 | return true; |
310 | } |
311 | |
312 | bool AstDumper::visit(AST::UiParameterList *el) { |
313 | start(str: QLatin1String("UiArrayBinding name=%1 commaToken=%2 propertyTypeToken=%3 identifierToken=%4 colonToken=%5" ) |
314 | .arg(args: qs(s: el->name), args: loc(s: el->commaToken), args: loc(s: el->propertyTypeToken), args: loc(s: el->identifierToken), args: loc(s: el->colonToken))); |
315 | Node::accept(node: el->type, visitor: this); |
316 | return true; |
317 | } |
318 | |
319 | bool AstDumper::visit(AST::UiObjectMemberList *) { start(str: "UiObjectMemberList" ); return true; } |
320 | |
321 | bool AstDumper::visit(AST::UiArrayMemberList *el) { |
322 | start(str: QLatin1String("UiArrayMemberList commaToken=%1" ) |
323 | .arg(args: loc(s: el->commaToken))); |
324 | return true; |
325 | } |
326 | |
327 | bool AstDumper::visit(AST::UiQualifiedId *el) { |
328 | start(str: QLatin1String("UiQualifiedId name=%1 identifierToken=%2" ) |
329 | .arg(args: qs(s: el->name), args: loc(s: el->identifierToken))); |
330 | Node::accept(node: el->next, visitor: this); |
331 | return true; |
332 | } |
333 | |
334 | bool AstDumper::visit(AST::UiEnumDeclaration *el) { |
335 | start(str: QLatin1String("UiEnumDeclaration enumToken=%1 rbraceToken=%2 name=%3" ) |
336 | .arg(args: loc(s: el->enumToken), args: loc(s: el->rbraceToken), args: qs(s: el->name))); |
337 | if (!noAnnotations()) // put annotations inside the node they refer to |
338 | Node::accept(node: el->annotations, visitor: this); |
339 | return true; |
340 | } |
341 | |
342 | bool AstDumper::visit(AST::UiEnumMemberList *el) { |
343 | start(str: QLatin1String("UiEnumMemberList member=%1 value=%2 memberToken=%3 valueToken=%4" ) |
344 | .arg(args: qs(s: el->member), args: qs(s: QString::number(el->value)), args: loc(s: el->memberToken), args: loc(s: el->valueToken))); |
345 | return true; |
346 | } |
347 | |
348 | bool AstDumper::visit(AST::UiVersionSpecifier *el) { |
349 | start(str: QLatin1String("UiVersionSpecifier majorVersion=%1 minorVersion=%2 majorToken=%3 minorToken=%4" ) |
350 | .arg(args: qs(s: QString::number(el->majorVersion)), args: qs(s: QString::number(el->minorVersion)), args: loc(s: el->majorToken), args: loc(s: el->minorToken))); |
351 | return true; |
352 | } |
353 | |
354 | bool AstDumper::visit(AST::UiInlineComponent *el) { |
355 | start(str: QLatin1String("UiInlineComponent name=%1 componentToken=%2" ) |
356 | .arg(args: qs(s: el->name), args: loc(s: el->componentToken))); |
357 | if (!noAnnotations()) // put annotations inside the node they refer to |
358 | Node::accept(node: el->annotations, visitor: this); |
359 | return true; |
360 | } |
361 | |
362 | bool AstDumper::visit(UiRequired *el) |
363 | { |
364 | start(str: QLatin1String("UiRequired name=%1 requiredToken=%2 semicolonToken=%3" ) |
365 | .arg(args: qs(s: el->name), args: loc(s: el->requiredToken), args: loc(s: el->semicolonToken))); |
366 | return true; |
367 | } |
368 | |
369 | bool AstDumper::visit(UiAnnotation *) |
370 | { |
371 | start(str: QLatin1String("UiAnnotation" )); |
372 | return true; |
373 | } |
374 | |
375 | bool AstDumper::visit(UiAnnotationList *) |
376 | { |
377 | start(str: QLatin1String("UiAnnotationList" )); |
378 | return true; |
379 | } |
380 | |
381 | void AstDumper::endVisit(AST::UiProgram *) { stop(str: "UiProgram" ); } |
382 | |
383 | void AstDumper::endVisit(AST::UiImport *el) { |
384 | Node::accept(node: el->version, visitor: this); |
385 | stop(str: "UiImport" ); |
386 | } |
387 | |
388 | void AstDumper::(AST::UiHeaderItemList *) { stop(str: "UiHeaderItemList" ); } |
389 | |
390 | void AstDumper::endVisit(AST::UiPragma *) { stop(str: "UiPragma" ); } |
391 | |
392 | void AstDumper::endVisit(AST::UiPublicMember *el) { |
393 | Node::accept(node: el->parameters, visitor: this); |
394 | stop(str: "UiPublicMember" ); |
395 | } |
396 | |
397 | void AstDumper::endVisit(AST::UiSourceElement *) { stop(str: "UiSourceElement" ); } |
398 | void AstDumper::endVisit(AST::UiObjectDefinition *) { stop(str: "UiObjectDefinition" ); } |
399 | void AstDumper::endVisit(AST::UiObjectInitializer *) { stop(str: "UiObjectInitializer" ); } |
400 | void AstDumper::endVisit(AST::UiObjectBinding *) { stop(str: "UiObjectBinding" ); } |
401 | void AstDumper::endVisit(AST::UiScriptBinding *) { stop(str: "UiScriptBinding" ); } |
402 | void AstDumper::endVisit(AST::UiArrayBinding *) { stop(str: "UiArrayBinding" ); } |
403 | void AstDumper::endVisit(AST::UiParameterList *el) { |
404 | stop(str: "UiParameterList" ); |
405 | Node::accept(node: el->next, visitor: this); // put other args at the same level as this one... |
406 | } |
407 | void AstDumper::endVisit(AST::UiObjectMemberList *) { stop(str: "UiObjectMemberList" ); } |
408 | void AstDumper::endVisit(AST::UiArrayMemberList *) { stop(str: "UiArrayMemberList" ); } |
409 | void AstDumper::endVisit(AST::UiQualifiedId *) { stop(str: "UiQualifiedId" ); } |
410 | void AstDumper::endVisit(AST::UiEnumDeclaration *) { stop(str: "UiEnumDeclaration" ); } |
411 | void AstDumper::endVisit(AST::UiEnumMemberList *el) { |
412 | stop(str: "UiEnumMemberList" ); |
413 | Node::accept(node: el->next, visitor: this); // put other enum members at the same level as this one... |
414 | } |
415 | void AstDumper::endVisit(AST::UiVersionSpecifier *) { stop(str: "UiVersionSpecifier" ); } |
416 | void AstDumper::endVisit(AST::UiInlineComponent *) { stop(str: "UiInlineComponent" ); } |
417 | void AstDumper::endVisit(UiRequired *) { stop(str: "UiRequired" ); } |
418 | void AstDumper::endVisit(UiAnnotation *) { stop(str: "UiAnnotation" ); } |
419 | void AstDumper::endVisit(UiAnnotationList *) { stop(str: "UiAnnotationList" ); } |
420 | |
421 | // QQmlJS |
422 | bool AstDumper::visit(AST::ThisExpression *el) { |
423 | start(str: QLatin1String("ThisExpression thisToken=%1" ) |
424 | .arg(args: loc(s: el->thisToken))); |
425 | return true; |
426 | } |
427 | void AstDumper::endVisit(AST::ThisExpression *) { stop(str: "ThisExpression" ); } |
428 | |
429 | bool AstDumper::visit(AST::IdentifierExpression *el) { |
430 | start(str: QLatin1String("IdentifierExpression name=%1 identiferToken=%2" ) |
431 | .arg(args: qs(s: el->name), args: loc(s: el->identifierToken))); |
432 | return true; |
433 | } |
434 | void AstDumper::endVisit(AST::IdentifierExpression *) { stop(str: "IdentifierExpression" ); } |
435 | |
436 | bool AstDumper::visit(AST::NullExpression *el) { |
437 | start(str: QLatin1String("NullExpression nullToken=%1" ) |
438 | .arg(args: loc(s: el->nullToken))); |
439 | return true; |
440 | } |
441 | void AstDumper::endVisit(AST::NullExpression *) { stop(str: "NullExpression" ); } |
442 | |
443 | bool AstDumper::visit(AST::TrueLiteral *el) { |
444 | start(str: QLatin1String("TrueLiteral trueToken=%1" ) |
445 | .arg(args: loc(s: el->trueToken))); |
446 | return true; |
447 | } |
448 | void AstDumper::endVisit(AST::TrueLiteral *) { stop(str: "TrueLiteral" ); } |
449 | |
450 | bool AstDumper::visit(AST::FalseLiteral *el) { |
451 | start(str: QLatin1String("FalseLiteral falseToken=%1" ) |
452 | .arg(args: loc(s: el->falseToken))); |
453 | return true; |
454 | } |
455 | void AstDumper::endVisit(AST::FalseLiteral *) { stop(str: "FalseLiteral" ); } |
456 | |
457 | bool AstDumper::visit(AST::SuperLiteral *el) { |
458 | start(str: QLatin1String("SuperLiteral superToken=%1" ) |
459 | .arg(args: loc(s: el->superToken))); |
460 | return true; |
461 | } |
462 | void AstDumper::endVisit(AST::SuperLiteral *) { stop(str: "SuperLiteral" ); } |
463 | |
464 | bool AstDumper::visit(AST::StringLiteral *el) { |
465 | start(str: QLatin1String("StringLiteral value=%1 literalToken=%2" ) |
466 | .arg(args: qs(s: el->value), args: loc(s: el->literalToken))); |
467 | return true; |
468 | } |
469 | void AstDumper::endVisit(AST::StringLiteral *) { stop(str: "StringLiteral" ); } |
470 | |
471 | bool AstDumper::visit(AST::TemplateLiteral *el) { |
472 | start(str: QLatin1String("TemplateLiteral value=%1 rawValue=%2 literalToken=%3" ) |
473 | .arg(args: qs(s: el->value), args: qs(s: el->rawValue), args: loc(s: el->literalToken))); |
474 | Node::accept(node: el->expression, visitor: this); |
475 | return true; |
476 | } |
477 | void AstDumper::endVisit(AST::TemplateLiteral *) { stop(str: "TemplateLiteral" ); } |
478 | |
479 | bool AstDumper::visit(AST::NumericLiteral *el) { |
480 | start(str: QLatin1String("NumericLiteral value=%1 literalToken=%2" ) |
481 | .arg(args: qs(s: QString::number(el->value)), args: loc(s: el->literalToken))); |
482 | return true; |
483 | } |
484 | void AstDumper::endVisit(AST::NumericLiteral *) { stop(str: "NumericLiteral" ); } |
485 | |
486 | bool AstDumper::visit(AST::RegExpLiteral *el) { |
487 | start(str: QLatin1String("RegExpLiteral pattern=%1 flags=%2 literalToken=%3" ) |
488 | .arg(args: qs(s: el->pattern), args: qs(s: QString::number(el->flags, base: 16)), args: loc(s: el->literalToken))); |
489 | return true; |
490 | } |
491 | void AstDumper::endVisit(AST::RegExpLiteral *) { stop(str: "RegExpLiteral" ); } |
492 | |
493 | bool AstDumper::visit(AST::ArrayPattern *el) { |
494 | start(str: QLatin1String("ArrayPattern lbracketToken=%1, commaToken=%2, rbracketToken=%3 parseMode=%4" ) |
495 | .arg(args: loc(s: el->lbracketToken),args: loc(s: el->commaToken),args: loc(s: el->rbracketToken), args: qs(s: QString::number(el->parseMode, base: 16)))); |
496 | return true; |
497 | } |
498 | void AstDumper::endVisit(AST::ArrayPattern *) { stop(str: "ArrayPattern" ); } |
499 | |
500 | bool AstDumper::visit(AST::ObjectPattern *el) { |
501 | start(str: QLatin1String("ObjectPattern lbraceToken=%1 rbraceToken=%2 parseMode=%3" ) |
502 | .arg(args: loc(s: el->lbraceToken), args: loc(s: el->rbraceToken), args: qs(s: QString::number(el->parseMode, base: 16)))); |
503 | return true; |
504 | } |
505 | void AstDumper::endVisit(AST::ObjectPattern *) { stop(str: "ObjectPattern" ); } |
506 | |
507 | bool AstDumper::visit(AST::PatternElementList *) { start(str: "PatternElementList" ); return true; } |
508 | void AstDumper::endVisit(AST::PatternElementList *) { stop(str: "PatternElementList" ); } |
509 | |
510 | bool AstDumper::visit(AST::PatternPropertyList *) { start(str: "PatternPropertyList" ); return true; } |
511 | void AstDumper::endVisit(AST::PatternPropertyList *) { stop(str: "PatternPropertyList" ); } |
512 | |
513 | bool AstDumper::visit(AST::PatternElement *el) { |
514 | start(str: QLatin1String("PatternElement identifierToken=%1 bindingIdentifier=%2 type=%3 scope=%4 isForDeclaration=%5" ) |
515 | .arg(args: loc(s: el->identifierToken), args: qs(s: el->bindingIdentifier), args: qs(s: QString::number(el->type, base: 16)), |
516 | args: qs(s: QString::number(static_cast<int>(el->scope), base: 16)), args: boolStr(v: el->isForDeclaration))); |
517 | return true; |
518 | } |
519 | void AstDumper::endVisit(AST::PatternElement *) { stop(str: "PatternElement" ); } |
520 | |
521 | bool AstDumper::visit(AST::PatternProperty *el) { |
522 | start(str: QLatin1String("PatternProperty identifierToken=%1 bindingIdentifier=%2 type=%3 scope=%4 isForDeclaration=%5 colonToken=%6" ) |
523 | .arg(args: loc(s: el->identifierToken), args: qs(s: el->bindingIdentifier), args: qs(s: QString::number(el->type, base: 16)), |
524 | args: qs(s: QString::number(static_cast<int>(el->scope), base: 16)), args: boolStr(v: el->isForDeclaration), args: loc(s: el->colonToken))); |
525 | return true; |
526 | } |
527 | void AstDumper::endVisit(AST::PatternProperty *) { stop(str: "PatternProperty" ); } |
528 | |
529 | bool AstDumper::visit(AST::Elision *el) { |
530 | start(str: QLatin1String("Elision commaToken=%1" ) |
531 | .arg(args: loc(s: el->commaToken))); |
532 | return true; |
533 | } |
534 | void AstDumper::endVisit(AST::Elision *el) { |
535 | stop(str: "Elision" ); |
536 | Node::accept(node: el->next, visitor: this); // emit other elisions at the same level |
537 | } |
538 | |
539 | bool AstDumper::visit(AST::NestedExpression *el) { |
540 | start(str: QLatin1String("NestedExpression lparenToken=%1 rparenToken=%2" ) |
541 | .arg(args: loc(s: el->lparenToken), args: loc(s: el->rparenToken))); |
542 | return true; |
543 | } |
544 | void AstDumper::endVisit(AST::NestedExpression *) { stop(str: "NestedExpression" ); } |
545 | |
546 | bool AstDumper::visit(AST::IdentifierPropertyName *el) { |
547 | start(str: QLatin1String("IdentifierPropertyName id=%1 propertyNameToken=%2" ) |
548 | .arg(args: qs(s: el->id), args: loc(s: el->propertyNameToken))); |
549 | return true; |
550 | } |
551 | void AstDumper::endVisit(AST::IdentifierPropertyName *) { stop(str: "IdentifierPropertyName" ); } |
552 | |
553 | bool AstDumper::visit(AST::StringLiteralPropertyName *el) { |
554 | start(str: QLatin1String("StringLiteralPropertyName id=%1 propertyNameToken=%2" ) |
555 | .arg(args: qs(s: el->id), args: loc(s: el->propertyNameToken))); |
556 | return true; |
557 | } |
558 | void AstDumper::endVisit(AST::StringLiteralPropertyName *) { stop(str: "StringLiteralPropertyName" ); } |
559 | |
560 | bool AstDumper::visit(AST::NumericLiteralPropertyName *el) { |
561 | start(str: QLatin1String("NumericLiteralPropertyName id=%1 propertyNameToken=%2" ) |
562 | .arg(args: qs(s: QString::number(el->id)),args: loc(s: el->propertyNameToken))); |
563 | return true; |
564 | } |
565 | void AstDumper::endVisit(AST::NumericLiteralPropertyName *) { stop(str: "NumericLiteralPropertyName" ); } |
566 | |
567 | bool AstDumper::visit(AST::ComputedPropertyName *) { |
568 | start(str: QLatin1String("ComputedPropertyName" )); |
569 | return true; |
570 | } |
571 | void AstDumper::endVisit(AST::ComputedPropertyName *) { stop(str: "ComputedPropertyName" ); } |
572 | |
573 | bool AstDumper::visit(AST::ArrayMemberExpression *el) { |
574 | start(str: QLatin1String("ArrayMemberExpression lbraketToken=%1 rbraketToken=%2" ) |
575 | .arg(args: loc(s: el->lbracketToken), args: loc(s: el->rbracketToken))); |
576 | return true; |
577 | } |
578 | void AstDumper::endVisit(AST::ArrayMemberExpression *) { stop(str: "ArrayMemberExpression" ); } |
579 | |
580 | bool AstDumper::visit(AST::FieldMemberExpression *el) { |
581 | start(str: QLatin1String("FieldMemberExpression name=%1 dotToken=%2 identifierToken=%3" ) |
582 | .arg(args: qs(s: el->name), args: loc(s: el->dotToken), args: loc(s: el->identifierToken))); |
583 | return true; |
584 | } |
585 | void AstDumper::endVisit(AST::FieldMemberExpression *) { stop(str: "FieldMemberExpression" ); } |
586 | |
587 | bool AstDumper::visit(AST::TaggedTemplate *) { |
588 | start(str: QLatin1String("TaggedTemplate" )); |
589 | return true; |
590 | } |
591 | void AstDumper::endVisit(AST::TaggedTemplate *) { stop(str: "TaggedTemplate" ); } |
592 | |
593 | bool AstDumper::visit(AST::NewMemberExpression *el) { |
594 | start(str: QLatin1String("NewMemberExpression newToken=%1 lparenToken=%2 rparenToken=%3" ) |
595 | .arg(args: loc(s: el->newToken), args: loc(s: el->lparenToken), args: loc(s: el->rparenToken))); |
596 | return true; |
597 | } |
598 | void AstDumper::endVisit(AST::NewMemberExpression *) { stop(str: "NewMemberExpression" ); } |
599 | |
600 | bool AstDumper::visit(AST::NewExpression *el) { |
601 | start(str: QLatin1String("NewExpression newToken=%1" ) |
602 | .arg(args: loc(s: el->newToken))); |
603 | return true; |
604 | } |
605 | void AstDumper::endVisit(AST::NewExpression *) { stop(str: "NewExpression" ); } |
606 | |
607 | bool AstDumper::visit(AST::CallExpression *el) { |
608 | start(str: QLatin1String("CallExpression lparenToken=%1 rparenToken=%2" ) |
609 | .arg(args: loc(s: el->lparenToken), args: loc(s: el->rparenToken))); |
610 | return true; |
611 | } |
612 | void AstDumper::endVisit(AST::CallExpression *) { stop(str: "CallExpression" ); } |
613 | |
614 | bool AstDumper::visit(AST::ArgumentList *el) { |
615 | start(str: QLatin1String("ArgumentList commaToken=%1 isSpreadElement=%2" ) |
616 | .arg(args: loc(s: el->commaToken), args: boolStr(v: el->isSpreadElement))); |
617 | return true; |
618 | } |
619 | void AstDumper::endVisit(AST::ArgumentList *) { stop(str: "ArgumentList" ); } |
620 | |
621 | bool AstDumper::visit(AST::PostIncrementExpression *el) { |
622 | start(str: QLatin1String("PostIncrementExpression incrementToken=%1" ) |
623 | .arg(args: loc(s: el->incrementToken))); |
624 | return true; |
625 | } |
626 | void AstDumper::endVisit(AST::PostIncrementExpression *) { stop(str: "PostIncrementExpression" ); } |
627 | |
628 | bool AstDumper::visit(AST::PostDecrementExpression *el) { |
629 | start(str: QLatin1String("PostDecrementExpression decrementToken=%1" ) |
630 | .arg(args: loc(s: el->decrementToken))); |
631 | return true; |
632 | } |
633 | void AstDumper::endVisit(AST::PostDecrementExpression *) { stop(str: "PostDecrementExpression" ); } |
634 | |
635 | bool AstDumper::visit(AST::DeleteExpression *el) { |
636 | start(str: QLatin1String("DeleteExpression deleteToken=%1" ) |
637 | .arg(args: loc(s: el->deleteToken))); |
638 | return true; |
639 | } |
640 | void AstDumper::endVisit(AST::DeleteExpression *) { stop(str: "DeleteExpression" ); } |
641 | |
642 | bool AstDumper::visit(AST::VoidExpression *el) { |
643 | start(str: QLatin1String("VoidExpression voidToken=%1" ) |
644 | .arg(args: loc(s: el->voidToken))); |
645 | return true; |
646 | } |
647 | void AstDumper::endVisit(AST::VoidExpression *) { stop(str: "VoidExpression" ); } |
648 | |
649 | bool AstDumper::visit(AST::TypeOfExpression *el) { |
650 | start(str: QLatin1String("TypeOfExpression typeofToken=%1" ) |
651 | .arg(args: loc(s: el->typeofToken))); |
652 | return true; |
653 | } |
654 | void AstDumper::endVisit(AST::TypeOfExpression *) { stop(str: "TypeOfExpression" ); } |
655 | |
656 | bool AstDumper::visit(AST::PreIncrementExpression *el) { |
657 | start(str: QLatin1String("PreIncrementExpression incrementToken=%1" ) |
658 | .arg(args: loc(s: el->incrementToken))); |
659 | return true; |
660 | } |
661 | void AstDumper::endVisit(AST::PreIncrementExpression *) { stop(str: "PreIncrementExpression" ); } |
662 | |
663 | bool AstDumper::visit(AST::PreDecrementExpression *el) { |
664 | start(str: QLatin1String("PreDecrementExpression decrementToken=%1" ) |
665 | .arg(args: loc(s: el->decrementToken))); |
666 | return true; |
667 | } |
668 | void AstDumper::endVisit(AST::PreDecrementExpression *) { stop(str: "PreDecrementExpression" ); } |
669 | |
670 | bool AstDumper::visit(AST::UnaryPlusExpression *el) { |
671 | start(str: QLatin1String("UnaryPlusExpression plusToken=%1" ) |
672 | .arg(args: loc(s: el->plusToken))); |
673 | return true; |
674 | } |
675 | void AstDumper::endVisit(AST::UnaryPlusExpression *) { stop(str: "UnaryPlusExpression" ); } |
676 | |
677 | bool AstDumper::visit(AST::UnaryMinusExpression *el) { |
678 | start(str: QLatin1String("UnaryMinusExpression minusToken=%1" ) |
679 | .arg(args: loc(s: el->minusToken))); |
680 | return true; |
681 | } |
682 | void AstDumper::endVisit(AST::UnaryMinusExpression *) { stop(str: "UnaryMinusExpression" ); } |
683 | |
684 | bool AstDumper::visit(AST::TildeExpression *el) { |
685 | start(str: QLatin1String("TildeExpression tildeToken=%1" ) |
686 | .arg(args: loc(s: el->tildeToken))); |
687 | return true; |
688 | } |
689 | void AstDumper::endVisit(AST::TildeExpression *) { stop(str: "TildeExpression" ); } |
690 | |
691 | bool AstDumper::visit(AST::NotExpression *el) { |
692 | start(str: QLatin1String("NotExpression notToken=%1" ) |
693 | .arg(args: loc(s: el->notToken))); |
694 | return true; |
695 | } |
696 | void AstDumper::endVisit(AST::NotExpression *) { stop(str: "NotExpression" ); } |
697 | |
698 | bool AstDumper::visit(AST::BinaryExpression *el) { |
699 | start(str: QLatin1String("BinaryExpression op=%1 operatorToken=%2" ) |
700 | .arg(args: qs(s: QString::number(el->op,base: 16)), args: loc(s: el->operatorToken))); |
701 | return true; |
702 | } |
703 | void AstDumper::endVisit(AST::BinaryExpression *) { stop(str: "BinaryExpression" ); } |
704 | |
705 | bool AstDumper::visit(AST::ConditionalExpression *el) { |
706 | start(str: QLatin1String("ConditionalExpression questionToken=%1 colonToken=%2" ) |
707 | .arg(args: loc(s: el->questionToken), args: loc(s: el->colonToken))); |
708 | return true; |
709 | } |
710 | void AstDumper::endVisit(AST::ConditionalExpression *) { stop(str: "ConditionalExpression" ); } |
711 | |
712 | bool AstDumper::visit(AST::Expression *el) { |
713 | start(str: QLatin1String("Expression commaToken=%1" ) |
714 | .arg(args: loc(s: el->commaToken))); |
715 | return true; |
716 | } |
717 | void AstDumper::endVisit(AST::Expression *) { stop(str: "Expression" ); } |
718 | |
719 | bool AstDumper::visit(AST::Block *el) { |
720 | start(str: QLatin1String("Block lbraceToken=%1 rbraceToken=%2" ) |
721 | .arg(args: loc(s: el->lbraceToken), args: loc(s: el->rbraceToken))); |
722 | return true; |
723 | } |
724 | void AstDumper::endVisit(AST::Block *) { stop(str: "Block" ); } |
725 | |
726 | bool AstDumper::visit(AST::StatementList *) { |
727 | start(str: QLatin1String("StatementList" )); |
728 | return true; |
729 | } |
730 | void AstDumper::endVisit(AST::StatementList *) { stop(str: "StatementList" ); } |
731 | |
732 | bool AstDumper::visit(AST::VariableStatement *el) { |
733 | start(str: QLatin1String("VariableStatement declarationKindToken=%1" ) |
734 | .arg(args: loc(s: el->declarationKindToken))); |
735 | return true; |
736 | } |
737 | void AstDumper::endVisit(AST::VariableStatement *) { stop(str: "VariableStatement" ); } |
738 | |
739 | bool AstDumper::visit(AST::VariableDeclarationList *el) { |
740 | start(str: QLatin1String("VariableDeclarationList commaToken=%1" ) |
741 | .arg(args: loc(s: el->commaToken))); |
742 | return true; |
743 | } |
744 | void AstDumper::endVisit(AST::VariableDeclarationList *) { stop(str: "VariableDeclarationList" ); } |
745 | |
746 | bool AstDumper::visit(AST::EmptyStatement *el) { |
747 | start(str: QLatin1String("EmptyStatement semicolonToken=%1" ) |
748 | .arg(args: loc(s: el->semicolonToken))); |
749 | return true; |
750 | } |
751 | void AstDumper::endVisit(AST::EmptyStatement *) { stop(str: "EmptyStatement" ); } |
752 | |
753 | bool AstDumper::visit(AST::ExpressionStatement *el) { |
754 | start(str: QLatin1String("ExpressionStatement semicolonToken=%1" ) |
755 | .arg(args: loc(s: el->semicolonToken))); |
756 | return true; |
757 | } |
758 | void AstDumper::endVisit(AST::ExpressionStatement *) { stop(str: "ExpressionStatement" ); } |
759 | |
760 | bool AstDumper::visit(AST::IfStatement *el) { |
761 | start(str: QLatin1String("IfStatement ifToken=%1 lparenToken=%2 rparenToken=%3 elseToken=%4" ) |
762 | .arg(args: loc(s: el->ifToken), args: loc(s: el->lparenToken), args: loc(s: el->rparenToken), args: loc(s: el->elseToken))); |
763 | return true; |
764 | } |
765 | void AstDumper::endVisit(AST::IfStatement *) { stop(str: "IfStatement" ); } |
766 | |
767 | bool AstDumper::visit(AST::DoWhileStatement *el) { |
768 | start(str: QLatin1String("DoWhileStatement doToken=%1 whileToken=%2 lparenToken=%3 rparenToken=%4 semicolonToken=%5" ) |
769 | .arg(args: loc(s: el->doToken), args: loc(s: el->whileToken), args: loc(s: el->lparenToken), args: loc(s: el->rparenToken), args: loc(s: el->semicolonToken))); |
770 | return true; |
771 | } |
772 | void AstDumper::endVisit(AST::DoWhileStatement *) { stop(str: "DoWhileStatement" ); } |
773 | |
774 | bool AstDumper::visit(AST::WhileStatement *el) { |
775 | start(str: QLatin1String("WhileStatement whileToken=%1 lparenToken=%2 rparenToken=%3" ) |
776 | .arg(args: loc(s: el->whileToken), args: loc(s: el->lparenToken), args: loc(s: el->rparenToken))); |
777 | return true; |
778 | } |
779 | void AstDumper::endVisit(AST::WhileStatement *) { stop(str: "WhileStatement" ); } |
780 | |
781 | bool AstDumper::visit(AST::ForStatement *el) { |
782 | start(str: QLatin1String("ForStatement forToken=%1 lparenToken=%2 firstSemicolonToken=%3 secondSemicolonToken=%4 rparenToken=%5" ) |
783 | .arg(args: loc(s: el->forToken), args: loc(s: el->lparenToken), args: loc(s: el->firstSemicolonToken), args: loc(s: el->secondSemicolonToken), args: loc(s: el->rparenToken))); |
784 | return true; |
785 | } |
786 | void AstDumper::endVisit(AST::ForStatement *) { stop(str: "ForStatement" ); } |
787 | |
788 | bool AstDumper::visit(AST::ForEachStatement *el) { |
789 | start(str: QLatin1String("ForEachStatement forToken=%1 lparenToken=%2 inOfToken=%3 rparenToken=%4 type=%5" ) |
790 | .arg(args: loc(s: el->forToken), args: loc(s: el->lparenToken), args: loc(s: el->inOfToken), args: loc(s: el->rparenToken), args: qs(s: QString::number(static_cast<int>(el->type), base: 16)))); |
791 | return true; |
792 | } |
793 | void AstDumper::endVisit(AST::ForEachStatement *) { stop(str: "ForEachStatement" ); } |
794 | |
795 | bool AstDumper::visit(AST::ContinueStatement *el) { |
796 | start(str: QLatin1String("ContinueStatement label=%1 continueToken=%2 identifierToken=%3 semicolonToken=%4" ) |
797 | .arg(args: qs(s: el->label), args: loc(s: el->continueToken), args: loc(s: el->identifierToken), args: loc(s: el->semicolonToken))); |
798 | return true; |
799 | } |
800 | void AstDumper::endVisit(AST::ContinueStatement *) { stop(str: "ContinueStatement" ); } |
801 | |
802 | bool AstDumper::visit(AST::BreakStatement *el) { |
803 | start(str: QLatin1String("BreakStatement label=%1 breakToken=%2 identifierToken=%3 semicolonToken=%4" ) |
804 | .arg(args: qs(s: el->label), args: loc(s: el->breakToken), args: loc(s: el->identifierToken), args: loc(s: el->semicolonToken))); |
805 | return true; |
806 | } |
807 | void AstDumper::endVisit(AST::BreakStatement *) { stop(str: "BreakStatement" ); } |
808 | |
809 | bool AstDumper::visit(AST::ReturnStatement *el) { |
810 | start(str: QLatin1String("ReturnStatement returnToken=%1 semicolonToken=%2" ) |
811 | .arg(args: loc(s: el->returnToken), args: loc(s: el->semicolonToken))); |
812 | return true; |
813 | } |
814 | void AstDumper::endVisit(AST::ReturnStatement *) { stop(str: "ReturnStatement" ); } |
815 | |
816 | bool AstDumper::visit(AST::YieldExpression *el) { |
817 | start(str: QLatin1String("YieldExpression isYieldStar=%1 yieldToken=%2" ) |
818 | .arg(args: boolStr(v: el->isYieldStar), args: loc(s: el->yieldToken))); |
819 | return true; |
820 | } |
821 | void AstDumper::endVisit(AST::YieldExpression *) { stop(str: "YieldExpression" ); } |
822 | |
823 | bool AstDumper::visit(AST::WithStatement *el) { |
824 | start(str: QLatin1String("WithStatement withToken=%1 lparenToken=%2 rparenToken=%3" ) |
825 | .arg(args: loc(s: el->withToken), args: loc(s: el->lparenToken), args: loc(s: el->rparenToken))); |
826 | return true; |
827 | } |
828 | void AstDumper::endVisit(AST::WithStatement *) { stop(str: "WithStatement" ); } |
829 | |
830 | bool AstDumper::visit(AST::SwitchStatement *el) { |
831 | start(str: QLatin1String("SwitchStatement switchToken=%1 lparenToken=%2 rparenToken=%3" ) |
832 | .arg(args: loc(s: el->switchToken), args: loc(s: el->lparenToken), args: loc(s: el->rparenToken))); |
833 | return true; |
834 | } |
835 | void AstDumper::endVisit(AST::SwitchStatement *) { stop(str: "SwitchStatement" ); } |
836 | |
837 | bool AstDumper::visit(AST::CaseBlock *el) { |
838 | start(str: QLatin1String("CaseBlock lbraceToken=%1 rbraceToken=%2" ) |
839 | .arg(args: loc(s: el->lbraceToken), args: loc(s: el->rbraceToken))); |
840 | return true; |
841 | } |
842 | void AstDumper::endVisit(AST::CaseBlock *) { stop(str: "CaseBlock" ); } |
843 | |
844 | bool AstDumper::visit(AST::CaseClauses *) { |
845 | start(str: QLatin1String("CaseClauses" )); |
846 | return true; |
847 | } |
848 | void AstDumper::endVisit(AST::CaseClauses *) { stop(str: "CaseClauses" ); } |
849 | |
850 | bool AstDumper::visit(AST::CaseClause *el) { |
851 | start(str: QLatin1String("CaseClause caseToken=%1 colonToken=%2" ) |
852 | .arg(args: loc(s: el->caseToken), args: loc(s: el->colonToken))); |
853 | return true; |
854 | } |
855 | void AstDumper::endVisit(AST::CaseClause *) { stop(str: "CaseClause" ); } |
856 | |
857 | bool AstDumper::visit(AST::DefaultClause *el) { |
858 | start(str: QLatin1String("DefaultClause defaultToken=%1 colonToken=%2" ) |
859 | .arg(args: loc(s: el->defaultToken), args: loc(s: el->colonToken))); |
860 | return true; |
861 | } |
862 | void AstDumper::endVisit(AST::DefaultClause *) { stop(str: "DefaultClause" ); } |
863 | |
864 | bool AstDumper::visit(AST::LabelledStatement *el) { |
865 | start(str: QLatin1String("LabelledStatement label=%1 identifierToken=%2 colonToken=%3" ) |
866 | .arg(args: qs(s: el->label), args: loc(s: el->identifierToken), args: loc(s: el->colonToken))); |
867 | return true; |
868 | } |
869 | void AstDumper::endVisit(AST::LabelledStatement *) { stop(str: "LabelledStatement" ); } |
870 | |
871 | bool AstDumper::visit(AST::ThrowStatement *el) { |
872 | start(str: QLatin1String("ThrowStatement throwToken=%1 semicolonToken=%2" ) |
873 | .arg(args: loc(s: el->throwToken), args: loc(s: el->semicolonToken))); |
874 | return true; |
875 | } |
876 | void AstDumper::endVisit(AST::ThrowStatement *) { stop(str: "ThrowStatement" ); } |
877 | |
878 | bool AstDumper::visit(AST::TryStatement *el) { |
879 | start(str: QLatin1String("TryStatement tryToken=%1" ) |
880 | .arg(args: loc(s: el->tryToken))); |
881 | return true; |
882 | } |
883 | void AstDumper::endVisit(AST::TryStatement *) { stop(str: "TryStatement" ); } |
884 | |
885 | bool AstDumper::visit(AST::Catch *el) { |
886 | start(str: QLatin1String("Catch catchToken=%1 lparenToken=%2 identifierToken=%3 rparenToken=%4" ) |
887 | .arg(args: loc(s: el->catchToken), args: loc(s: el->lparenToken), args: loc(s: el->identifierToken), args: loc(s: el->rparenToken))); |
888 | return true; |
889 | } |
890 | void AstDumper::endVisit(AST::Catch *) { stop(str: "Catch" ); } |
891 | |
892 | bool AstDumper::visit(AST::Finally *el) { |
893 | start(str: QLatin1String("Finally finallyToken=%1" ) |
894 | .arg(args: loc(s: el->finallyToken))); |
895 | return true; |
896 | } |
897 | void AstDumper::endVisit(AST::Finally *) { stop(str: "Finally" ); } |
898 | |
899 | bool AstDumper::visit(AST::FunctionDeclaration *el) { |
900 | start(str: QLatin1String("FunctionDeclaration name=%1 isArrowFunction=%2 isGenerator=%3 functionToken=%4 " |
901 | "identifierToken=%5 lparenToken=%6 rparenToken=%7 lbraceToken=%8 rbraceToken=%9" ) |
902 | .arg(args: qs(s: el->name), args: boolStr(v: el->isArrowFunction), args: boolStr(v: el->isGenerator), args: loc(s: el->functionToken), |
903 | args: loc(s: el->identifierToken), args: loc(s: el->lparenToken), args: loc(s: el->rparenToken), args: loc(s: el->lbraceToken), |
904 | args: loc(s: el->rbraceToken))); |
905 | return true; |
906 | } |
907 | void AstDumper::endVisit(AST::FunctionDeclaration *) { stop(str: "FunctionDeclaration" ); } |
908 | |
909 | bool AstDumper::visit(AST::FunctionExpression *el) { |
910 | start(str: QLatin1String("FunctionExpression name=%1 isArrowFunction=%2 isGenerator=%3 functionToken=%4 " |
911 | "identifierToken=%5 lparenToken=%6 rparenToken=%7 lbraceToken=%8 rbraceToken=%9" ) |
912 | .arg(args: qs(s: el->name), args: boolStr(v: el->isArrowFunction), args: boolStr(v: el->isGenerator), args: loc(s: el->functionToken), |
913 | args: loc(s: el->identifierToken), args: loc(s: el->lparenToken), args: loc(s: el->rparenToken), args: loc(s: el->lbraceToken), |
914 | args: loc(s: el->rbraceToken))); |
915 | return true; |
916 | } |
917 | void AstDumper::endVisit(AST::FunctionExpression *) { stop(str: "FunctionExpression" ); } |
918 | |
919 | bool AstDumper::visit(AST::FormalParameterList *) { |
920 | start(str: QLatin1String("FormalParameterList" )); |
921 | return true; |
922 | } |
923 | void AstDumper::endVisit(AST::FormalParameterList *) { stop(str: "FormalParameterList" ); } |
924 | |
925 | bool AstDumper::visit(AST::ClassExpression *el) { |
926 | start(str: QLatin1String("ClassExpression name=%1 classToken=%2 identifierToken=%3 lbraceToken=%4 rbraceToken=%5" ) |
927 | .arg(args: qs(s: el->name), args: loc(s: el->classToken), args: loc(s: el->identifierToken), args: loc(s: el->lbraceToken), args: loc(s: el->rbraceToken))); |
928 | return true; |
929 | } |
930 | void AstDumper::endVisit(AST::ClassExpression *) { stop(str: "ClassExpression" ); } |
931 | |
932 | bool AstDumper::visit(AST::ClassDeclaration *el) { |
933 | start(str: QLatin1String("ClassDeclaration name=%1 classToken=%2 identifierToken=%3 lbraceToken=%4 rbraceToken=%5" ) |
934 | .arg(args: qs(s: el->name), args: loc(s: el->classToken), args: loc(s: el->identifierToken), args: loc(s: el->lbraceToken), args: loc(s: el->rbraceToken))); |
935 | return true; |
936 | } |
937 | void AstDumper::endVisit(AST::ClassDeclaration *) { stop(str: "ClassDeclaration" ); } |
938 | |
939 | bool AstDumper::visit(AST::ClassElementList *el) { |
940 | start(str: QLatin1String("ClassElementList isStatic=%1" ) |
941 | .arg(args: boolStr(v: el->isStatic))); |
942 | return true; |
943 | } |
944 | void AstDumper::endVisit(AST::ClassElementList *) { stop(str: "ClassElementList" ); } |
945 | |
946 | bool AstDumper::visit(AST::Program *) { |
947 | start(str: QLatin1String("Program" )); |
948 | return true; |
949 | } |
950 | void AstDumper::endVisit(AST::Program *) { stop(str: "Program" ); } |
951 | |
952 | bool AstDumper::visit(AST::NameSpaceImport *el) { |
953 | start(str: QLatin1String("NameSpaceImport starToken=%1 importedBindingToken=%2 importedBinding=%3" ) |
954 | .arg(args: loc(s: el->starToken), args: loc(s: el->importedBindingToken), args: qs(s: el->importedBinding))); |
955 | return true; |
956 | } |
957 | void AstDumper::endVisit(AST::NameSpaceImport *) { stop(str: "NameSpaceImport" ); } |
958 | |
959 | bool AstDumper::visit(AST::ImportSpecifier *el) { |
960 | start(str: QLatin1String("ImportSpecifier identifierToken=%1 importedBindingToken=%2 identifier=%3 importedBinding=%4" ) |
961 | .arg(args: loc(s: el->identifierToken), args: loc(s: el->importedBindingToken), args: qs(s: el->identifier), args: qs(s: el->importedBinding))); |
962 | return true; |
963 | } |
964 | void AstDumper::endVisit(AST::ImportSpecifier *) { stop(str: "ImportSpecifier" ); } |
965 | |
966 | bool AstDumper::visit(AST::ImportsList *el) { |
967 | start(str: QLatin1String("ImportsList importSpecifierToken=%1" ) |
968 | .arg(args: loc(s: el->importSpecifierToken))); |
969 | return true; |
970 | } |
971 | void AstDumper::endVisit(AST::ImportsList *) { stop(str: "ImportsList" ); } |
972 | |
973 | bool AstDumper::visit(AST::NamedImports *el) { |
974 | start(str: QLatin1String("NamedImports leftBraceToken=%1 rightBraceToken=%2" ) |
975 | .arg(args: loc(s: el->leftBraceToken), args: loc(s: el->rightBraceToken))); |
976 | return true; |
977 | } |
978 | void AstDumper::endVisit(AST::NamedImports *) { stop(str: "NamedImports" ); } |
979 | |
980 | bool AstDumper::visit(AST::FromClause *el) { |
981 | start(str: QLatin1String("FromClause fromToken=%1 moduleSpecifierToken=%2 moduleSpecifier=%3" ) |
982 | .arg(args: loc(s: el->fromToken), args: loc(s: el->moduleSpecifierToken), args: qs(s: el->moduleSpecifier))); |
983 | return true; |
984 | } |
985 | void AstDumper::endVisit(AST::FromClause *) { stop(str: "FromClause" ); } |
986 | |
987 | bool AstDumper::visit(AST::ImportClause *el) { |
988 | start(str: QLatin1String("ImportClause importedDefaultBindingToken=%1 importedDefaultBinding=%2" ) |
989 | .arg(args: loc(s: el->importedDefaultBindingToken), args: qs(s: el->importedDefaultBinding))); |
990 | return true; |
991 | } |
992 | void AstDumper::endVisit(AST::ImportClause *) { stop(str: "ImportClause" ); } |
993 | |
994 | bool AstDumper::visit(AST::ImportDeclaration *el) { |
995 | start(str: QLatin1String("ImportDeclaration importToken=%1 moduleSpecifierToken=%2 moduleSpecifier=%3" ) |
996 | .arg(args: loc(s: el->importToken), args: loc(s: el->moduleSpecifierToken), args: qs(s: el->moduleSpecifier))); |
997 | return true; |
998 | } |
999 | void AstDumper::endVisit(AST::ImportDeclaration *) { stop(str: "ImportDeclaration" ); } |
1000 | |
1001 | bool AstDumper::visit(AST::ExportSpecifier *el) { |
1002 | start(str: QLatin1String("ExportSpecifier identifierToken=%1 exportedIdentifierToken=%2 identifier=%3 exportedIdentifier=%4" ) |
1003 | .arg(args: loc(s: el->identifierToken), args: loc(s: el->exportedIdentifierToken), args: qs(s: el->identifier), args: qs(s: el->exportedIdentifier))); |
1004 | return true; |
1005 | } |
1006 | void AstDumper::endVisit(AST::ExportSpecifier *) { stop(str: "ExportSpecifier" ); } |
1007 | |
1008 | bool AstDumper::visit(AST::ExportsList *) { |
1009 | start(str: QLatin1String("ExportsList" )); |
1010 | return true; |
1011 | } |
1012 | void AstDumper::endVisit(AST::ExportsList *) { stop(str: "ExportsList" ); } |
1013 | |
1014 | bool AstDumper::visit(AST::ExportClause *el) { |
1015 | start(str: QLatin1String("ExportClause leftBraceToken=%1 rightBraceToken=%2" ) |
1016 | .arg(args: loc(s: el->leftBraceToken), args: loc(s: el->rightBraceToken))); |
1017 | return true; |
1018 | } |
1019 | void AstDumper::endVisit(AST::ExportClause *) { stop(str: "ExportClause" ); } |
1020 | |
1021 | bool AstDumper::visit(AST::ExportDeclaration *el) { |
1022 | start(str: QLatin1String("ExportDeclaration exportToken=%1 exportAll=%2 exportDefault=%3" ) |
1023 | .arg(args: loc(s: el->exportToken), args: boolStr(v: el->exportAll), args: boolStr(v: el->exportDefault))); |
1024 | return true; |
1025 | } |
1026 | void AstDumper::endVisit(AST::ExportDeclaration *) { stop(str: "ExportDeclaration" ); } |
1027 | |
1028 | bool AstDumper::visit(AST::ESModule *) { |
1029 | start(str: QLatin1String("ESModule" )); |
1030 | return true; |
1031 | } |
1032 | void AstDumper::endVisit(AST::ESModule *) { stop(str: "ESModule" ); } |
1033 | |
1034 | bool AstDumper::visit(AST::DebuggerStatement *el) { |
1035 | start(str: QLatin1String("DebuggerStatement debuggerToken=%1 semicolonToken=%2" ) |
1036 | .arg(args: loc(s: el->debuggerToken), args: loc(s: el->semicolonToken))); |
1037 | return true; |
1038 | } |
1039 | void AstDumper::endVisit(AST::DebuggerStatement *) { stop(str: "DebuggerStatement" ); } |
1040 | |
1041 | bool AstDumper::visit(AST::Type *) { |
1042 | start(str: QLatin1String("Type" )); |
1043 | return true; |
1044 | } |
1045 | void AstDumper::endVisit(AST::Type *) { stop(str: "Type" ); } |
1046 | |
1047 | bool AstDumper::visit(AST::TypeArgumentList *) { |
1048 | start(str: QLatin1String("TypeArgumentList" )); |
1049 | return true; |
1050 | } |
1051 | void AstDumper::endVisit(AST::TypeArgumentList *) { stop(str: "TypeArgumentList" ); } |
1052 | |
1053 | bool AstDumper::visit(AST::TypeAnnotation *el) { |
1054 | start(str: QLatin1String("TypeAnnotation colonToken=%1" ) |
1055 | .arg(args: loc(s: el->colonToken))); |
1056 | return true; |
1057 | } |
1058 | void AstDumper::endVisit(AST::TypeAnnotation *) { stop(str: "TypeAnnotation" ); } |
1059 | |
1060 | void AstDumper::throwRecursionDepthError() |
1061 | { |
1062 | qDebug() << "Maximum statement or expression depth exceeded in AstDumper" ; |
1063 | } |
1064 | |
1065 | bool AstDumper::dumpNode() { |
1066 | return options & DumperOptions::DumpNode; |
1067 | } |
1068 | |
1069 | bool AstDumper::noLocations() { |
1070 | return options & DumperOptions::NoLocations; |
1071 | } |
1072 | |
1073 | bool AstDumper::noAnnotations() { |
1074 | return options & DumperOptions::NoAnnotations; |
1075 | } |
1076 | |
1077 | } // end namespace QQmlJS |
1078 | |
1079 | QT_END_NAMESPACE |
1080 | |