Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(492)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/dart_backend/dart_tree.dart

Issue 329983002: Implement references to "this" in the new IR. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 * A constant. 167 * A constant.
168 */ 168 */
169 class Constant extends Expression { 169 class Constant extends Expression {
170 dart2js.Constant value; 170 dart2js.Constant value;
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 {
178 accept(Visitor visitor) => visitor.visitThis(this);
179 }
180
177 class LiteralList extends Expression { 181 class LiteralList extends Expression {
178 final GenericType type; 182 final GenericType type;
179 final List<Expression> values; 183 final List<Expression> values;
180 final dart2js.Constant constant; 184 final dart2js.Constant constant;
181 185
182 LiteralList(this.type, this.values, [this.constant]); 186 LiteralList(this.type, this.values, [this.constant]);
183 187
184 accept(ExpressionVisitor visitor) => visitor.visitLiteralList(this); 188 accept(ExpressionVisitor visitor) => visitor.visitLiteralList(this);
185 } 189 }
186 190
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 } 418 }
415 419
416 abstract class ExpressionVisitor<E> { 420 abstract class ExpressionVisitor<E> {
417 E visitExpression(Expression e) => e.accept(this); 421 E visitExpression(Expression e) => e.accept(this);
418 E visitVariable(Variable node); 422 E visitVariable(Variable node);
419 E visitInvokeStatic(InvokeStatic node); 423 E visitInvokeStatic(InvokeStatic node);
420 E visitInvokeMethod(InvokeMethod node); 424 E visitInvokeMethod(InvokeMethod node);
421 E visitInvokeConstructor(InvokeConstructor node); 425 E visitInvokeConstructor(InvokeConstructor node);
422 E visitConcatenateStrings(ConcatenateStrings node); 426 E visitConcatenateStrings(ConcatenateStrings node);
423 E visitConstant(Constant node); 427 E visitConstant(Constant node);
428 E visitThis(This node);
424 E visitConditional(Conditional node); 429 E visitConditional(Conditional node);
425 E visitLogicalOperator(LogicalOperator node); 430 E visitLogicalOperator(LogicalOperator node);
426 E visitNot(Not node); 431 E visitNot(Not node);
427 E visitLiteralList(LiteralList node); 432 E visitLiteralList(LiteralList node);
428 E visitLiteralMap(LiteralMap node); 433 E visitLiteralMap(LiteralMap node);
429 } 434 }
430 435
431 abstract class StatementVisitor<S> { 436 abstract class StatementVisitor<S> {
432 S visitStatement(Statement s) => s.accept(this); 437 S visitStatement(Statement s) => s.accept(this);
433 S visitLabeledStatement(LabeledStatement node); 438 S visitLabeledStatement(LabeledStatement node);
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 node.constructor, 806 node.constructor,
802 node.selector, 807 node.selector,
803 translateArguments(node.arguments), 808 translateArguments(node.arguments),
804 node.constant); 809 node.constant);
805 } 810 }
806 811
807 Expression visitConstant(ir.Constant node) { 812 Expression visitConstant(ir.Constant node) {
808 return new Constant(node.value); 813 return new Constant(node.value);
809 } 814 }
810 815
816 Expression visitThis(ir.This node) {
817 return new This();
818 }
819
811 Expression visitLiteralList(ir.LiteralList node) { 820 Expression visitLiteralList(ir.LiteralList node) {
812 return new LiteralList( 821 return new LiteralList(
813 node.type, 822 node.type,
814 translateArguments(node.values), 823 translateArguments(node.values),
815 node.constant); 824 node.constant);
816 } 825 }
817 826
818 Expression visitLiteralMap(ir.LiteralMap node) { 827 Expression visitLiteralMap(ir.LiteralMap node) {
819 return new LiteralMap( 828 return new LiteralMap(
820 node.type, 829 node.type,
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 1157
1149 Statement visitWhileCondition(WhileCondition node) { 1158 Statement visitWhileCondition(WhileCondition node) {
1150 // Not introduced yet 1159 // Not introduced yet
1151 throw "Unexpected WhileCondition in StatementRewriter"; 1160 throw "Unexpected WhileCondition in StatementRewriter";
1152 } 1161 }
1153 1162
1154 Expression visitConstant(Constant node) { 1163 Expression visitConstant(Constant node) {
1155 return node; 1164 return node;
1156 } 1165 }
1157 1166
1167 Expression visitThis(This node) {
1168 return node;
1169 }
1170
1158 Expression visitLiteralList(LiteralList node) { 1171 Expression visitLiteralList(LiteralList node) {
1159 // Process values right-to-left, the opposite of evaluation order. 1172 // Process values right-to-left, the opposite of evaluation order.
1160 for (int i = node.values.length - 1; i >= 0; --i) { 1173 for (int i = node.values.length - 1; i >= 0; --i) {
1161 node.values[i] = visitExpression(node.values[i]); 1174 node.values[i] = visitExpression(node.values[i]);
1162 } 1175 }
1163 return node; 1176 return node;
1164 } 1177 }
1165 1178
1166 Expression visitLiteralMap(LiteralMap node) { 1179 Expression visitLiteralMap(LiteralMap node) {
1167 // Process arguments right-to-left, the opposite of evaluation order. 1180 // Process arguments right-to-left, the opposite of evaluation order.
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 Expression visitLiteralMap(LiteralMap node) { 1673 Expression visitLiteralMap(LiteralMap node) {
1661 _rewriteList(node.keys); 1674 _rewriteList(node.keys);
1662 _rewriteList(node.values); 1675 _rewriteList(node.values);
1663 return node; 1676 return node;
1664 } 1677 }
1665 1678
1666 Expression visitConstant(Constant node) { 1679 Expression visitConstant(Constant node) {
1667 return node; 1680 return node;
1668 } 1681 }
1669 1682
1683 Expression visitThis(This node) {
1684 return node;
1685 }
1686
1670 Expression visitNot(Not node) { 1687 Expression visitNot(Not node) {
1671 return toBoolean(makeCondition(node.operand, false, liftNots: false)); 1688 return toBoolean(makeCondition(node.operand, false, liftNots: false));
1672 } 1689 }
1673 1690
1674 Expression visitConditional(Conditional node) { 1691 Expression visitConditional(Conditional node) {
1675 // node.condition will be visited after the then and else parts, because its 1692 // node.condition will be visited after the then and else parts, because its
1676 // polarity depends on what rewrite we use. 1693 // polarity depends on what rewrite we use.
1677 node.thenExpression = visitExpression(node.thenExpression); 1694 node.thenExpression = visitExpression(node.thenExpression);
1678 node.elseExpression = visitExpression(node.elseExpression); 1695 node.elseExpression = visitExpression(node.elseExpression);
1679 1696
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 } 1894 }
1878 } 1895 }
1879 1896
1880 /// Destructively updates each entry of [l] with the result of visiting it. 1897 /// Destructively updates each entry of [l] with the result of visiting it.
1881 void _rewriteList(List<Expression> l) { 1898 void _rewriteList(List<Expression> l) {
1882 for (int i = 0; i < l.length; i++) { 1899 for (int i = 0; i < l.length; i++) {
1883 l[i] = visitExpression(l[i]); 1900 l[i] = visitExpression(l[i]);
1884 } 1901 }
1885 } 1902 }
1886 } 1903 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698