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

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

Issue 923013002: dart2dart: Implementation of simple try/catch. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed break/continue, incorporated comments. Created 5 years, 9 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 dart2js.ir_nodes_sexpr; 5 library dart2js.ir_nodes_sexpr;
6 6
7 import '../constants/values.dart'; 7 import '../constants/values.dart';
8 import '../util/util.dart'; 8 import '../util/util.dart';
9 import 'cps_ir_nodes.dart'; 9 import 'cps_ir_nodes.dart';
10 10
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 first = false; 91 first = false;
92 conts = '($name ($parameters)\n$body)'; 92 conts = '($name ($parameters)\n$body)';
93 } else { 93 } else {
94 // Each subsequent line is indented additional spaces to align it 94 // Each subsequent line is indented additional spaces to align it
95 // with the previous continuation. 95 // with the previous continuation.
96 String indent = '$indentation${' ' * '(LetCont ('.length}'; 96 String indent = '$indentation${' ' * '(LetCont ('.length}';
97 conts = '$conts\n$indent($name ($parameters)\n$body)'; 97 conts = '$conts\n$indent($name ($parameters)\n$body)';
98 } 98 }
99 } 99 }
100 String body = indentBlock(() => visit(node.body)); 100 String body = indentBlock(() => visit(node.body));
101 return '$indentation($LetCont ($conts)\n$body)'; 101 return '$indentation(LetCont ($conts)\n$body)';
102 }
103
104 String visitLetHandler(LetHandler node) {
105 // There are no explicit references to the handler, so we leave it
106 // anonymous in the printed representation.
107 String parameters = node.handler.parameters
108 .map((p) => '${decorator(p, newValueName(p))}')
109 .join(' ');
110 String handlerBody =
111 indentBlock(() => indentBlock(() => visit(node.handler.body)));
112 String body = indentBlock(() => visit(node.body));
113 return '$indentation(LetHandler (($parameters)\n$handlerBody)\n$body)';
102 } 114 }
103 115
104 String visitLetMutable(LetMutable node) { 116 String visitLetMutable(LetMutable node) {
105 String name = visit(node.variable); 117 String name = visit(node.variable);
106 String value = access(node.value); 118 String value = access(node.value);
107 String body = indentBlock(() => visit(node.body)); 119 String body = indentBlock(() => visit(node.body));
108 return '$indentation(LetMutable ($name $value)\n$body)'; 120 return '$indentation(LetMutable ($name $value)\n$body)';
109 } 121 }
110 122
111 String formatArguments(Invoke node) { 123 String formatArguments(Invoke node) {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 320
309 String visitBool(BoolConstantValue constant, _) { 321 String visitBool(BoolConstantValue constant, _) {
310 return '(Bool ${constant.unparse()})'; 322 return '(Bool ${constant.unparse()})';
311 } 323 }
312 324
313 String visitString(StringConstantValue constant, _) { 325 String visitString(StringConstantValue constant, _) {
314 return '(String ${constant.unparse()})'; 326 return '(String ${constant.unparse()})';
315 } 327 }
316 328
317 String visitList(ListConstantValue constant, _) { 329 String visitList(ListConstantValue constant, _) {
318 return _failWith(constant); 330 String entries =
331 constant.entries.map((entry) => entry.accept(this, _)).join(' ');
332 return '(List $entries)';
319 } 333 }
320 334
321 String visitMap(MapConstantValue constant, _) { 335 String visitMap(MapConstantValue constant, _) {
322 return _failWith(constant); 336 List<String> elements = <String>[];
337 for (int i = 0; i < constant.keys.length; ++i) {
338 ConstantValue key = constant.keys[i];
339 ConstantValue value = constant.values[i];
340 elements.add('(${key.accept(this, _)} . ${value.accept(this, _)})');
341 }
342 return '(Map (${elements.join(' ')}))';
323 } 343 }
324 344
325 String visitConstructed(ConstructedConstantValue constant, _) { 345 String visitConstructed(ConstructedConstantValue constant, _) {
326 return _failWith(constant); 346 return '(Constructed "${constant.unparse()}")';
327 } 347 }
328 348
329 String visitType(TypeConstantValue constant, _) { 349 String visitType(TypeConstantValue constant, _) {
330 return _failWith(constant); 350 return '(Type "${constant.representedType}")';
331 } 351 }
332 352
333 String visitInterceptor(InterceptorConstantValue constant, _) { 353 String visitInterceptor(InterceptorConstantValue constant, _) {
334 return _failWith(constant); 354 return _failWith(constant);
335 } 355 }
336 356
337 String visitDummy(DummyConstantValue constant, _) { 357 String visitDummy(DummyConstantValue constant, _) {
338 return _failWith(constant); 358 return _failWith(constant);
339 } 359 }
340 360
(...skipping 30 matching lines...) Expand all
371 void setReturnContinuation(Continuation node) { 391 void setReturnContinuation(Continuation node) {
372 assert(!_names.containsKey(node) || _names[node] == 'return'); 392 assert(!_names.containsKey(node) || _names[node] == 'return');
373 _names[node] = 'return'; 393 _names[node] = 'return';
374 } 394 }
375 395
376 String getName(Node node) { 396 String getName(Node node) {
377 assert(_names.containsKey(node)); 397 assert(_names.containsKey(node));
378 return _names[node]; 398 return _names[node];
379 } 399 }
380 } 400 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698