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 CallStructure; | 10 import '../universe/call_structure.dart' show CallStructure; |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 } | 457 } |
458 | 458 |
459 class ConstantStringifier extends ConstantValueVisitor<String, Null> { | 459 class ConstantStringifier extends ConstantValueVisitor<String, Null> { |
460 // Some of these methods are unimplemented because we haven't had a need | 460 // Some of these methods are unimplemented because we haven't had a need |
461 // to print such constants. When printing is implemented, the corresponding | 461 // to print such constants. When printing is implemented, the corresponding |
462 // parsing support should be added to SExpressionUnstringifier.parseConstant | 462 // parsing support should be added to SExpressionUnstringifier.parseConstant |
463 // in the dart2js tests (currently in the file | 463 // in the dart2js tests (currently in the file |
464 // tests/compiler/dart2js/backend_dart/sexpr_unstringifier.dart). | 464 // tests/compiler/dart2js/backend_dart/sexpr_unstringifier.dart). |
465 | 465 |
466 String _failWith(ConstantValue constant) { | 466 String _failWith(ConstantValue constant) { |
467 throw 'Stringification not supported for ${constant.toStructuredString()}'; | 467 throw 'Stringification not supported for ${constant.toStructuredText()}'; |
468 } | 468 } |
469 | 469 |
470 String visitFunction(FunctionConstantValue constant, _) { | 470 String visitFunction(FunctionConstantValue constant, _) { |
471 return '(Function "${constant.unparse()}")'; | 471 return '(Function "${constant.toDartText()}")'; |
472 } | 472 } |
473 | 473 |
474 String visitNull(NullConstantValue constant, _) { | 474 String visitNull(NullConstantValue constant, _) { |
475 return '(Null)'; | 475 return '(Null)'; |
476 } | 476 } |
477 | 477 |
478 String visitInt(IntConstantValue constant, _) { | 478 String visitInt(IntConstantValue constant, _) { |
479 return '(Int ${constant.unparse()})'; | 479 return '(Int ${constant.toDartText()})'; |
480 } | 480 } |
481 | 481 |
482 String visitDouble(DoubleConstantValue constant, _) { | 482 String visitDouble(DoubleConstantValue constant, _) { |
483 return '(Double ${constant.unparse()})'; | 483 return '(Double ${constant.toDartText()})'; |
484 } | 484 } |
485 | 485 |
486 String visitBool(BoolConstantValue constant, _) { | 486 String visitBool(BoolConstantValue constant, _) { |
487 return '(Bool ${constant.unparse()})'; | 487 return '(Bool ${constant.toDartText()})'; |
488 } | 488 } |
489 | 489 |
490 String visitString(StringConstantValue constant, _) { | 490 String visitString(StringConstantValue constant, _) { |
491 return '(String ${constant.unparse()})'; | 491 return '(String ${constant.toDartText()})'; |
492 } | 492 } |
493 | 493 |
494 String visitList(ListConstantValue constant, _) { | 494 String visitList(ListConstantValue constant, _) { |
495 String entries = | 495 String entries = |
496 constant.entries.map((entry) => entry.accept(this, _)).join(' '); | 496 constant.entries.map((entry) => entry.accept(this, _)).join(' '); |
497 return '(List $entries)'; | 497 return '(List $entries)'; |
498 } | 498 } |
499 | 499 |
500 String visitMap(MapConstantValue constant, _) { | 500 String visitMap(MapConstantValue constant, _) { |
501 List<String> elements = <String>[]; | 501 List<String> elements = <String>[]; |
502 for (int i = 0; i < constant.keys.length; ++i) { | 502 for (int i = 0; i < constant.keys.length; ++i) { |
503 ConstantValue key = constant.keys[i]; | 503 ConstantValue key = constant.keys[i]; |
504 ConstantValue value = constant.values[i]; | 504 ConstantValue value = constant.values[i]; |
505 elements.add('(${key.accept(this, _)} . ${value.accept(this, _)})'); | 505 elements.add('(${key.accept(this, _)} . ${value.accept(this, _)})'); |
506 } | 506 } |
507 return '(Map (${elements.join(' ')}))'; | 507 return '(Map (${elements.join(' ')}))'; |
508 } | 508 } |
509 | 509 |
510 String visitConstructed(ConstructedConstantValue constant, _) { | 510 String visitConstructed(ConstructedConstantValue constant, _) { |
511 return '(Constructed "${constant.unparse()}")'; | 511 return '(Constructed "${constant.toDartText()}")'; |
512 } | 512 } |
513 | 513 |
514 String visitType(TypeConstantValue constant, _) { | 514 String visitType(TypeConstantValue constant, _) { |
515 return '(Type "${constant.representedType}")'; | 515 return '(Type "${constant.representedType}")'; |
516 } | 516 } |
517 | 517 |
518 String visitInterceptor(InterceptorConstantValue constant, _) { | 518 String visitInterceptor(InterceptorConstantValue constant, _) { |
519 return '(Interceptor "${constant.unparse()}")'; | 519 return '(Interceptor "${constant.toDartText()}")'; |
520 } | 520 } |
521 | 521 |
522 String visitSynthetic(SyntheticConstantValue constant, _) { | 522 String visitSynthetic(SyntheticConstantValue constant, _) { |
523 return '(Synthetic "${constant.unparse()}")'; | 523 return '(Synthetic "${constant.toDartText()}")'; |
524 } | 524 } |
525 | 525 |
526 String visitDeferred(DeferredConstantValue constant, _) { | 526 String visitDeferred(DeferredConstantValue constant, _) { |
527 return _failWith(constant); | 527 return _failWith(constant); |
528 } | 528 } |
529 } | 529 } |
530 | 530 |
531 class _Namer { | 531 class _Namer { |
532 final Map<Node, String> _names = <Node, String>{}; | 532 final Map<Node, String> _names = <Node, String>{}; |
533 int _valueCounter = 0; | 533 int _valueCounter = 0; |
(...skipping 27 matching lines...) Expand all Loading... |
561 void setReturnContinuation(Continuation node) { | 561 void setReturnContinuation(Continuation node) { |
562 assert(!_names.containsKey(node) || _names[node] == 'return'); | 562 assert(!_names.containsKey(node) || _names[node] == 'return'); |
563 _names[node] = 'return'; | 563 _names[node] = 'return'; |
564 } | 564 } |
565 | 565 |
566 String getName(Node node) { | 566 String getName(Node node) { |
567 if (!_names.containsKey(node)) return 'MISSING_NAME'; | 567 if (!_names.containsKey(node)) return 'MISSING_NAME'; |
568 return _names[node]; | 568 return _names[node]; |
569 } | 569 } |
570 } | 570 } |
OLD | NEW |