OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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.constants.values; | 5 library dart2js.constants.values; |
6 | 6 |
7 import '../core_types.dart'; | 7 import '../core_types.dart'; |
8 import '../dart_types.dart'; | 8 import '../dart_types.dart'; |
9 import '../dart2jslib.dart' | 9 import '../dart2jslib.dart' |
10 show assertDebugMode; | 10 show assertDebugMode; |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
596 | 596 |
597 String unparse() { | 597 String unparse() { |
598 return 'interceptor($dispatchedType)'; | 598 return 'interceptor($dispatchedType)'; |
599 } | 599 } |
600 | 600 |
601 String toStructuredString() { | 601 String toStructuredString() { |
602 return 'InterceptorConstant(${dispatchedType.getStringAsDeclared("o")})'; | 602 return 'InterceptorConstant(${dispatchedType.getStringAsDeclared("o")})'; |
603 } | 603 } |
604 } | 604 } |
605 | 605 |
606 // TODO(johnniwinther): Remove this class. | |
607 class DummyConstantValue extends ConstantValue { | 606 class DummyConstantValue extends ConstantValue { |
Johnni Winther
2015/05/28 12:07:17
Rename to SyntheticConstantValue, ForeignConstantV
herhut
2015/06/01 12:09:41
I went for SyntheticConstantValue.
| |
608 final ti.TypeMask typeMask; | 607 final payload; |
sra1
2015/05/27 19:38:50
TL;DR: should this class be split into 2 to 3 clas
herhut
2015/06/01 12:09:41
The idea is that these constants are opaque to the
| |
608 final String kind; | |
609 | 609 |
610 DummyConstantValue(this.typeMask); | 610 DummyConstantValue(this.kind, this.payload); |
611 | 611 |
612 bool get isDummy => true; | 612 bool get isDummy => true; |
613 | 613 |
614 bool operator ==(other) { | 614 bool operator ==(other) { |
615 return other is DummyConstantValue | 615 return other is DummyConstantValue |
616 && typeMask == other.typeMask; | 616 && payload == other.payload; |
617 } | 617 } |
618 | 618 |
619 get hashCode => typeMask.hashCode; | 619 get hashCode => payload.hashCode; |
620 | 620 |
621 List<ConstantValue> getDependencies() => const <ConstantValue>[]; | 621 List<ConstantValue> getDependencies() => const <ConstantValue>[]; |
622 | 622 |
623 accept(ConstantValueVisitor visitor, arg) => visitor.visitDummy(this, arg); | 623 accept(ConstantValueVisitor visitor, arg) => visitor.visitDummy(this, arg); |
624 | 624 |
625 DartType getType(CoreTypes types) => const DynamicType(); | 625 DartType getType(CoreTypes types) => const DynamicType(); |
626 | 626 |
627 String unparse() => 'dummy($typeMask)'; | 627 String unparse() => 'dummy($kind, $payload)'; |
628 | 628 |
629 String toStructuredString() => 'DummyConstant($typeMask)'; | 629 String toStructuredString() => 'DummyConstant($kind, $payload)'; |
630 } | 630 } |
631 | 631 |
632 class ConstructedConstantValue extends ObjectConstantValue { | 632 class ConstructedConstantValue extends ObjectConstantValue { |
633 final Map<FieldElement, ConstantValue> fields; | 633 final Map<FieldElement, ConstantValue> fields; |
634 final int hashCode; | 634 final int hashCode; |
635 | 635 |
636 ConstructedConstantValue(InterfaceType type, | 636 ConstructedConstantValue(InterfaceType type, |
637 Map<FieldElement, ConstantValue> fields) | 637 Map<FieldElement, ConstantValue> fields) |
638 : this.fields = fields, | 638 : this.fields = fields, |
639 hashCode = Hashing.mapHash(fields, Hashing.objectHash(type)), | 639 hashCode = Hashing.mapHash(fields, Hashing.objectHash(type)), |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
741 | 741 |
742 @override | 742 @override |
743 DartType getType(CoreTypes types) => const DynamicType(); | 743 DartType getType(CoreTypes types) => const DynamicType(); |
744 | 744 |
745 @override | 745 @override |
746 String toStructuredString() => 'NonConstant'; | 746 String toStructuredString() => 'NonConstant'; |
747 | 747 |
748 @override | 748 @override |
749 String unparse() => '>>non-constant<<'; | 749 String unparse() => '>>non-constant<<'; |
750 } | 750 } |
OLD | NEW |