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 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 accept(NodeVisitor visitor) => visitor.visitArrayInitializer(this); | 784 accept(NodeVisitor visitor) => visitor.visitArrayInitializer(this); |
785 | 785 |
786 void visitChildren(NodeVisitor visitor) { | 786 void visitChildren(NodeVisitor visitor) { |
787 for (ArrayElement element in elements) element.accept(visitor); | 787 for (ArrayElement element in elements) element.accept(visitor); |
788 } | 788 } |
789 | 789 |
790 int get precedenceLevel => PRIMARY; | 790 int get precedenceLevel => PRIMARY; |
791 | 791 |
792 static List<ArrayElement> _convert(List<Expression> expressions) { | 792 static List<ArrayElement> _convert(List<Expression> expressions) { |
793 int index = 0; | 793 int index = 0; |
794 return expressions.map( | 794 return expressions.mappedBy( |
795 (expression) => new ArrayElement(index++, expression)); | 795 (expression) => new ArrayElement(index++, expression)) |
| 796 .toList(); |
796 } | 797 } |
797 } | 798 } |
798 | 799 |
799 /** | 800 /** |
800 * An expression inside an [ArrayInitialization]. An [ArrayElement] knows | 801 * An expression inside an [ArrayInitialization]. An [ArrayElement] knows |
801 * its position in the containing [ArrayInitialization]. | 802 * its position in the containing [ArrayInitialization]. |
802 */ | 803 */ |
803 class ArrayElement extends Node { | 804 class ArrayElement extends Node { |
804 int index; | 805 int index; |
805 Expression value; | 806 Expression value; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 | 885 |
885 Block block1(Statement statement) => new Block(<Statement>[statement]); | 886 Block block1(Statement statement) => new Block(<Statement>[statement]); |
886 | 887 |
887 Block block2(Statement s1, Statement s2) => new Block(<Statement>[s1, s2]); | 888 Block block2(Statement s1, Statement s2) => new Block(<Statement>[s1, s2]); |
888 | 889 |
889 Call call(Expression target, List<Expression> arguments) { | 890 Call call(Expression target, List<Expression> arguments) { |
890 return new Call(target, arguments); | 891 return new Call(target, arguments); |
891 } | 892 } |
892 | 893 |
893 Fun fun(List<String> parameterNames, Block body) { | 894 Fun fun(List<String> parameterNames, Block body) { |
894 return new Fun(parameterNames.map((n) => new Parameter(n)), body); | 895 return new Fun(parameterNames.mappedBy((n) => new Parameter(n)).toList(), |
| 896 body); |
895 } | 897 } |
896 | 898 |
897 Assignment assign(Expression leftHandSide, Expression value) { | 899 Assignment assign(Expression leftHandSide, Expression value) { |
898 return new Assignment(leftHandSide, value); | 900 return new Assignment(leftHandSide, value); |
899 } | 901 } |
900 | 902 |
901 Expression undefined() => new Prefix('void', new LiteralNumber('0')); | 903 Expression undefined() => new Prefix('void', new LiteralNumber('0')); |
OLD | NEW |