| 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; | 5 part of js; |
| 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 10 matching lines...) Expand all Loading... |
| 21 T visitThrow(Throw node); | 21 T visitThrow(Throw node); |
| 22 T visitTry(Try node); | 22 T visitTry(Try node); |
| 23 T visitCatch(Catch node); | 23 T visitCatch(Catch node); |
| 24 T visitSwitch(Switch node); | 24 T visitSwitch(Switch node); |
| 25 T visitCase(Case node); | 25 T visitCase(Case node); |
| 26 T visitDefault(Default node); | 26 T visitDefault(Default node); |
| 27 T visitFunctionDeclaration(FunctionDeclaration node); | 27 T visitFunctionDeclaration(FunctionDeclaration node); |
| 28 T visitLabeledStatement(LabeledStatement node); | 28 T visitLabeledStatement(LabeledStatement node); |
| 29 T visitLiteralStatement(LiteralStatement node); | 29 T visitLiteralStatement(LiteralStatement node); |
| 30 | 30 |
| 31 T visitBlob(Blob node); |
| 31 T visitLiteralExpression(LiteralExpression node); | 32 T visitLiteralExpression(LiteralExpression node); |
| 32 T visitVariableDeclarationList(VariableDeclarationList node); | 33 T visitVariableDeclarationList(VariableDeclarationList node); |
| 33 T visitSequence(Sequence node); | 34 T visitSequence(Sequence node); |
| 34 T visitAssignment(Assignment node); | 35 T visitAssignment(Assignment node); |
| 35 T visitVariableInitialization(VariableInitialization node); | 36 T visitVariableInitialization(VariableInitialization node); |
| 36 T visitConditional(Conditional cond); | 37 T visitConditional(Conditional cond); |
| 37 T visitNew(New node); | 38 T visitNew(New node); |
| 38 T visitCall(Call node); | 39 T visitCall(Call node); |
| 39 T visitBinary(Binary node); | 40 T visitBinary(Binary node); |
| 40 T visitPrefix(Prefix node); | 41 T visitPrefix(Prefix node); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 T visitFunctionDeclaration(FunctionDeclaration node) | 97 T visitFunctionDeclaration(FunctionDeclaration node) |
| 97 => visitStatement(node); | 98 => visitStatement(node); |
| 98 T visitLabeledStatement(LabeledStatement node) => visitStatement(node); | 99 T visitLabeledStatement(LabeledStatement node) => visitStatement(node); |
| 99 T visitLiteralStatement(LiteralStatement node) => visitStatement(node); | 100 T visitLiteralStatement(LiteralStatement node) => visitStatement(node); |
| 100 | 101 |
| 101 T visitCatch(Catch node) => visitNode(node); | 102 T visitCatch(Catch node) => visitNode(node); |
| 102 T visitCase(Case node) => visitNode(node); | 103 T visitCase(Case node) => visitNode(node); |
| 103 T visitDefault(Default node) => visitNode(node); | 104 T visitDefault(Default node) => visitNode(node); |
| 104 | 105 |
| 105 T visitExpression(Expression node) => visitNode(node); | 106 T visitExpression(Expression node) => visitNode(node); |
| 107 T visitBlob(Blob node) => visitExpression(node); |
| 106 T visitVariableReference(VariableReference node) => visitExpression(node); | 108 T visitVariableReference(VariableReference node) => visitExpression(node); |
| 107 | 109 |
| 108 T visitLiteralExpression(LiteralExpression node) => visitExpression(node); | 110 T visitLiteralExpression(LiteralExpression node) => visitExpression(node); |
| 109 T visitVariableDeclarationList(VariableDeclarationList node) | 111 T visitVariableDeclarationList(VariableDeclarationList node) |
| 110 => visitExpression(node); | 112 => visitExpression(node); |
| 111 T visitSequence(Sequence node) => visitExpression(node); | 113 T visitSequence(Sequence node) => visitExpression(node); |
| 112 T visitAssignment(Assignment node) => visitExpression(node); | 114 T visitAssignment(Assignment node) => visitExpression(node); |
| 113 T visitVariableInitialization(VariableInitialization node) { | 115 T visitVariableInitialization(VariableInitialization node) { |
| 114 if (node.value != null) { | 116 if (node.value != null) { |
| 115 visitAssignment(node); | 117 visitAssignment(node); |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 return new Assignment.compound(this, operator, js.toExpression(expression)); | 511 return new Assignment.compound(this, operator, js.toExpression(expression)); |
| 510 } | 512 } |
| 511 | 513 |
| 512 Expression get plusPlus => new Postfix('++', this); | 514 Expression get plusPlus => new Postfix('++', this); |
| 513 | 515 |
| 514 Prefix get typeof => new Prefix('typeof', this); | 516 Prefix get typeof => new Prefix('typeof', this); |
| 515 | 517 |
| 516 Prefix get not => new Prefix('!', this); | 518 Prefix get not => new Prefix('!', this); |
| 517 } | 519 } |
| 518 | 520 |
| 521 /// Wrap a CodeBuffer as an expression. |
| 522 class Blob extends Expression { |
| 523 // TODO(ahe): This class is an aid to convert everything to ASTs, remove when |
| 524 // not needed anymore. |
| 525 |
| 526 final leg.CodeBuffer buffer; |
| 527 |
| 528 Blob(this.buffer); |
| 529 |
| 530 accept(NodeVisitor visitor) => visitor.visitBlob(this); |
| 531 |
| 532 void visitChildren(NodeVisitor visitor) {} |
| 533 |
| 534 int get precedenceLevel => PRIMARY; |
| 535 } |
| 536 |
| 519 class LiteralExpression extends Expression { | 537 class LiteralExpression extends Expression { |
| 520 final String template; | 538 final String template; |
| 521 final List<Expression> inputs; | 539 final List<Expression> inputs; |
| 522 | 540 |
| 523 LiteralExpression(this.template) : inputs = const []; | 541 LiteralExpression(this.template) : inputs = const []; |
| 524 LiteralExpression.withData(this.template, this.inputs); | 542 LiteralExpression.withData(this.template, this.inputs); |
| 525 | 543 |
| 526 accept(NodeVisitor visitor) => visitor.visitLiteralExpression(this); | 544 accept(NodeVisitor visitor) => visitor.visitLiteralExpression(this); |
| 527 | 545 |
| 528 void visitChildren(NodeVisitor visitor) { | 546 void visitChildren(NodeVisitor visitor) { |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 */ | 1001 */ |
| 984 class Comment extends Statement { | 1002 class Comment extends Statement { |
| 985 final String comment; | 1003 final String comment; |
| 986 | 1004 |
| 987 Comment(this.comment); | 1005 Comment(this.comment); |
| 988 | 1006 |
| 989 accept(NodeVisitor visitor) => visitor.visitComment(this); | 1007 accept(NodeVisitor visitor) => visitor.visitComment(this); |
| 990 | 1008 |
| 991 void visitChildren(NodeVisitor visitor) {} | 1009 void visitChildren(NodeVisitor visitor) {} |
| 992 } | 1010 } |
| OLD | NEW |