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

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

Issue 923013002: dart2dart: Implementation of simple try/catch. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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) 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 4
5 // IrNodes are kept in a separate library to have precise control over their 5 // IrNodes are kept in a separate library to have precise control over their
6 // dependencies on other parts of the system. 6 // dependencies on other parts of the system.
7 library dart2js.ir_nodes; 7 library dart2js.ir_nodes;
8 8
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../constants/values.dart' as values show ConstantValue; 10 import '../constants/values.dart' as values show ConstantValue;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 Expression plug(Expression expr) { 147 Expression plug(Expression expr) {
148 assert(continuations != null && 148 assert(continuations != null &&
149 continuations.isNotEmpty && 149 continuations.isNotEmpty &&
150 continuations.first.body == null); 150 continuations.first.body == null);
151 return continuations.first.body = expr; 151 return continuations.first.body = expr;
152 } 152 }
153 153
154 accept(Visitor visitor) => visitor.visitLetCont(this); 154 accept(Visitor visitor) => visitor.visitLetCont(this);
155 } 155 }
156 156
157 // Binding an exception handler.
karlklose 2015/02/16 10:15:48 Make this a DartDoc comment ('///'), and maybe put
Kevin Millikin (Google) 2015/02/24 11:59:25 OK. But I'll just address the TODO before submitt
158 //
159 // let handler h(v0 ...) = E0 in E1
160 //
161 // The handler is a continuation which is implicitly the error continuation of
162 // all the code in its body E1. The handler parameters represent the
163 // exception and possibly the stack trace. (TODO(kmillikin): should we just
164 // ensure that they always have two parameters?) It differs from let cont
165 // binding a call continuation in that it (1) has the runtime semantics of
166 // pushing/popping a handler from the dynamic exception handler stack and
167 // (2) it does not have explicit invocations.
168 class LetHandler extends Expression implements InteriorNode {
169 Continuation handler;
170 Expression body;
171
172 LetHandler(this.handler, this.body);
173
174 accept(Visitor visitor) => visitor.visitLetHandler(this);
175 }
176
157 /// Binding mutable variables. 177 /// Binding mutable variables.
158 /// 178 ///
159 /// let mutable v = P in E 179 /// let mutable v = P in E
160 /// 180 ///
161 /// [MutableVariable]s can be seen as ref cells that are not first-class 181 /// [MutableVariable]s can be seen as ref cells that are not first-class
162 /// values. They are therefore not [Primitive]s and not bound by [LetPrim] 182 /// values. They are therefore not [Primitive]s and not bound by [LetPrim]
163 /// to prevent unrestricted use of references to them. During one-pass 183 /// to prevent unrestricted use of references to them. During one-pass
164 /// construction, a [LetMutable] with an empty body is use to represent the 184 /// construction, a [LetMutable] with an empty body is use to represent the
165 /// one-hole context 'let mutable v = P in []'. 185 /// one-hole context 'let mutable v = P in []'.
166 class LetMutable extends Expression implements InteriorNode { 186 class LetMutable extends Expression implements InteriorNode {
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 } 882 }
863 883
864 // Initializers 884 // Initializers
865 T visitInitializer(Initializer node) => visitNode(node); 885 T visitInitializer(Initializer node) => visitNode(node);
866 T visitFieldInitializer(FieldInitializer node) => visitInitializer(node); 886 T visitFieldInitializer(FieldInitializer node) => visitInitializer(node);
867 T visitSuperInitializer(SuperInitializer node) => visitInitializer(node); 887 T visitSuperInitializer(SuperInitializer node) => visitInitializer(node);
868 888
869 // Expressions. 889 // Expressions.
870 T visitLetPrim(LetPrim node) => visitExpression(node); 890 T visitLetPrim(LetPrim node) => visitExpression(node);
871 T visitLetCont(LetCont node) => visitExpression(node); 891 T visitLetCont(LetCont node) => visitExpression(node);
892 T visitLetHandler(LetHandler node) => visitExpression(node);
872 T visitLetMutable(LetMutable node) => visitExpression(node); 893 T visitLetMutable(LetMutable node) => visitExpression(node);
873 T visitInvokeStatic(InvokeStatic node) => visitExpression(node); 894 T visitInvokeStatic(InvokeStatic node) => visitExpression(node);
874 T visitInvokeContinuation(InvokeContinuation node) => visitExpression(node); 895 T visitInvokeContinuation(InvokeContinuation node) => visitExpression(node);
875 T visitInvokeMethod(InvokeMethod node) => visitExpression(node); 896 T visitInvokeMethod(InvokeMethod node) => visitExpression(node);
876 T visitInvokeMethodDirectly(InvokeMethodDirectly node) => visitExpression(node ); 897 T visitInvokeMethodDirectly(InvokeMethodDirectly node) => visitExpression(node );
877 T visitInvokeConstructor(InvokeConstructor node) => visitExpression(node); 898 T visitInvokeConstructor(InvokeConstructor node) => visitExpression(node);
878 T visitConcatenateStrings(ConcatenateStrings node) => visitExpression(node); 899 T visitConcatenateStrings(ConcatenateStrings node) => visitExpression(node);
879 T visitBranch(Branch node) => visitExpression(node); 900 T visitBranch(Branch node) => visitExpression(node);
880 T visitTypeOperator(TypeOperator node) => visitExpression(node); 901 T visitTypeOperator(TypeOperator node) => visitExpression(node);
881 T visitSetMutableVariable(SetMutableVariable node) => visitExpression(node); 902 T visitSetMutableVariable(SetMutableVariable node) => visitExpression(node);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 visit(node.body); 995 visit(node.body);
975 } 996 }
976 997
977 processLetCont(LetCont node) {} 998 processLetCont(LetCont node) {}
978 visitLetCont(LetCont node) { 999 visitLetCont(LetCont node) {
979 processLetCont(node); 1000 processLetCont(node);
980 node.continuations.forEach(visit); 1001 node.continuations.forEach(visit);
981 visit(node.body); 1002 visit(node.body);
982 } 1003 }
983 1004
1005 processLetHandler(LetHandler node) {}
1006 visitLetHandler(LetHandler node) {
1007 processLetHandler(node);
1008 visit(node.handler);
1009 visit(node.body);
1010 }
1011
984 processLetMutable(LetMutable node) {} 1012 processLetMutable(LetMutable node) {}
985 visitLetMutable(LetMutable node) { 1013 visitLetMutable(LetMutable node) {
986 processLetMutable(node); 1014 processLetMutable(node);
987 visit(node.variable); 1015 visit(node.variable);
988 processReference(node.value); 1016 processReference(node.value);
989 visit(node.body); 1017 visit(node.body);
990 } 1018 }
991 1019
992 processInvokeStatic(InvokeStatic node) {} 1020 processInvokeStatic(InvokeStatic node) {}
993 visitInvokeStatic(InvokeStatic node) { 1021 visitInvokeStatic(InvokeStatic node) {
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 visit(node.body); 1296 visit(node.body);
1269 release(node.primitive); 1297 release(node.primitive);
1270 visit(node.primitive); 1298 visit(node.primitive);
1271 } 1299 }
1272 1300
1273 void visitLetCont(LetCont node) { 1301 void visitLetCont(LetCont node) {
1274 node.continuations.forEach(visit); 1302 node.continuations.forEach(visit);
1275 visit(node.body); 1303 visit(node.body);
1276 } 1304 }
1277 1305
1306 void visitLetHandler(LetHandler node) {
1307 visit(node.handler);
1308 // Assign indices to unused handler parameters, because they should
1309 // not be eliminated. Then release all of them because they are not
1310 // live in the try block.
1311 node.handler.parameters.forEach((p) {
floitsch 2015/02/16 14:54:07 We tend to type (even for closures) and not to abb
Kevin Millikin (Google) 2015/02/24 11:59:25 Done.
1312 allocate(p);
1313 release(p);
floitsch 2015/02/16 14:54:07 I'm not sure I understand (even with the comment).
Kevin Millikin (Google) 2015/02/24 11:59:25 The clearest name I can think of is "AllocateThenR
1314 });
1315 visit(node.body);
1316 }
1317
1278 void visitLetMutable(LetMutable node) { 1318 void visitLetMutable(LetMutable node) {
1279 visit(node.body); 1319 visit(node.body);
1280 visitReference(node.value); 1320 visitReference(node.value);
1281 } 1321 }
1282 1322
1283 void visitInvokeStatic(InvokeStatic node) { 1323 void visitInvokeStatic(InvokeStatic node) {
1284 node.arguments.forEach(visitReference); 1324 node.arguments.forEach(visitReference);
1285 } 1325 }
1286 1326
1287 void visitInvokeContinuation(InvokeContinuation node) { 1327 void visitInvokeContinuation(InvokeContinuation node) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 1431
1392 void visitIdentical(Identical node) { 1432 void visitIdentical(Identical node) {
1393 visitReference(node.left); 1433 visitReference(node.left);
1394 visitReference(node.right); 1434 visitReference(node.right);
1395 } 1435 }
1396 1436
1397 void visitInterceptor(Interceptor node) { 1437 void visitInterceptor(Interceptor node) {
1398 visitReference(node.input); 1438 visitReference(node.input);
1399 } 1439 }
1400 } 1440 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698