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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart

Issue 1353843002: dart2js cps: Support sync* and yield. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library dart2js.ir_nodes; 4 library dart2js.ir_nodes;
5 5
6 import 'dart:collection'; 6 import 'dart:collection';
7 import '../constants/values.dart' as values; 7 import '../constants/values.dart' as values;
8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; 8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType;
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../io/source_information.dart' show SourceInformation; 10 import '../io/source_information.dart' show SourceInformation;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 80
81 /// An expression that passes a continuation to a call. 81 /// An expression that passes a continuation to a call.
82 abstract class CallExpression extends Expression { 82 abstract class CallExpression extends Expression {
83 Reference<Continuation> get continuation; 83 Reference<Continuation> get continuation;
84 Expression get next => continuation.definition.body; 84 Expression get next => continuation.definition.body;
85 } 85 }
86 86
87 /// An expression without a continuation or a subexpression body. 87 /// An expression without a continuation or a subexpression body.
88 /// 88 ///
89 /// These break straight-line control flow and can be throught of as ending a 89 /// These break straight-line control flow and can be thought of as ending a
90 /// basic block. 90 /// basic block.
91 abstract class TailExpression extends Expression { 91 abstract class TailExpression extends Expression {
92 Expression get next => null; 92 Expression get next => null;
93 } 93 }
94 94
95 /// The base class of things that variables can refer to: primitives, 95 /// The base class of things that variables can refer to: primitives,
96 /// continuations, function and continuation parameters, etc. 96 /// continuations, function and continuation parameters, etc.
97 abstract class Definition<T extends Definition<T>> extends Node { 97 abstract class Definition<T extends Definition<T>> extends Node {
98 // The head of a linked-list of occurrences, in no particular order. 98 // The head of a linked-list of occurrences, in no particular order.
99 Reference<T> firstRef; 99 Reference<T> firstRef;
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 Await(Primitive input, Continuation continuation) 1254 Await(Primitive input, Continuation continuation)
1255 : this.input = new Reference<Primitive>(input), 1255 : this.input = new Reference<Primitive>(input),
1256 this.continuation = new Reference<Continuation>(continuation); 1256 this.continuation = new Reference<Continuation>(continuation);
1257 1257
1258 @override 1258 @override
1259 accept(Visitor visitor) { 1259 accept(Visitor visitor) {
1260 return visitor.visitAwait(this); 1260 return visitor.visitAwait(this);
1261 } 1261 }
1262 } 1262 }
1263 1263
1264 class Yield extends CallExpression {
1265 final Reference<Primitive> input;
1266 final Reference<Continuation> continuation;
1267 final bool hasStar;
1268
1269 Yield(Primitive input, this.hasStar, Continuation continuation)
1270 : this.input = new Reference<Primitive>(input),
1271 this.continuation = new Reference<Continuation>(continuation);
1272
1273 @override
1274 accept(Visitor visitor) {
1275 return visitor.visitYield(this);
1276 }
1277 }
1278
1264 List<Reference<Primitive>> _referenceList(Iterable<Primitive> definitions) { 1279 List<Reference<Primitive>> _referenceList(Iterable<Primitive> definitions) {
1265 return definitions.map((e) => new Reference<Primitive>(e)).toList(); 1280 return definitions.map((e) => new Reference<Primitive>(e)).toList();
1266 } 1281 }
1267 1282
1268 abstract class Visitor<T> { 1283 abstract class Visitor<T> {
1269 const Visitor(); 1284 const Visitor();
1270 1285
1271 T visit(Node node); 1286 T visit(Node node);
1272 1287
1273 // Concrete classes. 1288 // Concrete classes.
(...skipping 12 matching lines...) Expand all
1286 T visitThrow(Throw node); 1301 T visitThrow(Throw node);
1287 T visitRethrow(Rethrow node); 1302 T visitRethrow(Rethrow node);
1288 T visitBranch(Branch node); 1303 T visitBranch(Branch node);
1289 T visitTypeCast(TypeCast node); 1304 T visitTypeCast(TypeCast node);
1290 T visitSetMutable(SetMutable node); 1305 T visitSetMutable(SetMutable node);
1291 T visitSetStatic(SetStatic node); 1306 T visitSetStatic(SetStatic node);
1292 T visitGetLazyStatic(GetLazyStatic node); 1307 T visitGetLazyStatic(GetLazyStatic node);
1293 T visitSetField(SetField node); 1308 T visitSetField(SetField node);
1294 T visitUnreachable(Unreachable node); 1309 T visitUnreachable(Unreachable node);
1295 T visitAwait(Await node); 1310 T visitAwait(Await node);
1311 T visitYield(Yield node);
1296 1312
1297 // Definitions. 1313 // Definitions.
1298 T visitLiteralList(LiteralList node); 1314 T visitLiteralList(LiteralList node);
1299 T visitLiteralMap(LiteralMap node); 1315 T visitLiteralMap(LiteralMap node);
1300 T visitConstant(Constant node); 1316 T visitConstant(Constant node);
1301 T visitCreateFunction(CreateFunction node); 1317 T visitCreateFunction(CreateFunction node);
1302 T visitGetMutable(GetMutable node); 1318 T visitGetMutable(GetMutable node);
1303 T visitParameter(Parameter node); 1319 T visitParameter(Parameter node);
1304 T visitContinuation(Continuation node); 1320 T visitContinuation(Continuation node);
1305 T visitMutableVariable(MutableVariable node); 1321 T visitMutableVariable(MutableVariable node);
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 processUnreachable(node); 1611 processUnreachable(node);
1596 } 1612 }
1597 1613
1598 processAwait(Await node) {} 1614 processAwait(Await node) {}
1599 visitAwait(Await node) { 1615 visitAwait(Await node) {
1600 processAwait(node); 1616 processAwait(node);
1601 processReference(node.input); 1617 processReference(node.input);
1602 processReference(node.continuation); 1618 processReference(node.continuation);
1603 } 1619 }
1604 1620
1621 processYield(Yield node) {}
1622 visitYield(Yield node) {
1623 processYield(node);
1624 processReference(node.input);
1625 processReference(node.continuation);
1626 }
1627
1605 processGetLength(GetLength node) {} 1628 processGetLength(GetLength node) {}
1606 visitGetLength(GetLength node) { 1629 visitGetLength(GetLength node) {
1607 processGetLength(node); 1630 processGetLength(node);
1608 processReference(node.object); 1631 processReference(node.object);
1609 } 1632 }
1610 1633
1611 processGetIndex(GetIndex node) {} 1634 processGetIndex(GetIndex node) {}
1612 visitGetIndex(GetIndex node) { 1635 visitGetIndex(GetIndex node) {
1613 processGetIndex(node); 1636 processGetIndex(node);
1614 processReference(node.object); 1637 processReference(node.object);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 /// Visit a just-deleted subterm and unlink all [Reference]s in it. 1775 /// Visit a just-deleted subterm and unlink all [Reference]s in it.
1753 class RemovalVisitor extends RecursiveVisitor { 1776 class RemovalVisitor extends RecursiveVisitor {
1754 processReference(Reference reference) { 1777 processReference(Reference reference) {
1755 reference.unlink(); 1778 reference.unlink();
1756 } 1779 }
1757 1780
1758 static void remove(Node node) { 1781 static void remove(Node node) {
1759 (new RemovalVisitor()).visit(node); 1782 (new RemovalVisitor()).visit(node);
1760 } 1783 }
1761 } 1784 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698