| 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'; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 // TODO(johnniwinther): Split this into an element environment and a type query | 214 // TODO(johnniwinther): Split this into an element environment and a type query |
| 215 // interface, the first should only be used during resolution and the latter in | 215 // interface, the first should only be used during resolution and the latter in |
| 216 // both resolution and codegen. | 216 // both resolution and codegen. |
| 217 abstract class ElementEnvironment { | 217 abstract class ElementEnvironment { |
| 218 /// Returns the main library for the compilation. | 218 /// Returns the main library for the compilation. |
| 219 LibraryEntity get mainLibrary; | 219 LibraryEntity get mainLibrary; |
| 220 | 220 |
| 221 /// Returns the main method for the compilation. | 221 /// Returns the main method for the compilation. |
| 222 FunctionEntity get mainFunction; | 222 FunctionEntity get mainFunction; |
| 223 | 223 |
| 224 /// Returns all known libraries. |
| 225 Iterable<LibraryEntity> get libraries; |
| 226 |
| 224 /// Lookup the library with the canonical [uri], fail if the library is | 227 /// Lookup the library with the canonical [uri], fail if the library is |
| 225 /// missing and [required]; | 228 /// missing and [required]; |
| 226 LibraryEntity lookupLibrary(Uri uri, {bool required: false}); | 229 LibraryEntity lookupLibrary(Uri uri, {bool required: false}); |
| 227 | 230 |
| 228 /// Lookup the class [name] in [library], fail if the class is missing and | 231 /// Lookup the class [name] in [library], fail if the class is missing and |
| 229 /// [required]. | 232 /// [required]. |
| 230 ClassEntity lookupClass(LibraryEntity library, String name, | 233 ClassEntity lookupClass(LibraryEntity library, String name, |
| 231 {bool required: false}); | 234 {bool required: false}); |
| 232 | 235 |
| 233 /// Lookup the member [name] in [library], fail if the class is missing and | 236 /// Lookup the member [name] in [library], fail if the class is missing and |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 | 422 |
| 420 ClassEntity _mapClass; | 423 ClassEntity _mapClass; |
| 421 ClassEntity get mapClass => _mapClass ??= findClass(coreLibrary, 'Map'); | 424 ClassEntity get mapClass => _mapClass ??= findClass(coreLibrary, 'Map'); |
| 422 | 425 |
| 423 ClassEntity _symbolClass; | 426 ClassEntity _symbolClass; |
| 424 ClassEntity get symbolClass => | 427 ClassEntity get symbolClass => |
| 425 _symbolClass ??= findClass(coreLibrary, 'Symbol'); | 428 _symbolClass ??= findClass(coreLibrary, 'Symbol'); |
| 426 | 429 |
| 427 ConstructorEntity _symbolConstructor; | 430 ConstructorEntity _symbolConstructor; |
| 428 ConstructorEntity get symbolConstructor => | 431 ConstructorEntity get symbolConstructor => |
| 429 _symbolConstructor ??= findConstructor(symbolClass, ''); | 432 // TODO(johnniwinther): Kernel does not include redirecting factories |
| 433 // so this cannot be found in kernel. Find a consistent way to handle |
| 434 // this and similar cases. |
| 435 _symbolConstructor ??= findConstructor(symbolClass, '', required: false); |
| 430 | 436 |
| 431 bool isSymbolConstructor(Entity e) => e == symbolConstructor; | 437 bool isSymbolConstructor(Entity e) => e == symbolConstructor; |
| 432 | 438 |
| 433 ClassEntity _stackTraceClass; | 439 ClassEntity _stackTraceClass; |
| 434 ClassEntity get stackTraceClass => | 440 ClassEntity get stackTraceClass => |
| 435 _stackTraceClass ??= findClass(coreLibrary, 'StackTrace'); | 441 _stackTraceClass ??= findClass(coreLibrary, 'StackTrace'); |
| 436 | 442 |
| 437 ClassEntity _iterableClass; | 443 ClassEntity _iterableClass; |
| 438 ClassEntity get iterableClass => | 444 ClassEntity get iterableClass => |
| 439 _iterableClass ??= findClass(coreLibrary, 'Iterable'); | 445 _iterableClass ??= findClass(coreLibrary, 'Iterable'); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 } | 590 } |
| 585 | 591 |
| 586 @override | 592 @override |
| 587 InterfaceType streamType([DartType elementType]) { | 593 InterfaceType streamType([DartType elementType]) { |
| 588 if (elementType == null) { | 594 if (elementType == null) { |
| 589 return getRawType(streamClass); | 595 return getRawType(streamClass); |
| 590 } | 596 } |
| 591 return createInterfaceType(streamClass, [elementType]); | 597 return createInterfaceType(streamClass, [elementType]); |
| 592 } | 598 } |
| 593 } | 599 } |
| OLD | NEW |