| 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 /** | 5 /** |
| 6 * The implementation of the class [DartObject]. | 6 * The implementation of the class [DartObject]. |
| 7 */ | 7 */ |
| 8 library analyzer.src.dart.constant.value; | 8 library analyzer.src.dart.constant.value; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 if (state is SymbolState) { | 713 if (state is SymbolState) { |
| 714 return state.value; | 714 return state.value; |
| 715 } | 715 } |
| 716 return null; | 716 return null; |
| 717 } | 717 } |
| 718 | 718 |
| 719 @override | 719 @override |
| 720 DartType toTypeValue() { | 720 DartType toTypeValue() { |
| 721 InstanceState state = _state; | 721 InstanceState state = _state; |
| 722 if (state is TypeState) { | 722 if (state is TypeState) { |
| 723 return state._type; | 723 Element element = state._element; |
| 724 if (element is TypeDefiningElement) { |
| 725 return element.type; |
| 726 } |
| 724 } | 727 } |
| 725 return null; | 728 return null; |
| 726 } | 729 } |
| 727 } | 730 } |
| 728 | 731 |
| 729 /** | 732 /** |
| 730 * The state of an object representing a double. | 733 * The state of an object representing a double. |
| 731 */ | 734 */ |
| 732 class DoubleState extends NumState { | 735 class DoubleState extends NumState { |
| 733 /** | 736 /** |
| (...skipping 2027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2761 String toString() => value == null ? "-unknown-" : "#$value"; | 2764 String toString() => value == null ? "-unknown-" : "#$value"; |
| 2762 } | 2765 } |
| 2763 | 2766 |
| 2764 /** | 2767 /** |
| 2765 * The state of an object representing a type. | 2768 * The state of an object representing a type. |
| 2766 */ | 2769 */ |
| 2767 class TypeState extends InstanceState { | 2770 class TypeState extends InstanceState { |
| 2768 /** | 2771 /** |
| 2769 * The element representing the type being modeled. | 2772 * The element representing the type being modeled. |
| 2770 */ | 2773 */ |
| 2771 final DartType _type; | 2774 final Element _element; |
| 2772 | 2775 |
| 2773 /** | 2776 /** |
| 2774 * Initialize a newly created state to represent the given [value]. | 2777 * Initialize a newly created state to represent the given [value]. |
| 2775 */ | 2778 */ |
| 2776 TypeState(this._type); | 2779 TypeState(this._element); |
| 2777 | 2780 |
| 2778 @override | 2781 @override |
| 2779 int get hashCode => _type?.hashCode ?? 0; | 2782 int get hashCode => _element == null ? 0 : _element.hashCode; |
| 2780 | 2783 |
| 2781 @override | 2784 @override |
| 2782 String get typeName => "Type"; | 2785 String get typeName => "Type"; |
| 2783 | 2786 |
| 2784 @override | 2787 @override |
| 2785 bool operator ==(Object object) => | 2788 bool operator ==(Object object) => |
| 2786 object is TypeState && (_type == object._type); | 2789 object is TypeState && (_element == object._element); |
| 2787 | 2790 |
| 2788 @override | 2791 @override |
| 2789 StringState convertToString() { | 2792 StringState convertToString() { |
| 2790 if (_type == null) { | 2793 if (_element == null) { |
| 2791 return StringState.UNKNOWN_VALUE; | 2794 return StringState.UNKNOWN_VALUE; |
| 2792 } | 2795 } |
| 2793 return new StringState(_type.displayName); | 2796 return new StringState(_element.name); |
| 2794 } | 2797 } |
| 2795 | 2798 |
| 2796 @override | 2799 @override |
| 2797 BoolState equalEqual(InstanceState rightOperand) { | 2800 BoolState equalEqual(InstanceState rightOperand) { |
| 2798 assertBoolNumStringOrNull(rightOperand); | 2801 assertBoolNumStringOrNull(rightOperand); |
| 2799 return isIdentical(rightOperand); | 2802 return isIdentical(rightOperand); |
| 2800 } | 2803 } |
| 2801 | 2804 |
| 2802 @override | 2805 @override |
| 2803 BoolState isIdentical(InstanceState rightOperand) { | 2806 BoolState isIdentical(InstanceState rightOperand) { |
| 2804 if (_type == null) { | 2807 if (_element == null) { |
| 2805 return BoolState.UNKNOWN_VALUE; | 2808 return BoolState.UNKNOWN_VALUE; |
| 2806 } | 2809 } |
| 2807 if (rightOperand is TypeState) { | 2810 if (rightOperand is TypeState) { |
| 2808 DartType rightType = rightOperand._type; | 2811 Element rightElement = rightOperand._element; |
| 2809 if (rightType == null) { | 2812 if (rightElement == null) { |
| 2810 return BoolState.UNKNOWN_VALUE; | 2813 return BoolState.UNKNOWN_VALUE; |
| 2811 } | 2814 } |
| 2812 return BoolState.from(_type == rightType); | 2815 return BoolState.from(_element == rightElement); |
| 2813 } else if (rightOperand is DynamicState) { | 2816 } else if (rightOperand is DynamicState) { |
| 2814 return BoolState.UNKNOWN_VALUE; | 2817 return BoolState.UNKNOWN_VALUE; |
| 2815 } | 2818 } |
| 2816 return BoolState.FALSE_STATE; | 2819 return BoolState.FALSE_STATE; |
| 2817 } | 2820 } |
| 2818 | 2821 |
| 2819 @override | 2822 @override |
| 2820 String toString() => _type?.toString() ?? "-unknown-"; | 2823 String toString() => _element == null ? "-unknown-" : _element.name; |
| 2821 } | 2824 } |
| OLD | NEW |