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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 /** | 138 /** |
139 * A representation of an instance of a Dart class. | 139 * A representation of an instance of a Dart class. |
140 */ | 140 */ |
141 class DartObjectImpl implements DartObject { | 141 class DartObjectImpl implements DartObject { |
142 /** | 142 /** |
143 * An empty list of objects. | 143 * An empty list of objects. |
144 */ | 144 */ |
145 static const List<DartObjectImpl> EMPTY_LIST = const <DartObjectImpl>[]; | 145 static const List<DartObjectImpl> EMPTY_LIST = const <DartObjectImpl>[]; |
146 | 146 |
147 /** | |
148 * The run-time type of this object. | |
149 */ | |
150 @override | 147 @override |
151 final ParameterizedType type; | 148 final ParameterizedType type; |
152 | 149 |
153 /** | 150 /** |
154 * The state of the object. | 151 * The state of the object. |
155 */ | 152 */ |
156 final InstanceState _state; | 153 final InstanceState _state; |
157 | 154 |
158 /** | 155 /** |
159 * Initialize a newly created object to have the given [type] and [_state]. | 156 * Initialize a newly created object to have the given [type] and [_state]. |
160 */ | 157 */ |
161 DartObjectImpl(this.type, this._state); | 158 DartObjectImpl(this.type, this._state); |
162 | 159 |
163 /** | 160 /** |
164 * Create an object to represent an unknown value. | 161 * Create an object to represent an unknown value. |
165 */ | 162 */ |
166 factory DartObjectImpl.validWithUnknownValue(InterfaceType type) { | 163 factory DartObjectImpl.validWithUnknownValue(ParameterizedType type) { |
167 if (type.element.library.isDartCore) { | 164 if (type.element.library.isDartCore) { |
168 String typeName = type.name; | 165 String typeName = type.name; |
169 if (typeName == "bool") { | 166 if (typeName == "bool") { |
170 return new DartObjectImpl(type, BoolState.UNKNOWN_VALUE); | 167 return new DartObjectImpl(type, BoolState.UNKNOWN_VALUE); |
171 } else if (typeName == "double") { | 168 } else if (typeName == "double") { |
172 return new DartObjectImpl(type, DoubleState.UNKNOWN_VALUE); | 169 return new DartObjectImpl(type, DoubleState.UNKNOWN_VALUE); |
173 } else if (typeName == "int") { | 170 } else if (typeName == "int") { |
174 return new DartObjectImpl(type, IntState.UNKNOWN_VALUE); | 171 return new DartObjectImpl(type, IntState.UNKNOWN_VALUE); |
175 } else if (typeName == "String") { | 172 } else if (typeName == "String") { |
176 return new DartObjectImpl(type, StringState.UNKNOWN_VALUE); | 173 return new DartObjectImpl(type, StringState.UNKNOWN_VALUE); |
(...skipping 2634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2811 return BoolState.from(_type == rightType); | 2808 return BoolState.from(_type == rightType); |
2812 } else if (rightOperand is DynamicState) { | 2809 } else if (rightOperand is DynamicState) { |
2813 return BoolState.UNKNOWN_VALUE; | 2810 return BoolState.UNKNOWN_VALUE; |
2814 } | 2811 } |
2815 return BoolState.FALSE_STATE; | 2812 return BoolState.FALSE_STATE; |
2816 } | 2813 } |
2817 | 2814 |
2818 @override | 2815 @override |
2819 String toString() => _type?.toString() ?? "-unknown-"; | 2816 String toString() => _type?.toString() ?? "-unknown-"; |
2820 } | 2817 } |
OLD | NEW |