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 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 import '../universe/call_structure.dart' show | 10 import '../universe/call_structure.dart' show |
(...skipping 15 matching lines...) Expand all Loading... |
26 SExpressionStringifier([this.decorator]) { | 26 SExpressionStringifier([this.decorator]) { |
27 if (this.decorator == null) { | 27 if (this.decorator == null) { |
28 this.decorator = (node, String s) => s; | 28 this.decorator = (node, String s) => s; |
29 } | 29 } |
30 } | 30 } |
31 | 31 |
32 String access(Reference<Definition> r) { | 32 String access(Reference<Definition> r) { |
33 return decorator(r, namer.getName(r.definition)); | 33 return decorator(r, namer.getName(r.definition)); |
34 } | 34 } |
35 | 35 |
| 36 String optional(Reference<Definition> r) { |
| 37 return r == null ? '()' : '(${access(r)})'; |
| 38 } |
| 39 |
36 String visitParameter(Parameter node) { | 40 String visitParameter(Parameter node) { |
37 return namer.nameParameter(node); | 41 return namer.nameParameter(node); |
38 } | 42 } |
39 | 43 |
40 String visitMutableVariable(MutableVariable node) { | 44 String visitMutableVariable(MutableVariable node) { |
41 return namer.nameMutableVariable(node); | 45 return namer.nameMutableVariable(node); |
42 } | 46 } |
43 | 47 |
44 /// Main entry point for creating a [String] from a [Node]. All recursive | 48 /// Main entry point for creating a [String] from a [Node]. All recursive |
45 /// calls must go through this method. | 49 /// calls must go through this method. |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 @override | 357 @override |
354 String visitYield(Yield node) { | 358 String visitYield(Yield node) { |
355 String value = access(node.input); | 359 String value = access(node.input); |
356 return '(Yield $value)'; | 360 return '(Yield $value)'; |
357 } | 361 } |
358 | 362 |
359 String visitRefinement(Refinement node) { | 363 String visitRefinement(Refinement node) { |
360 String value = access(node.value); | 364 String value = access(node.value); |
361 return '(Refinement $value ${node.type})'; | 365 return '(Refinement $value ${node.type})'; |
362 } | 366 } |
| 367 |
| 368 String visitNullCheck(NullCheck node) { |
| 369 String value = access(node.value); |
| 370 String condition = optional(node.condition); |
| 371 return '(NullCheck $value $condition (${node.selector ?? ""}))'; |
| 372 } |
363 } | 373 } |
364 | 374 |
365 class ConstantStringifier extends ConstantValueVisitor<String, Null> { | 375 class ConstantStringifier extends ConstantValueVisitor<String, Null> { |
366 // Some of these methods are unimplemented because we haven't had a need | 376 // Some of these methods are unimplemented because we haven't had a need |
367 // to print such constants. When printing is implemented, the corresponding | 377 // to print such constants. When printing is implemented, the corresponding |
368 // parsing support should be added to SExpressionUnstringifier.parseConstant | 378 // parsing support should be added to SExpressionUnstringifier.parseConstant |
369 // in the dart2js tests (currently in the file | 379 // in the dart2js tests (currently in the file |
370 // tests/compiler/dart2js/backend_dart/sexpr_unstringifier.dart). | 380 // tests/compiler/dart2js/backend_dart/sexpr_unstringifier.dart). |
371 | 381 |
372 String _failWith(ConstantValue constant) { | 382 String _failWith(ConstantValue constant) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 void setReturnContinuation(Continuation node) { | 477 void setReturnContinuation(Continuation node) { |
468 assert(!_names.containsKey(node) || _names[node] == 'return'); | 478 assert(!_names.containsKey(node) || _names[node] == 'return'); |
469 _names[node] = 'return'; | 479 _names[node] = 'return'; |
470 } | 480 } |
471 | 481 |
472 String getName(Node node) { | 482 String getName(Node node) { |
473 if (!_names.containsKey(node)) return 'MISSING_NAME'; | 483 if (!_names.containsKey(node)) return 'MISSING_NAME'; |
474 return _names[node]; | 484 return _names[node]; |
475 } | 485 } |
476 } | 486 } |
OLD | NEW |