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 Uris; | 8 import 'common/names.dart' show Uris; |
9 import 'elements/types.dart'; | 9 import 'elements/types.dart'; |
10 import 'elements/entities.dart'; | 10 import 'elements/entities.dart'; |
| 11 import 'universe/call_structure.dart'; |
11 | 12 |
12 /// The common elements and types in Dart. | 13 /// The common elements and types in Dart. |
13 abstract class CommonElements { | 14 abstract class CommonElements { |
14 /// The `Object` class defined in 'dart:core'. | 15 /// The `Object` class defined in 'dart:core'. |
15 ClassEntity get objectClass; | 16 ClassEntity get objectClass; |
16 | 17 |
17 /// The `bool` class defined in 'dart:core'. | 18 /// The `bool` class defined in 'dart:core'. |
18 ClassEntity get boolClass; | 19 ClassEntity get boolClass; |
19 | 20 |
20 /// The `num` class defined in 'dart:core'. | 21 /// The `num` class defined in 'dart:core'. |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 /// Returns the 'raw type' of [cls]. That is, the instantiation of [cls] | 278 /// Returns the 'raw type' of [cls]. That is, the instantiation of [cls] |
278 /// where all types arguments are `dynamic`. | 279 /// where all types arguments are `dynamic`. |
279 InterfaceType getRawType(ClassEntity cls); | 280 InterfaceType getRawType(ClassEntity cls); |
280 | 281 |
281 /// Returns the 'this type' of [cls]. That is, the instantiation of [cls] | 282 /// Returns the 'this type' of [cls]. That is, the instantiation of [cls] |
282 /// where the type arguments are the type variables of [cls]. | 283 /// where the type arguments are the type variables of [cls]. |
283 InterfaceType getThisType(ClassEntity cls); | 284 InterfaceType getThisType(ClassEntity cls); |
284 | 285 |
285 /// Returns `true` if [a] is a subtype of [b]. | 286 /// Returns `true` if [a] is a subtype of [b]. |
286 bool isSubtype(DartType a, DartType b); | 287 bool isSubtype(DartType a, DartType b); |
| 288 |
| 289 /// Returns the type if [function]. |
| 290 FunctionType getFunctionType(FunctionEntity function); |
| 291 |
| 292 /// Returns the [CallStructure] corresponding to calling [entity] with all |
| 293 /// arguments, both required and optional. |
| 294 CallStructure getCallStructure(FunctionEntity entity); |
| 295 |
| 296 /// Returns `true` if [member] a the synthetic getter `loadLibrary` injected |
| 297 /// on deferred libraries. |
| 298 bool isDeferredLoadLibraryGetter(MemberEntity member); |
287 } | 299 } |
288 | 300 |
289 class CommonElementsImpl implements CommonElements { | 301 class CommonElementsImpl implements CommonElements { |
290 final ElementEnvironment _env; | 302 final ElementEnvironment _env; |
291 | 303 |
292 CommonElementsImpl(this._env); | 304 CommonElementsImpl(this._env); |
293 | 305 |
294 ClassEntity findClass(LibraryEntity library, String name, | 306 ClassEntity findClass(LibraryEntity library, String name, |
295 {bool required: true}) { | 307 {bool required: true}) { |
296 if (library == null) return null; | 308 if (library == null) return null; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 } | 566 } |
555 | 567 |
556 @override | 568 @override |
557 InterfaceType streamType([DartType elementType]) { | 569 InterfaceType streamType([DartType elementType]) { |
558 if (elementType == null) { | 570 if (elementType == null) { |
559 return getRawType(streamClass); | 571 return getRawType(streamClass); |
560 } | 572 } |
561 return createInterfaceType(streamClass, [elementType]); | 573 return createInterfaceType(streamClass, [elementType]); |
562 } | 574 } |
563 } | 575 } |
OLD | NEW |