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.mappedBy( | 794 return expressions.map( |
795 (expression) => new ArrayElement(index++, expression)) | 795 (expression) => new ArrayElement(index++, expression)) |
796 .toList(); | 796 .toList(); |
797 } | 797 } |
798 } | 798 } |
799 | 799 |
800 /** | 800 /** |
801 * An expression inside an [ArrayInitialization]. An [ArrayElement] knows | 801 * An expression inside an [ArrayInitialization]. An [ArrayElement] knows |
802 * its position in the containing [ArrayInitialization]. | 802 * its position in the containing [ArrayInitialization]. |
803 */ | 803 */ |
804 class ArrayElement extends Node { | 804 class ArrayElement extends Node { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 | 889 |
890 Block block1(Statement statement) => new Block(<Statement>[statement]); | 890 Block block1(Statement statement) => new Block(<Statement>[statement]); |
891 | 891 |
892 Block block2(Statement s1, Statement s2) => new Block(<Statement>[s1, s2]); | 892 Block block2(Statement s1, Statement s2) => new Block(<Statement>[s1, s2]); |
893 | 893 |
894 Call call(Expression target, List<Expression> arguments) { | 894 Call call(Expression target, List<Expression> arguments) { |
895 return new Call(target, arguments); | 895 return new Call(target, arguments); |
896 } | 896 } |
897 | 897 |
898 Fun fun(List<String> parameterNames, Block body) { | 898 Fun fun(List<String> parameterNames, Block body) { |
899 return new Fun(parameterNames.mappedBy((n) => new Parameter(n)).toList(), | 899 return new Fun(parameterNames.map((n) => new Parameter(n)).toList(), body); |
900 body); | |
901 } | 900 } |
902 | 901 |
903 Assignment assign(Expression leftHandSide, Expression value) { | 902 Assignment assign(Expression leftHandSide, Expression value) { |
904 return new Assignment(leftHandSide, value); | 903 return new Assignment(leftHandSide, value); |
905 } | 904 } |
906 | 905 |
907 Expression undefined() => new Prefix('void', new LiteralNumber('0')); | 906 Expression undefined() => new Prefix('void', new LiteralNumber('0')); |
OLD | NEW |