| 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) { | 36 String optionalAccess(Reference<Definition> reference) { |
| 37 return r == null ? '()' : '(${access(r)})'; | 37 return reference == null ? '()' : '(${access(reference)})'; |
| 38 } | 38 } |
| 39 | 39 |
| 40 String visitParameter(Parameter node) { | 40 String visitParameter(Parameter node) { |
| 41 return namer.nameParameter(node); | 41 return namer.nameParameter(node); |
| 42 } | 42 } |
| 43 | 43 |
| 44 String visitMutableVariable(MutableVariable node) { | 44 String visitMutableVariable(MutableVariable node) { |
| 45 return namer.nameMutableVariable(node); | 45 return namer.nameMutableVariable(node); |
| 46 } | 46 } |
| 47 | 47 |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 String visitYield(Yield node) { | 358 String visitYield(Yield node) { |
| 359 String value = access(node.input); | 359 String value = access(node.input); |
| 360 return '(Yield $value)'; | 360 return '(Yield $value)'; |
| 361 } | 361 } |
| 362 | 362 |
| 363 String visitRefinement(Refinement node) { | 363 String visitRefinement(Refinement node) { |
| 364 String value = access(node.value); | 364 String value = access(node.value); |
| 365 return '(Refinement $value ${node.type})'; | 365 return '(Refinement $value ${node.type})'; |
| 366 } | 366 } |
| 367 | 367 |
| 368 String visitBoundsCheck(BoundsCheck node) { |
| 369 String object = access(node.object); |
| 370 String index = optionalAccess(node.index); |
| 371 String length = optionalAccess(node.length); |
| 372 return '(BoundsCheck $object $index $length ${node.checkString})'; |
| 373 } |
| 374 |
| 368 String visitNullCheck(NullCheck node) { | 375 String visitNullCheck(NullCheck node) { |
| 369 String value = access(node.value); | 376 String value = access(node.value); |
| 370 String condition = optional(node.condition); | 377 String condition = optionalAccess(node.condition); |
| 371 return '(NullCheck $value $condition (${node.selector ?? ""}))'; | 378 return '(NullCheck $value $condition (${node.selector ?? ""}))'; |
| 372 } | 379 } |
| 373 } | 380 } |
| 374 | 381 |
| 375 class ConstantStringifier extends ConstantValueVisitor<String, Null> { | 382 class ConstantStringifier extends ConstantValueVisitor<String, Null> { |
| 376 // Some of these methods are unimplemented because we haven't had a need | 383 // Some of these methods are unimplemented because we haven't had a need |
| 377 // to print such constants. When printing is implemented, the corresponding | 384 // to print such constants. When printing is implemented, the corresponding |
| 378 // parsing support should be added to SExpressionUnstringifier.parseConstant | 385 // parsing support should be added to SExpressionUnstringifier.parseConstant |
| 379 // in the dart2js tests (currently in the file | 386 // in the dart2js tests (currently in the file |
| 380 // tests/compiler/dart2js/backend_dart/sexpr_unstringifier.dart). | 387 // tests/compiler/dart2js/backend_dart/sexpr_unstringifier.dart). |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 void setReturnContinuation(Continuation node) { | 484 void setReturnContinuation(Continuation node) { |
| 478 assert(!_names.containsKey(node) || _names[node] == 'return'); | 485 assert(!_names.containsKey(node) || _names[node] == 'return'); |
| 479 _names[node] = 'return'; | 486 _names[node] = 'return'; |
| 480 } | 487 } |
| 481 | 488 |
| 482 String getName(Node node) { | 489 String getName(Node node) { |
| 483 if (!_names.containsKey(node)) return 'MISSING_NAME'; | 490 if (!_names.containsKey(node)) return 'MISSING_NAME'; |
| 484 return _names[node]; | 491 return _names[node]; |
| 485 } | 492 } |
| 486 } | 493 } |
| OLD | NEW |