OLD | NEW |
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> { | 7 abstract class NodeVisitor<T> { |
8 T visitProgram(Program node); | 8 T visitProgram(Program node); |
9 | 9 |
10 T visitBlock(Block node); | 10 T visitBlock(Block node); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 T visitDeferredNumber(DeferredNumber node); | 53 T visitDeferredNumber(DeferredNumber node); |
54 T visitDeferredString(DeferredString node); | 54 T visitDeferredString(DeferredString node); |
55 | 55 |
56 T visitLiteralBool(LiteralBool node); | 56 T visitLiteralBool(LiteralBool node); |
57 T visitLiteralString(LiteralString node); | 57 T visitLiteralString(LiteralString node); |
58 T visitLiteralNumber(LiteralNumber node); | 58 T visitLiteralNumber(LiteralNumber node); |
59 T visitLiteralNull(LiteralNull node); | 59 T visitLiteralNull(LiteralNull node); |
60 | 60 |
61 T visitStringConcatenation(StringConcatenation node); | 61 T visitStringConcatenation(StringConcatenation node); |
62 | 62 |
| 63 T visitName(Name node); |
| 64 |
63 T visitArrayInitializer(ArrayInitializer node); | 65 T visitArrayInitializer(ArrayInitializer node); |
64 T visitArrayHole(ArrayHole node); | 66 T visitArrayHole(ArrayHole node); |
65 T visitObjectInitializer(ObjectInitializer node); | 67 T visitObjectInitializer(ObjectInitializer node); |
66 T visitProperty(Property node); | 68 T visitProperty(Property node); |
67 T visitRegExpLiteral(RegExpLiteral node); | 69 T visitRegExpLiteral(RegExpLiteral node); |
68 | 70 |
69 T visitAwait(Await node); | 71 T visitAwait(Await node); |
70 | 72 |
71 T visitComment(Comment node); | 73 T visitComment(Comment node); |
72 | 74 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 155 |
154 T visitLiteral(Literal node) => visitExpression(node); | 156 T visitLiteral(Literal node) => visitExpression(node); |
155 | 157 |
156 T visitLiteralBool(LiteralBool node) => visitLiteral(node); | 158 T visitLiteralBool(LiteralBool node) => visitLiteral(node); |
157 T visitLiteralString(LiteralString node) => visitLiteral(node); | 159 T visitLiteralString(LiteralString node) => visitLiteral(node); |
158 T visitLiteralNumber(LiteralNumber node) => visitLiteral(node); | 160 T visitLiteralNumber(LiteralNumber node) => visitLiteral(node); |
159 T visitLiteralNull(LiteralNull node) => visitLiteral(node); | 161 T visitLiteralNull(LiteralNull node) => visitLiteral(node); |
160 | 162 |
161 T visitStringConcatenation(StringConcatenation node) => visitLiteral(node); | 163 T visitStringConcatenation(StringConcatenation node) => visitLiteral(node); |
162 | 164 |
| 165 T visitName(Name node) => visitNode(node); |
| 166 |
163 T visitArrayInitializer(ArrayInitializer node) => visitExpression(node); | 167 T visitArrayInitializer(ArrayInitializer node) => visitExpression(node); |
164 T visitArrayHole(ArrayHole node) => visitExpression(node); | 168 T visitArrayHole(ArrayHole node) => visitExpression(node); |
165 T visitObjectInitializer(ObjectInitializer node) => visitExpression(node); | 169 T visitObjectInitializer(ObjectInitializer node) => visitExpression(node); |
166 T visitProperty(Property node) => visitNode(node); | 170 T visitProperty(Property node) => visitNode(node); |
167 T visitRegExpLiteral(RegExpLiteral node) => visitExpression(node); | 171 T visitRegExpLiteral(RegExpLiteral node) => visitExpression(node); |
168 | 172 |
169 T visitInterpolatedNode(InterpolatedNode node) => visitNode(node); | 173 T visitInterpolatedNode(InterpolatedNode node) => visitNode(node); |
170 | 174 |
171 T visitInterpolatedExpression(InterpolatedExpression node) | 175 T visitInterpolatedExpression(InterpolatedExpression node) |
172 => visitInterpolatedNode(node); | 176 => visitInterpolatedNode(node); |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 abstract class Expression extends Node { | 570 abstract class Expression extends Node { |
567 int get precedenceLevel; | 571 int get precedenceLevel; |
568 | 572 |
569 Statement toStatement() => new ExpressionStatement(this); | 573 Statement toStatement() => new ExpressionStatement(this); |
570 } | 574 } |
571 | 575 |
572 abstract class Declaration implements VariableReference { | 576 abstract class Declaration implements VariableReference { |
573 | 577 |
574 } | 578 } |
575 | 579 |
| 580 /// An implementation of [Name] represents a potentially late bound name in |
| 581 /// the generated ast. |
| 582 /// |
| 583 /// While [Name] implements comparable, there is no requirement on the actual |
| 584 /// implementation of [compareTo] other than that it needs to be stable. |
| 585 /// In particular, there is no guarantee that implementations of [compareTo] |
| 586 /// will implement some form of lexicographic ordering like [String.compareTo]. |
| 587 abstract class Name extends Literal |
| 588 implements Declaration, Parameter, Comparable { |
| 589 accept(NodeVisitor visitor) => visitor.visitName(this); |
| 590 |
| 591 bool get allowRename => false; |
| 592 } |
| 593 |
| 594 class LiteralStringFromName extends LiteralString { |
| 595 Name name; |
| 596 |
| 597 LiteralStringFromName(this.name) : super(null); |
| 598 |
| 599 String get value => '"${name.name}"'; |
| 600 } |
| 601 |
576 class LiteralExpression extends Expression { | 602 class LiteralExpression extends Expression { |
577 final String template; | 603 final String template; |
578 final List<Expression> inputs; | 604 final List<Expression> inputs; |
579 | 605 |
580 LiteralExpression(this.template) : inputs = const []; | 606 LiteralExpression(this.template) : inputs = const []; |
581 LiteralExpression.withData(this.template, this.inputs); | 607 LiteralExpression.withData(this.template, this.inputs); |
582 | 608 |
583 accept(NodeVisitor visitor) => visitor.visitLiteralExpression(this); | 609 accept(NodeVisitor visitor) => visitor.visitLiteralExpression(this); |
584 | 610 |
585 void visitChildren(NodeVisitor visitor) { | 611 void visitChildren(NodeVisitor visitor) { |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 class Comment extends Statement { | 1273 class Comment extends Statement { |
1248 final String comment; | 1274 final String comment; |
1249 | 1275 |
1250 Comment(this.comment); | 1276 Comment(this.comment); |
1251 | 1277 |
1252 accept(NodeVisitor visitor) => visitor.visitComment(this); | 1278 accept(NodeVisitor visitor) => visitor.visitComment(this); |
1253 Comment _clone() => new Comment(comment); | 1279 Comment _clone() => new Comment(comment); |
1254 | 1280 |
1255 void visitChildren(NodeVisitor visitor) {} | 1281 void visitChildren(NodeVisitor visitor) {} |
1256 } | 1282 } |
OLD | NEW |