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> 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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 for (var node in exprs) { | 702 for (var node in exprs) { |
703 comma = (comma == null) ? node : new Binary(op, comma, node); | 703 comma = (comma == null) ? node : new Binary(op, comma, node); |
704 } | 704 } |
705 return comma; | 705 return comma; |
706 } | 706 } |
707 | 707 |
708 int get precedenceLevel; | 708 int get precedenceLevel; |
709 | 709 |
710 Statement toStatement() => new ExpressionStatement(toVoidExpression()); | 710 Statement toStatement() => new ExpressionStatement(toVoidExpression()); |
711 Statement toReturn() => new Return(this); | 711 Statement toReturn() => new Return(this); |
| 712 |
| 713 // TODO(jmesserly): make this return a Yield? |
712 Statement toYieldStatement({bool star: false}) => | 714 Statement toYieldStatement({bool star: false}) => |
713 new ExpressionStatement(new Yield(this, star: star)); | 715 new ExpressionStatement(new Yield(this, star: star)); |
714 | 716 |
715 Expression toVoidExpression() => this; | 717 Expression toVoidExpression() => this; |
716 Expression toAssignExpression(Expression left) => new Assignment(left, this); | 718 Expression toAssignExpression(Expression left, [String op]) => |
| 719 new Assignment.compound(left, op, this); |
| 720 |
| 721 // TODO(jmesserly): make this work for more cases? |
717 Statement toVariableDeclaration(Identifier name) => | 722 Statement toVariableDeclaration(Identifier name) => |
718 new VariableDeclarationList( | 723 new VariableDeclarationList( |
719 'let', [new VariableInitialization(name, this)]).toStatement(); | 724 'let', [new VariableInitialization(name, this)]).toStatement(); |
720 } | 725 } |
721 | 726 |
722 class LiteralExpression extends Expression { | 727 class LiteralExpression extends Expression { |
723 final String template; | 728 final String template; |
724 final List<Expression> inputs; | 729 final List<Expression> inputs; |
725 | 730 |
726 LiteralExpression(this.template) : inputs = const []; | 731 LiteralExpression(this.template) : inputs = const []; |
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 final List<ModuleItem> body; | 1908 final List<ModuleItem> body; |
1904 Module(this.body, {this.name}); | 1909 Module(this.body, {this.name}); |
1905 | 1910 |
1906 accept(NodeVisitor visitor) => visitor.visitModule(this); | 1911 accept(NodeVisitor visitor) => visitor.visitModule(this); |
1907 void visitChildren(NodeVisitor visitor) { | 1912 void visitChildren(NodeVisitor visitor) { |
1908 for (ModuleItem item in body) item.accept(visitor); | 1913 for (ModuleItem item in body) item.accept(visitor); |
1909 } | 1914 } |
1910 | 1915 |
1911 Module _clone() => new Module(body); | 1916 Module _clone() => new Module(body); |
1912 } | 1917 } |
OLD | NEW |