Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library dart_tree; | 5 library dart_tree; |
| 6 | 6 |
| 7 import '../dart2jslib.dart' as dart2js; | 7 import '../dart2jslib.dart' as dart2js; |
| 8 import '../elements/elements.dart' | 8 import '../elements/elements.dart' |
| 9 show Element, FunctionElement, FunctionSignature, ParameterElement, | 9 show Element, FunctionElement, FunctionSignature, ParameterElement, |
| 10 ClassElement; | 10 ClassElement; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 | 171 |
| 172 Constant(this.value); | 172 Constant(this.value); |
| 173 | 173 |
| 174 accept(ExpressionVisitor visitor) => visitor.visitConstant(this); | 174 accept(ExpressionVisitor visitor) => visitor.visitConstant(this); |
| 175 } | 175 } |
| 176 | 176 |
| 177 class This extends Expression { | 177 class This extends Expression { |
| 178 accept(Visitor visitor) => visitor.visitThis(this); | 178 accept(Visitor visitor) => visitor.visitThis(this); |
| 179 } | 179 } |
| 180 | 180 |
| 181 class Super extends Expression { | |
|
asgerf
2014/06/23 10:55:17
I would prefer that we did this like in dart_tree,
sigurdm
2014/06/24 09:23:08
Good point - did that.
| |
| 182 accept(Visitor visitor) => visitor.visitSuper(this); | |
| 183 } | |
| 184 | |
| 181 class LiteralList extends Expression { | 185 class LiteralList extends Expression { |
| 182 final GenericType type; | 186 final GenericType type; |
| 183 final List<Expression> values; | 187 final List<Expression> values; |
| 184 final dart2js.Constant constant; | 188 final dart2js.Constant constant; |
| 185 | 189 |
| 186 LiteralList(this.type, this.values, [this.constant]); | 190 LiteralList(this.type, this.values, [this.constant]); |
| 187 | 191 |
| 188 accept(ExpressionVisitor visitor) => visitor.visitLiteralList(this); | 192 accept(ExpressionVisitor visitor) => visitor.visitLiteralList(this); |
| 189 } | 193 } |
| 190 | 194 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 | 423 |
| 420 abstract class ExpressionVisitor<E> { | 424 abstract class ExpressionVisitor<E> { |
| 421 E visitExpression(Expression e) => e.accept(this); | 425 E visitExpression(Expression e) => e.accept(this); |
| 422 E visitVariable(Variable node); | 426 E visitVariable(Variable node); |
| 423 E visitInvokeStatic(InvokeStatic node); | 427 E visitInvokeStatic(InvokeStatic node); |
| 424 E visitInvokeMethod(InvokeMethod node); | 428 E visitInvokeMethod(InvokeMethod node); |
| 425 E visitInvokeConstructor(InvokeConstructor node); | 429 E visitInvokeConstructor(InvokeConstructor node); |
| 426 E visitConcatenateStrings(ConcatenateStrings node); | 430 E visitConcatenateStrings(ConcatenateStrings node); |
| 427 E visitConstant(Constant node); | 431 E visitConstant(Constant node); |
| 428 E visitThis(This node); | 432 E visitThis(This node); |
| 433 E visitSuper(Super node); | |
| 429 E visitConditional(Conditional node); | 434 E visitConditional(Conditional node); |
| 430 E visitLogicalOperator(LogicalOperator node); | 435 E visitLogicalOperator(LogicalOperator node); |
| 431 E visitNot(Not node); | 436 E visitNot(Not node); |
| 432 E visitLiteralList(LiteralList node); | 437 E visitLiteralList(LiteralList node); |
| 433 E visitLiteralMap(LiteralMap node); | 438 E visitLiteralMap(LiteralMap node); |
| 434 } | 439 } |
| 435 | 440 |
| 436 abstract class StatementVisitor<S> { | 441 abstract class StatementVisitor<S> { |
| 437 S visitStatement(Statement s) => s.accept(this); | 442 S visitStatement(Statement s) => s.accept(this); |
| 438 S visitLabeledStatement(LabeledStatement node); | 443 S visitLabeledStatement(LabeledStatement node); |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 810 } | 815 } |
| 811 | 816 |
| 812 Expression visitConstant(ir.Constant node) { | 817 Expression visitConstant(ir.Constant node) { |
| 813 return new Constant(node.value); | 818 return new Constant(node.value); |
| 814 } | 819 } |
| 815 | 820 |
| 816 Expression visitThis(ir.This node) { | 821 Expression visitThis(ir.This node) { |
| 817 return new This(); | 822 return new This(); |
| 818 } | 823 } |
| 819 | 824 |
| 825 Expression visitSuper(ir.Super node) { | |
| 826 return new Super(); | |
| 827 } | |
| 828 | |
| 820 Expression visitLiteralList(ir.LiteralList node) { | 829 Expression visitLiteralList(ir.LiteralList node) { |
| 821 return new LiteralList( | 830 return new LiteralList( |
| 822 node.type, | 831 node.type, |
| 823 translateArguments(node.values), | 832 translateArguments(node.values), |
| 824 node.constant); | 833 node.constant); |
| 825 } | 834 } |
| 826 | 835 |
| 827 Expression visitLiteralMap(ir.LiteralMap node) { | 836 Expression visitLiteralMap(ir.LiteralMap node) { |
| 828 return new LiteralMap( | 837 return new LiteralMap( |
| 829 node.type, | 838 node.type, |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1161 } | 1170 } |
| 1162 | 1171 |
| 1163 Expression visitConstant(Constant node) { | 1172 Expression visitConstant(Constant node) { |
| 1164 return node; | 1173 return node; |
| 1165 } | 1174 } |
| 1166 | 1175 |
| 1167 Expression visitThis(This node) { | 1176 Expression visitThis(This node) { |
| 1168 return node; | 1177 return node; |
| 1169 } | 1178 } |
| 1170 | 1179 |
| 1180 Expression visitSuper(Super node) { | |
| 1181 return node; | |
| 1182 } | |
| 1183 | |
| 1171 Expression visitLiteralList(LiteralList node) { | 1184 Expression visitLiteralList(LiteralList node) { |
| 1172 // Process values right-to-left, the opposite of evaluation order. | 1185 // Process values right-to-left, the opposite of evaluation order. |
| 1173 for (int i = node.values.length - 1; i >= 0; --i) { | 1186 for (int i = node.values.length - 1; i >= 0; --i) { |
| 1174 node.values[i] = visitExpression(node.values[i]); | 1187 node.values[i] = visitExpression(node.values[i]); |
| 1175 } | 1188 } |
| 1176 return node; | 1189 return node; |
| 1177 } | 1190 } |
| 1178 | 1191 |
| 1179 Expression visitLiteralMap(LiteralMap node) { | 1192 Expression visitLiteralMap(LiteralMap node) { |
| 1180 // Process arguments right-to-left, the opposite of evaluation order. | 1193 // Process arguments right-to-left, the opposite of evaluation order. |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1677 } | 1690 } |
| 1678 | 1691 |
| 1679 Expression visitConstant(Constant node) { | 1692 Expression visitConstant(Constant node) { |
| 1680 return node; | 1693 return node; |
| 1681 } | 1694 } |
| 1682 | 1695 |
| 1683 Expression visitThis(This node) { | 1696 Expression visitThis(This node) { |
| 1684 return node; | 1697 return node; |
| 1685 } | 1698 } |
| 1686 | 1699 |
| 1700 Expression visitSuper(Super node) { | |
| 1701 return node; | |
| 1702 } | |
| 1703 | |
| 1687 Expression visitNot(Not node) { | 1704 Expression visitNot(Not node) { |
| 1688 return toBoolean(makeCondition(node.operand, false, liftNots: false)); | 1705 return toBoolean(makeCondition(node.operand, false, liftNots: false)); |
| 1689 } | 1706 } |
| 1690 | 1707 |
| 1691 Expression visitConditional(Conditional node) { | 1708 Expression visitConditional(Conditional node) { |
| 1692 // node.condition will be visited after the then and else parts, because its | 1709 // node.condition will be visited after the then and else parts, because its |
| 1693 // polarity depends on what rewrite we use. | 1710 // polarity depends on what rewrite we use. |
| 1694 node.thenExpression = visitExpression(node.thenExpression); | 1711 node.thenExpression = visitExpression(node.thenExpression); |
| 1695 node.elseExpression = visitExpression(node.elseExpression); | 1712 node.elseExpression = visitExpression(node.elseExpression); |
| 1696 | 1713 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1894 } | 1911 } |
| 1895 } | 1912 } |
| 1896 | 1913 |
| 1897 /// Destructively updates each entry of [l] with the result of visiting it. | 1914 /// Destructively updates each entry of [l] with the result of visiting it. |
| 1898 void _rewriteList(List<Expression> l) { | 1915 void _rewriteList(List<Expression> l) { |
| 1899 for (int i = 0; i < l.length; i++) { | 1916 for (int i = 0; i < l.length; i++) { |
| 1900 l[i] = visitExpression(l[i]); | 1917 l[i] = visitExpression(l[i]); |
| 1901 } | 1918 } |
| 1902 } | 1919 } |
| 1903 } | 1920 } |
| OLD | NEW |