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 // TODO(sigmund): rename and move to common/elements.dart | 5 // TODO(sigmund): rename and move to common/elements.dart |
6 library dart2js.type_system; | 6 library dart2js.type_system; |
7 | 7 |
8 import 'common/names.dart' show Identifiers, Uris; | 8 import 'common/names.dart' show Identifiers, Uris; |
9 import 'js_backend/constant_system_javascript.dart'; | 9 import 'js_backend/constant_system_javascript.dart'; |
10 import 'elements/types.dart'; | 10 import 'elements/types.dart'; |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 255 |
256 /// The `Function` type defined in 'dart:core'. | 256 /// The `Function` type defined in 'dart:core'. |
257 InterfaceType get functionType => _getRawType(functionClass); | 257 InterfaceType get functionType => _getRawType(functionClass); |
258 | 258 |
259 /// The `Null` type defined in 'dart:core'. | 259 /// The `Null` type defined in 'dart:core'. |
260 InterfaceType get nullType => _getRawType(nullClass); | 260 InterfaceType get nullType => _getRawType(nullClass); |
261 | 261 |
262 /// The `Type` type defined in 'dart:core'. | 262 /// The `Type` type defined in 'dart:core'. |
263 InterfaceType get typeType => _getRawType(typeClass); | 263 InterfaceType get typeType => _getRawType(typeClass); |
264 | 264 |
| 265 InterfaceType get typeLiteralType => _getRawType(typeLiteralClass); |
| 266 |
265 /// The `StackTrace` type defined in 'dart:core'; | 267 /// The `StackTrace` type defined in 'dart:core'; |
266 InterfaceType get stackTraceType => _getRawType(stackTraceClass); | 268 InterfaceType get stackTraceType => _getRawType(stackTraceClass); |
267 | 269 |
268 /// Returns an instance of the `List` type defined in 'dart:core' with | 270 /// Returns an instance of the `List` type defined in 'dart:core' with |
269 /// [elementType] as its type argument. | 271 /// [elementType] as its type argument. |
270 /// | 272 /// |
271 /// If no type argument is provided, the canonical raw type is returned. | 273 /// If no type argument is provided, the canonical raw type is returned. |
272 InterfaceType listType([DartType elementType]) { | 274 InterfaceType listType([DartType elementType]) { |
273 if (elementType == null) { | 275 if (elementType == null) { |
274 return _getRawType(listClass); | 276 return _getRawType(listClass); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 InterfaceType _getRawType(ClassEntity cls) { | 371 InterfaceType _getRawType(ClassEntity cls) { |
370 return _env.getRawType(cls); | 372 return _env.getRawType(cls); |
371 } | 373 } |
372 | 374 |
373 /// Create the instantiation of [cls] with the given [typeArguments]. | 375 /// Create the instantiation of [cls] with the given [typeArguments]. |
374 InterfaceType _createInterfaceType( | 376 InterfaceType _createInterfaceType( |
375 ClassEntity cls, List<DartType> typeArguments) { | 377 ClassEntity cls, List<DartType> typeArguments) { |
376 return _env.createInterfaceType(cls, typeArguments); | 378 return _env.createInterfaceType(cls, typeArguments); |
377 } | 379 } |
378 | 380 |
| 381 InterfaceType getConstantMapTypeFor(InterfaceType sourceType, |
| 382 {bool hasProtoKey: false, bool onlyStringKeys: false}) { |
| 383 ClassEntity classElement = onlyStringKeys |
| 384 ? (hasProtoKey ? constantProtoMapClass : constantStringMapClass) |
| 385 : generalConstantMapClass; |
| 386 List<DartType> typeArgument = sourceType.typeArguments; |
| 387 if (sourceType.treatAsRaw) { |
| 388 return _env.getRawType(classElement); |
| 389 } else { |
| 390 return _env.createInterfaceType(classElement, typeArgument); |
| 391 } |
| 392 } |
| 393 |
| 394 FieldEntity get symbolField => symbolImplementationField; |
| 395 |
| 396 InterfaceType get symbolImplementationType => |
| 397 _env.getRawType(symbolImplementationClass); |
| 398 |
| 399 bool isDefaultEqualityImplementation(MemberEntity element) { |
| 400 assert(element.name == '=='); |
| 401 ClassEntity classElement = element.enclosingClass; |
| 402 return classElement == objectClass || |
| 403 classElement == jsInterceptorClass || |
| 404 classElement == jsNullClass; |
| 405 } |
| 406 |
379 // From dart:core | 407 // From dart:core |
380 FunctionEntity get malformedTypeError => | 408 FunctionEntity get malformedTypeError => |
381 _cachedCoreHelper('_malformedTypeError'); | 409 _cachedCoreHelper('_malformedTypeError'); |
382 FunctionEntity get genericNoSuchMethod => | 410 FunctionEntity get genericNoSuchMethod => |
383 _cachedCoreHelper('_genericNoSuchMethod'); | 411 _cachedCoreHelper('_genericNoSuchMethod'); |
384 FunctionEntity get unresolvedConstructorError => | 412 FunctionEntity get unresolvedConstructorError => |
385 _cachedCoreHelper('_unresolvedConstructorError'); | 413 _cachedCoreHelper('_unresolvedConstructorError'); |
386 FunctionEntity get unresolvedStaticGetterError => | 414 FunctionEntity get unresolvedStaticGetterError => |
387 _cachedCoreHelper('_unresolvedStaticGetterError'); | 415 _cachedCoreHelper('_unresolvedStaticGetterError'); |
388 FunctionEntity get unresolvedStaticSetterError => | 416 FunctionEntity get unresolvedStaticSetterError => |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 DartType getUnaliasedType(DartType type); | 1191 DartType getUnaliasedType(DartType type); |
1164 | 1192 |
1165 /// Returns the [CallStructure] corresponding to calling [entity] with all | 1193 /// Returns the [CallStructure] corresponding to calling [entity] with all |
1166 /// arguments, both required and optional. | 1194 /// arguments, both required and optional. |
1167 CallStructure getCallStructure(FunctionEntity entity); | 1195 CallStructure getCallStructure(FunctionEntity entity); |
1168 | 1196 |
1169 /// Returns `true` if [member] a the synthetic getter `loadLibrary` injected | 1197 /// Returns `true` if [member] a the synthetic getter `loadLibrary` injected |
1170 /// on deferred libraries. | 1198 /// on deferred libraries. |
1171 bool isDeferredLoadLibraryGetter(MemberEntity member); | 1199 bool isDeferredLoadLibraryGetter(MemberEntity member); |
1172 } | 1200 } |
OLD | NEW |