Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: pkg/dev_compiler/lib/src/js_ast/nodes.dart

Issue 2822633003: fix #29346, ensure all nodes are implemented by DDC's code generator (Closed)
Patch Set: fix Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of js_ast; 5 part of js_ast;
6 6
7 abstract class NodeVisitor<T> implements TypeRefVisitor<T> { 7 abstract class NodeVisitor<T> implements TypeRefVisitor<T> {
8 T visitProgram(Program node); 8 T visitProgram(Program node);
9 9
10 T visitBlock(Block node); 10 T visitBlock(Block node);
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 } 1436 }
1437 1437
1438 // TODO(jmesserly): parser does not support this yet. 1438 // TODO(jmesserly): parser does not support this yet.
1439 class TemplateString extends Expression { 1439 class TemplateString extends Expression {
1440 /** 1440 /**
1441 * The parts of this template string: a sequence of [String]s and 1441 * The parts of this template string: a sequence of [String]s and
1442 * [Expression]s. Strings and expressions will alternate, for example: 1442 * [Expression]s. Strings and expressions will alternate, for example:
1443 * 1443 *
1444 * `foo${1 + 2} bar ${'hi'}` 1444 * `foo${1 + 2} bar ${'hi'}`
1445 * 1445 *
1446 * would be represented by: 1446 * would be represented by [strings]:
1447 * 1447 *
1448 * ['foo', new JS.Binary('+', js.number(1), js.number(2)), 1448 * ['foo', ' bar ', '']
1449 * ' bar ', new JS.LiteralString("'hi'")] 1449 *
1450 * and [interpolations]:
1451 *
1452 * [new JS.Binary('+', js.number(1), js.number(2)),
1453 * new JS.LiteralString("'hi'")]
1454 *
1455 * There should be exactly one more string than interpolation expression.
1450 */ 1456 */
1451 final List elements; 1457 final List<String> strings;
1452 TemplateString(this.elements); 1458 final List<Expression> interpolations;
1459
1460 TemplateString(this.strings, this.interpolations) {
1461 assert(strings.length == interpolations.length + 1);
1462 }
1453 1463
1454 accept(NodeVisitor visitor) => visitor.visitTemplateString(this); 1464 accept(NodeVisitor visitor) => visitor.visitTemplateString(this);
1455 1465
1456 void visitChildren(NodeVisitor visitor) { 1466 void visitChildren(NodeVisitor visitor) {
1457 for (var element in elements) { 1467 for (var element in interpolations) {
1458 if (element is Expression) element.accept(visitor); 1468 element.accept(visitor);
1459 } 1469 }
1460 } 1470 }
1461 1471
1462 TemplateString _clone() => new TemplateString(elements); 1472 TemplateString _clone() => new TemplateString(strings, interpolations);
1463 1473
1464 int get precedenceLevel => PRIMARY; 1474 int get precedenceLevel => PRIMARY;
1465 } 1475 }
1466 1476
1467 // TODO(jmesserly): parser does not support this yet. 1477 // TODO(jmesserly): parser does not support this yet.
1468 class TaggedTemplate extends Expression { 1478 class TaggedTemplate extends Expression {
1469 final Expression tag; 1479 final Expression tag;
1470 final TemplateString template; 1480 final TemplateString template;
1471 1481
1472 TaggedTemplate(this.tag, this.template); 1482 TaggedTemplate(this.tag, this.template);
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 final List<ModuleItem> body; 1913 final List<ModuleItem> body;
1904 Module(this.body, {this.name}); 1914 Module(this.body, {this.name});
1905 1915
1906 accept(NodeVisitor visitor) => visitor.visitModule(this); 1916 accept(NodeVisitor visitor) => visitor.visitModule(this);
1907 void visitChildren(NodeVisitor visitor) { 1917 void visitChildren(NodeVisitor visitor) {
1908 for (ModuleItem item in body) item.accept(visitor); 1918 for (ModuleItem item in body) item.accept(visitor);
1909 } 1919 }
1910 1920
1911 Module _clone() => new Module(body); 1921 Module _clone() => new Module(body);
1912 } 1922 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698