Index: pkg/compiler/lib/src/common_elements.dart |
diff --git a/pkg/compiler/lib/src/common_elements.dart b/pkg/compiler/lib/src/common_elements.dart |
index b5af19e42c4fb506617193350b41d71ff6cef49a..b5f615169f6ade11b40ae177d6ab2eade2fd0d0a 100644 |
--- a/pkg/compiler/lib/src/common_elements.dart |
+++ b/pkg/compiler/lib/src/common_elements.dart |
@@ -5,206 +5,1058 @@ |
// TODO(sigmund): rename and move to common/elements.dart |
library dart2js.type_system; |
-import 'common/names.dart' show Uris; |
+import 'common/names.dart' show Identifiers, Uris; |
+import 'js_backend/constant_system_javascript.dart'; |
import 'elements/types.dart'; |
+import 'elements/elements.dart' show PublicName; |
import 'elements/entities.dart'; |
+import 'js_backend/backend.dart' show JavaScriptBackend; |
+import 'universe/call_structure.dart' show CallStructure; |
+import 'universe/selector.dart' show Selector; |
import 'universe/call_structure.dart'; |
/// The common elements and types in Dart. |
-abstract class CommonElements { |
+class CommonElements { |
+ final ElementEnvironment _env; |
+ |
+ CommonElements(this._env); |
+ |
/// The `Object` class defined in 'dart:core'. |
- ClassEntity get objectClass; |
+ ClassEntity _objectClass; |
+ ClassEntity get objectClass => |
+ _objectClass ??= _findClass(coreLibrary, 'Object'); |
/// The `bool` class defined in 'dart:core'. |
- ClassEntity get boolClass; |
+ ClassEntity _boolClass; |
+ ClassEntity get boolClass => _boolClass ??= _findClass(coreLibrary, 'bool'); |
/// The `num` class defined in 'dart:core'. |
- ClassEntity get numClass; |
+ ClassEntity _numClass; |
+ ClassEntity get numClass => _numClass ??= _findClass(coreLibrary, 'num'); |
/// The `int` class defined in 'dart:core'. |
- ClassEntity get intClass; |
+ ClassEntity _intClass; |
+ ClassEntity get intClass => _intClass ??= _findClass(coreLibrary, 'int'); |
/// The `double` class defined in 'dart:core'. |
- ClassEntity get doubleClass; |
- |
- /// The `Resource` class defined in 'dart:core'. |
- ClassEntity get resourceClass; |
+ ClassEntity _doubleClass; |
+ ClassEntity get doubleClass => |
+ _doubleClass ??= _findClass(coreLibrary, 'double'); |
/// The `String` class defined in 'dart:core'. |
- ClassEntity get stringClass; |
- |
- /// The `Symbol` class defined in 'dart:core'. |
- ClassEntity get symbolClass; |
+ ClassEntity _stringClass; |
+ ClassEntity get stringClass => |
+ _stringClass ??= _findClass(coreLibrary, 'String'); |
/// The `Function` class defined in 'dart:core'. |
- ClassEntity get functionClass; |
+ ClassEntity _functionClass; |
+ ClassEntity get functionClass => |
+ _functionClass ??= _findClass(coreLibrary, 'Function'); |
+ |
+ /// The `Resource` class defined in 'dart:core'. |
+ ClassEntity _resourceClass; |
+ ClassEntity get resourceClass => |
+ _resourceClass ??= _findClass(coreLibrary, 'Resource'); |
+ |
+ /// The `Symbol` class defined in 'dart:core'. |
+ ClassEntity _symbolClass; |
+ ClassEntity get symbolClass => |
+ _symbolClass ??= _findClass(coreLibrary, 'Symbol'); |
/// The `Null` class defined in 'dart:core'. |
- ClassEntity get nullClass; |
+ ClassEntity _nullClass; |
+ ClassEntity get nullClass => _nullClass ??= _findClass(coreLibrary, 'Null'); |
/// The `Type` class defined in 'dart:core'. |
- ClassEntity get typeClass; |
+ ClassEntity _typeClass; |
+ ClassEntity get typeClass => _typeClass ??= _findClass(coreLibrary, 'Type'); |
/// The `StackTrace` class defined in 'dart:core'; |
- ClassEntity get stackTraceClass; |
+ ClassEntity _stackTraceClass; |
+ ClassEntity get stackTraceClass => |
+ _stackTraceClass ??= _findClass(coreLibrary, 'StackTrace'); |
/// The `List` class defined in 'dart:core'; |
- ClassEntity get listClass; |
+ ClassEntity _listClass; |
+ ClassEntity get listClass => _listClass ??= _findClass(coreLibrary, 'List'); |
/// The `Map` class defined in 'dart:core'; |
- ClassEntity get mapClass; |
+ ClassEntity _mapClass; |
+ ClassEntity get mapClass => _mapClass ??= _findClass(coreLibrary, 'Map'); |
/// The `Iterable` class defined in 'dart:core'; |
- ClassEntity get iterableClass; |
+ ClassEntity _iterableClass; |
+ ClassEntity get iterableClass => |
+ _iterableClass ??= _findClass(coreLibrary, 'Iterable'); |
/// The `Future` class defined in 'async';. |
- ClassEntity get futureClass; |
+ ClassEntity _futureClass; |
+ ClassEntity get futureClass => |
+ _futureClass ??= _findClass(asyncLibrary, 'Future'); |
/// The `Stream` class defined in 'async'; |
- ClassEntity get streamClass; |
+ ClassEntity _streamClass; |
+ ClassEntity get streamClass => |
+ _streamClass ??= _findClass(asyncLibrary, 'Stream'); |
/// The dart:core library. |
- LibraryEntity get coreLibrary; |
+ LibraryEntity _coreLibrary; |
+ LibraryEntity get coreLibrary => |
+ _coreLibrary ??= _env.lookupLibrary(Uris.dart_core, required: true); |
/// The dart:async library. |
- LibraryEntity get asyncLibrary; |
+ LibraryEntity _asyncLibrary; |
+ LibraryEntity get asyncLibrary => |
+ _asyncLibrary ??= _env.lookupLibrary(Uris.dart_async); |
/// The dart:mirrors library. Null if the program doesn't access dart:mirrors. |
- LibraryEntity get mirrorsLibrary; |
+ LibraryEntity _mirrorsLibrary; |
+ LibraryEntity get mirrorsLibrary => |
+ _mirrorsLibrary ??= _env.lookupLibrary(Uris.dart_mirrors); |
/// The dart:typed_data library. |
- LibraryEntity get typedDataLibrary; |
+ LibraryEntity _typedDataLibrary; |
+ LibraryEntity get typedDataLibrary => |
+ _typedDataLibrary ??= _env.lookupLibrary(Uris.dart__native_typed_data); |
+ |
+ LibraryEntity _jsHelperLibrary; |
+ LibraryEntity get jsHelperLibrary => |
+ _jsHelperLibrary ??= _env.lookupLibrary(Uris.dart__js_helper); |
+ |
+ LibraryEntity _interceptorsLibrary; |
+ LibraryEntity get interceptorsLibrary => |
+ _interceptorsLibrary ??= _env.lookupLibrary(Uris.dart__interceptors); |
+ |
+ LibraryEntity _foreignLibrary; |
+ LibraryEntity get foreignLibrary => |
+ _foreignLibrary ??= _env.lookupLibrary(Uris.dart__foreign_helper); |
+ |
+ LibraryEntity _isolateHelperLibrary; |
+ LibraryEntity get isolateHelperLibrary => |
+ _isolateHelperLibrary ??= _env.lookupLibrary(Uris.dart__isolate_helper); |
+ |
+ /// Reference to the internal library to lookup functions to always inline. |
+ LibraryEntity _internalLibrary; |
+ LibraryEntity get internalLibrary => |
+ _internalLibrary ??= _env.lookupLibrary(Uris.dart__internal); |
/// The `NativeTypedData` class from dart:typed_data. |
- ClassEntity get typedDataClass; |
+ ClassEntity _typedDataClass; |
+ ClassEntity get typedDataClass => |
+ _typedDataClass ??= _findClass(typedDataLibrary, 'NativeTypedData'); |
/// Constructor of the `Symbol` class. This getter will ensure that `Symbol` |
/// is resolved and lookup the constructor on demand. |
- ConstructorEntity get symbolConstructor; |
+ ConstructorEntity _symbolConstructor; |
+ ConstructorEntity get symbolConstructor => |
+ // TODO(johnniwinther): Kernel does not include redirecting factories |
+ // so this cannot be found in kernel. Find a consistent way to handle |
+ // this and similar cases. |
+ _symbolConstructor ??= _findConstructor(symbolClass, '', required: false); |
/// Whether [element] is the same as [symbolConstructor]. Used to check |
/// for the constructor without computing it until it is likely to be seen. |
// TODO(johnniwinther): Change type of [e] to [MemberEntity]. |
- bool isSymbolConstructor(Entity e); |
+ bool isSymbolConstructor(Entity e) => e == symbolConstructor; |
/// The `MirrorSystem` class in dart:mirrors. |
- ClassEntity get mirrorSystemClass; |
+ ClassEntity _mirrorSystemClass; |
+ ClassEntity get mirrorSystemClass => _mirrorSystemClass ??= |
+ _findClass(mirrorsLibrary, 'MirrorSystem', required: false); |
/// Whether [element] is `MirrorClass.getName`. Used to check for the use of |
/// that static method without forcing the resolution of the `MirrorSystem` |
/// class until it is necessary. |
- bool isMirrorSystemGetNameFunction(MemberEntity element); |
+ FunctionEntity _mirrorSystemGetNameFunction; |
+ bool isMirrorSystemGetNameFunction(MemberEntity element) { |
+ if (_mirrorSystemGetNameFunction == null) { |
+ if (!element.isFunction || mirrorsLibrary == null) return false; |
+ ClassEntity cls = mirrorSystemClass; |
+ if (element.enclosingClass != cls) return false; |
+ if (cls != null) { |
+ _mirrorSystemGetNameFunction = |
+ _findClassMember(cls, 'getName', required: false); |
+ } |
+ } |
+ return element == _mirrorSystemGetNameFunction; |
+ } |
/// The `MirrorsUsed` annotation in dart:mirrors. |
- ClassEntity get mirrorsUsedClass; |
+ ClassEntity _mirrorsUsedClass; |
+ ClassEntity get mirrorsUsedClass => _mirrorsUsedClass ??= |
+ _findClass(mirrorsLibrary, 'MirrorsUsed', required: false); |
/// Whether [element] is the constructor of the `MirrorsUsed` class. Used to |
/// check for the constructor without forcing the resolution of the |
/// `MirrorsUsed` class until it is necessary. |
- bool isMirrorsUsedConstructor(ConstructorEntity element); |
+ bool isMirrorsUsedConstructor(ConstructorEntity element) => |
+ mirrorsLibrary != null && mirrorsUsedClass == element.enclosingClass; |
/// The `DeferredLibrary` annotation in dart:async that was used before the |
/// deferred import syntax was introduced. |
// TODO(sigmund): drop support for this old syntax? |
- ClassEntity get deferredLibraryClass; |
+ ClassEntity _deferredLibraryClass; |
+ ClassEntity get deferredLibraryClass => |
+ _deferredLibraryClass ??= _findClass(asyncLibrary, "DeferredLibrary"); |
/// The function `identical` in dart:core. |
- FunctionEntity get identicalFunction; |
+ FunctionEntity _identicalFunction; |
+ FunctionEntity get identicalFunction => |
+ _identicalFunction ??= _findLibraryMember(coreLibrary, 'identical'); |
/// The method `Function.apply`. |
- FunctionEntity get functionApplyMethod; |
+ FunctionEntity _functionApplyMethod; |
+ FunctionEntity get functionApplyMethod => |
+ _functionApplyMethod ??= _findClassMember(functionClass, 'apply'); |
/// Whether [element] is the same as [functionApplyMethod]. This will not |
/// resolve the apply method if it hasn't been seen yet during compilation. |
- bool isFunctionApplyMethod(MemberEntity element); |
+ bool isFunctionApplyMethod(MemberEntity element) => |
+ element.name == 'apply' && element.enclosingClass == functionClass; |
/// Returns `true` if [element] is the unnamed constructor of `List`. This |
/// will not resolve the constructor if it hasn't been seen yet during |
/// compilation. |
- bool isUnnamedListConstructor(ConstructorEntity element); |
+ bool isUnnamedListConstructor(ConstructorEntity element) => |
+ element.name == '' && element.enclosingClass == listClass; |
/// Returns `true` if [element] is the 'filled' constructor of `List`. This |
/// will not resolve the constructor if it hasn't been seen yet during |
/// compilation. |
- bool isFilledListConstructor(ConstructorEntity element); |
+ bool isFilledListConstructor(ConstructorEntity element) => |
+ element.name == 'filled' && element.enclosingClass == listClass; |
/// The `dynamic` type. |
- DynamicType get dynamicType; |
+ DynamicType get dynamicType => _env.dynamicType; |
/// The `Object` type defined in 'dart:core'. |
- InterfaceType get objectType; |
+ InterfaceType get objectType => _getRawType(objectClass); |
/// The `bool` type defined in 'dart:core'. |
- InterfaceType get boolType; |
+ InterfaceType get boolType => _getRawType(boolClass); |
/// The `num` type defined in 'dart:core'. |
- InterfaceType get numType; |
+ InterfaceType get numType => _getRawType(numClass); |
/// The `int` type defined in 'dart:core'. |
- InterfaceType get intType; |
+ InterfaceType get intType => _getRawType(intClass); |
/// The `double` type defined in 'dart:core'. |
- InterfaceType get doubleType; |
+ InterfaceType get doubleType => _getRawType(doubleClass); |
/// The `Resource` type defined in 'dart:core'. |
- InterfaceType get resourceType; |
+ InterfaceType get resourceType => _getRawType(resourceClass); |
/// The `String` type defined in 'dart:core'. |
- InterfaceType get stringType; |
+ InterfaceType get stringType => _getRawType(stringClass); |
/// The `Symbol` type defined in 'dart:core'. |
- InterfaceType get symbolType; |
+ InterfaceType get symbolType => _getRawType(symbolClass); |
/// The `Function` type defined in 'dart:core'. |
- InterfaceType get functionType; |
+ InterfaceType get functionType => _getRawType(functionClass); |
/// The `Null` type defined in 'dart:core'. |
- InterfaceType get nullType; |
+ InterfaceType get nullType => _getRawType(nullClass); |
/// The `Type` type defined in 'dart:core'. |
- InterfaceType get typeType; |
+ InterfaceType get typeType => _getRawType(typeClass); |
/// The `StackTrace` type defined in 'dart:core'; |
- InterfaceType get stackTraceType; |
+ InterfaceType get stackTraceType => _getRawType(stackTraceClass); |
/// Returns an instance of the `List` type defined in 'dart:core' with |
/// [elementType] as its type argument. |
/// |
/// If no type argument is provided, the canonical raw type is returned. |
- InterfaceType listType([DartType elementType]); |
+ InterfaceType listType([DartType elementType]) { |
+ if (elementType == null) { |
+ return _getRawType(listClass); |
+ } |
+ return _createInterfaceType(listClass, [elementType]); |
+ } |
/// Returns an instance of the `Map` type defined in 'dart:core' with |
/// [keyType] and [valueType] as its type arguments. |
/// |
/// If no type arguments are provided, the canonical raw type is returned. |
- InterfaceType mapType([DartType keyType, DartType valueType]); |
+ InterfaceType mapType([DartType keyType, DartType valueType]) { |
+ if (keyType == null && valueType == null) { |
+ return _getRawType(mapClass); |
+ } else if (keyType == null) { |
+ keyType = dynamicType; |
+ } else if (valueType == null) { |
+ valueType = dynamicType; |
+ } |
+ return _createInterfaceType(mapClass, [keyType, valueType]); |
+ } |
/// Returns an instance of the `Iterable` type defined in 'dart:core' with |
/// [elementType] as its type argument. |
/// |
/// If no type argument is provided, the canonical raw type is returned. |
- InterfaceType iterableType([DartType elementType]); |
+ InterfaceType iterableType([DartType elementType]) { |
+ if (elementType == null) { |
+ return _getRawType(iterableClass); |
+ } |
+ return _createInterfaceType(iterableClass, [elementType]); |
+ } |
/// Returns an instance of the `Future` type defined in 'dart:async' with |
/// [elementType] as its type argument. |
/// |
/// If no type argument is provided, the canonical raw type is returned. |
- InterfaceType futureType([DartType elementType]); |
+ InterfaceType futureType([DartType elementType]) { |
+ if (elementType == null) { |
+ return _getRawType(futureClass); |
+ } |
+ return _createInterfaceType(futureClass, [elementType]); |
+ } |
/// Returns an instance of the `Stream` type defined in 'dart:async' with |
/// [elementType] as its type argument. |
/// |
/// If no type argument is provided, the canonical raw type is returned. |
- InterfaceType streamType([DartType elementType]); |
+ InterfaceType streamType([DartType elementType]) { |
+ if (elementType == null) { |
+ return _getRawType(streamClass); |
+ } |
+ return _createInterfaceType(streamClass, [elementType]); |
+ } |
/// Returns `true` if [element] is a superclass of `String` or `num`. |
- bool isNumberOrStringSupertype(ClassEntity element); |
+ // TODO(johnniwinther): Change types to `ClassEntity` when these are not |
+ // called with unrelated elements. |
+ bool isNumberOrStringSupertype(/*Class*/ Entity element) { |
+ return element == _findClass(coreLibrary, 'Comparable', required: false); |
+ } |
/// Returns `true` if [element] is a superclass of `String`. |
- bool isStringOnlySupertype(ClassEntity element); |
+ // TODO(johnniwinther): Change types to `ClassEntity` when these are not |
+ // called with unrelated elements. |
+ bool isStringOnlySupertype(/*Class*/ Entity element) { |
+ return element == _findClass(coreLibrary, 'Pattern', required: false); |
+ } |
/// Returns `true` if [element] is a superclass of `List`. |
- bool isListSupertype(ClassEntity element); |
+ bool isListSupertype(ClassEntity element) => element == iterableClass; |
+ |
+ ClassEntity _findClass(LibraryEntity library, String name, |
+ {bool required: true}) { |
+ if (library == null) return null; |
+ return _env.lookupClass(library, name, required: required); |
+ } |
+ |
+ MemberEntity _findLibraryMember(LibraryEntity library, String name, |
+ {bool setter: false, bool required: true}) { |
+ if (library == null) return null; |
+ return _env.lookupLibraryMember(library, name, |
+ setter: setter, required: required); |
+ } |
+ |
+ MemberEntity _findClassMember(ClassEntity cls, String name, |
+ {bool setter: false, bool required: true}) { |
+ return _env.lookupClassMember(cls, name, |
+ setter: setter, required: required); |
+ } |
+ |
+ ConstructorEntity _findConstructor(ClassEntity cls, String name, |
+ {bool required: true}) { |
+ return _env.lookupConstructor(cls, name, required: required); |
+ } |
+ |
+ /// Return the raw type of [cls]. |
+ InterfaceType _getRawType(ClassEntity cls) { |
+ return _env.getRawType(cls); |
+ } |
+ |
+ /// Create the instantiation of [cls] with the given [typeArguments]. |
+ InterfaceType _createInterfaceType( |
+ ClassEntity cls, List<DartType> typeArguments) { |
+ return _env.createInterfaceType(cls, typeArguments); |
+ } |
+ |
+ // From dart:core |
+ FunctionEntity get malformedTypeError => |
+ _cachedCoreHelper('_malformedTypeError'); |
+ FunctionEntity get genericNoSuchMethod => |
+ _cachedCoreHelper('_genericNoSuchMethod'); |
+ FunctionEntity get unresolvedConstructorError => |
+ _cachedCoreHelper('_unresolvedConstructorError'); |
+ FunctionEntity get unresolvedStaticGetterError => |
+ _cachedCoreHelper('_unresolvedStaticGetterError'); |
+ FunctionEntity get unresolvedStaticSetterError => |
+ _cachedCoreHelper('_unresolvedStaticSetterError'); |
+ FunctionEntity get unresolvedStaticMethodError => |
+ _cachedCoreHelper('_unresolvedStaticMethodError'); |
+ FunctionEntity get unresolvedTopLevelGetterError => |
+ _cachedCoreHelper('_unresolvedTopLevelGetterError'); |
+ FunctionEntity get unresolvedTopLevelSetterError => |
+ _cachedCoreHelper('_unresolvedTopLevelSetterError'); |
+ FunctionEntity get unresolvedTopLevelMethodError => |
+ _cachedCoreHelper('_unresolvedTopLevelMethodError'); |
+ |
+ Map<String, FunctionEntity> _cachedCoreHelpers = <String, FunctionEntity>{}; |
+ FunctionEntity _cachedCoreHelper(String name) => _cachedCoreHelpers[name] ??= |
+ _env.lookupLibraryMember(coreLibrary, name, required: true); |
+ |
+ FunctionEntity _objectEquals; |
+ FunctionEntity get objectEquals => |
+ _objectEquals ??= _findClassMember(objectClass, '=='); |
+ |
+ ClassEntity _mapLiteralClass; |
+ ClassEntity get mapLiteralClass { |
+ if (_mapLiteralClass == null) { |
+ _mapLiteralClass = _env.lookupClass(coreLibrary, 'LinkedHashMap'); |
+ if (_mapLiteralClass == null) { |
+ _mapLiteralClass = _findClass( |
+ _env.lookupLibrary(Uris.dart_collection), 'LinkedHashMap'); |
+ } |
+ } |
+ return _mapLiteralClass; |
+ } |
+ |
+ ConstructorEntity _mapLiteralConstructor; |
+ ConstructorEntity _mapLiteralConstructorEmpty; |
+ FunctionEntity _mapLiteralUntypedMaker; |
+ FunctionEntity _mapLiteralUntypedEmptyMaker; |
+ void _ensureMapLiteralHelpers() { |
+ if (_mapLiteralConstructor != null) return; |
+ |
+ _mapLiteralConstructor = |
+ _env.lookupConstructor(mapLiteralClass, '_literal'); |
+ _mapLiteralConstructorEmpty = |
+ _env.lookupConstructor(mapLiteralClass, '_empty'); |
+ _mapLiteralUntypedMaker = |
+ _env.lookupClassMember(mapLiteralClass, '_makeLiteral'); |
+ _mapLiteralUntypedEmptyMaker = |
+ _env.lookupClassMember(mapLiteralClass, '_makeEmpty'); |
+ } |
+ |
+ ConstructorEntity get mapLiteralConstructor { |
+ _ensureMapLiteralHelpers(); |
+ return _mapLiteralConstructor; |
+ } |
+ |
+ ConstructorEntity get mapLiteralConstructorEmpty { |
+ _ensureMapLiteralHelpers(); |
+ return _mapLiteralConstructorEmpty; |
+ } |
+ |
+ FunctionEntity get mapLiteralUntypedMaker { |
+ _ensureMapLiteralHelpers(); |
+ return _mapLiteralUntypedMaker; |
+ } |
+ |
+ FunctionEntity get mapLiteralUntypedEmptyMaker { |
+ _ensureMapLiteralHelpers(); |
+ return _mapLiteralUntypedEmptyMaker; |
+ } |
+ |
+ FunctionEntity _objectNoSuchMethod; |
+ FunctionEntity get objectNoSuchMethod { |
+ return _objectNoSuchMethod ??= |
+ _env.lookupClassMember(objectClass, Identifiers.noSuchMethod_); |
+ } |
+ |
+ bool isDefaultNoSuchMethodImplementation(FunctionEntity element) { |
+ ClassEntity classElement = element.enclosingClass; |
+ return classElement == objectClass || |
+ classElement == jsInterceptorClass || |
+ classElement == jsNullClass; |
+ } |
+ |
+ // From dart:async |
+ ClassEntity _findAsyncHelperClass(String name) => |
+ _findClass(asyncLibrary, name); |
+ |
+ FunctionEntity _findAsyncHelperFunction(String name) => |
+ _findLibraryMember(asyncLibrary, name); |
+ |
+ FunctionEntity get asyncHelper => _findAsyncHelperFunction("_asyncHelper"); |
+ |
+ FunctionEntity get wrapBody => |
+ _findAsyncHelperFunction("_wrapJsFunctionForAsync"); |
+ |
+ FunctionEntity get yieldStar => _env.lookupClassMember( |
+ _findAsyncHelperClass("_IterationMarker"), "yieldStar"); |
+ |
+ FunctionEntity get yieldSingle => _env.lookupClassMember( |
+ _findAsyncHelperClass("_IterationMarker"), "yieldSingle"); |
+ |
+ FunctionEntity get syncStarUncaughtError => _env.lookupClassMember( |
+ _findAsyncHelperClass("_IterationMarker"), "uncaughtError"); |
+ |
+ FunctionEntity get asyncStarHelper => |
+ _findAsyncHelperFunction("_asyncStarHelper"); |
+ |
+ FunctionEntity get streamOfController => |
+ _findAsyncHelperFunction("_streamOfController"); |
+ |
+ FunctionEntity get endOfIteration => _env.lookupClassMember( |
+ _findAsyncHelperClass("_IterationMarker"), "endOfIteration"); |
+ |
+ ClassEntity get syncStarIterable => |
+ _findAsyncHelperClass("_SyncStarIterable"); |
+ |
+ ClassEntity get futureImplementation => _findAsyncHelperClass('_Future'); |
+ |
+ ClassEntity get controllerStream => |
+ _findAsyncHelperClass("_ControllerStream"); |
+ |
+ ConstructorEntity get syncStarIterableConstructor => |
+ _env.lookupConstructor(syncStarIterable, ""); |
+ |
+ ConstructorEntity get syncCompleterConstructor => |
+ _env.lookupConstructor(_findAsyncHelperClass("Completer"), "sync"); |
+ |
+ ClassEntity get asyncStarController => |
+ _findAsyncHelperClass("_AsyncStarStreamController"); |
+ |
+ ConstructorEntity get asyncStarControllerConstructor => |
+ _env.lookupConstructor(asyncStarController, "", required: true); |
+ |
+ ConstructorEntity get streamIteratorConstructor => |
+ _env.lookupConstructor(_findAsyncHelperClass("StreamIterator"), ""); |
+ |
+ // From dart:mirrors |
+ FunctionEntity _findMirrorsFunction(String name) { |
+ LibraryEntity library = _env.lookupLibrary(Uris.dart__js_mirrors); |
+ if (library == null) return null; |
+ return _env.lookupLibraryMember(library, name, required: true); |
+ } |
+ |
+ /// Holds the method "disableTreeShaking" in js_mirrors when |
+ /// dart:mirrors has been loaded. |
+ FunctionEntity _disableTreeShakingMarker; |
+ FunctionEntity get disableTreeShakingMarker => |
+ _disableTreeShakingMarker ??= _findMirrorsFunction('disableTreeShaking'); |
+ |
+ /// Holds the method "preserveNames" in js_mirrors when |
+ /// dart:mirrors has been loaded. |
+ FunctionEntity _preserveNamesMarker; |
+ FunctionEntity get preserveNamesMarker { |
+ if (_preserveNamesMarker == null) { |
+ LibraryEntity library = _env.lookupLibrary(Uris.dart__js_names); |
+ if (library != null) { |
+ _preserveNamesMarker = _findLibraryMember(library, 'preserveNames'); |
+ } |
+ } |
+ return _preserveNamesMarker; |
+ } |
+ |
+ /// Holds the method "preserveMetadata" in js_mirrors when |
+ /// dart:mirrors has been loaded. |
+ FunctionEntity _preserveMetadataMarker; |
+ FunctionEntity get preserveMetadataMarker => |
+ _preserveMetadataMarker ??= _findMirrorsFunction('preserveMetadata'); |
+ |
+ /// Holds the method "preserveUris" in js_mirrors when |
+ /// dart:mirrors has been loaded. |
+ FunctionEntity _preserveUrisMarker; |
+ FunctionEntity get preserveUrisMarker => |
+ _preserveUrisMarker ??= _findMirrorsFunction('preserveUris'); |
+ |
+ /// Holds the method "preserveLibraryNames" in js_mirrors when |
+ /// dart:mirrors has been loaded. |
+ FunctionEntity _preserveLibraryNamesMarker; |
+ FunctionEntity get preserveLibraryNamesMarker => |
+ _preserveLibraryNamesMarker ??= |
+ _findMirrorsFunction('preserveLibraryNames'); |
+ |
+ // From dart:_interceptors |
+ ClassEntity _findInterceptorsClass(String name) => |
+ _findClass(interceptorsLibrary, name); |
+ |
+ FunctionEntity _findInterceptorsFunction(String name) => |
+ _findLibraryMember(interceptorsLibrary, name); |
+ |
+ ClassEntity _jsInterceptorClass; |
+ ClassEntity get jsInterceptorClass => |
+ _jsInterceptorClass ??= _findInterceptorsClass('Interceptor'); |
+ |
+ ClassEntity _jsStringClass; |
+ ClassEntity get jsStringClass => |
+ _jsStringClass ??= _findInterceptorsClass('JSString'); |
+ |
+ ClassEntity _jsArrayClass; |
+ ClassEntity get jsArrayClass => |
+ _jsArrayClass ??= _findInterceptorsClass('JSArray'); |
+ |
+ ClassEntity _jsNumberClass; |
+ ClassEntity get jsNumberClass => |
+ _jsNumberClass ??= _findInterceptorsClass('JSNumber'); |
+ |
+ ClassEntity _jsIntClass; |
+ ClassEntity get jsIntClass => _jsIntClass ??= _findInterceptorsClass('JSInt'); |
+ |
+ ClassEntity _jsDoubleClass; |
+ ClassEntity get jsDoubleClass => |
+ _jsDoubleClass ??= _findInterceptorsClass('JSDouble'); |
+ |
+ ClassEntity _jsNullClass; |
+ ClassEntity get jsNullClass => |
+ _jsNullClass ??= _findInterceptorsClass('JSNull'); |
+ |
+ ClassEntity _jsBoolClass; |
+ ClassEntity get jsBoolClass => |
+ _jsBoolClass ??= _findInterceptorsClass('JSBool'); |
+ |
+ ClassEntity _jsPlainJavaScriptObjectClass; |
+ ClassEntity get jsPlainJavaScriptObjectClass => |
+ _jsPlainJavaScriptObjectClass ??= |
+ _findInterceptorsClass('PlainJavaScriptObject'); |
+ |
+ ClassEntity _jsUnknownJavaScriptObjectClass; |
+ ClassEntity get jsUnknownJavaScriptObjectClass => |
+ _jsUnknownJavaScriptObjectClass ??= |
+ _findInterceptorsClass('UnknownJavaScriptObject'); |
+ |
+ ClassEntity _jsJavaScriptFunctionClass; |
+ ClassEntity get jsJavaScriptFunctionClass => _jsJavaScriptFunctionClass ??= |
+ _findInterceptorsClass('JavaScriptFunction'); |
+ |
+ ClassEntity _jsJavaScriptObjectClass; |
+ ClassEntity get jsJavaScriptObjectClass => |
+ _jsJavaScriptObjectClass ??= _findInterceptorsClass('JavaScriptObject'); |
+ |
+ ClassEntity _jsIndexableClass; |
+ ClassEntity get jsIndexableClass => |
+ _jsIndexableClass ??= _findInterceptorsClass('JSIndexable'); |
+ |
+ ClassEntity _jsMutableIndexableClass; |
+ ClassEntity get jsMutableIndexableClass => |
+ _jsMutableIndexableClass ??= _findInterceptorsClass('JSMutableIndexable'); |
+ |
+ ClassEntity _jsMutableArrayClass; |
+ ClassEntity get jsMutableArrayClass => |
+ _jsMutableArrayClass ??= _findInterceptorsClass('JSMutableArray'); |
+ |
+ ClassEntity _jsFixedArrayClass; |
+ ClassEntity get jsFixedArrayClass => |
+ _jsFixedArrayClass ??= _findInterceptorsClass('JSFixedArray'); |
+ |
+ ClassEntity _jsExtendableArrayClass; |
+ ClassEntity get jsExtendableArrayClass => |
+ _jsExtendableArrayClass ??= _findInterceptorsClass('JSExtendableArray'); |
+ |
+ ClassEntity _jsUnmodifiableArrayClass; |
+ ClassEntity get jsUnmodifiableArrayClass => _jsUnmodifiableArrayClass ??= |
+ _findInterceptorsClass('JSUnmodifiableArray'); |
+ |
+ ClassEntity _jsPositiveIntClass; |
+ ClassEntity get jsPositiveIntClass => |
+ _jsPositiveIntClass ??= _findInterceptorsClass('JSPositiveInt'); |
+ |
+ ClassEntity _jsUInt32Class; |
+ ClassEntity get jsUInt32Class => |
+ _jsUInt32Class ??= _findInterceptorsClass('JSUInt32'); |
+ |
+ ClassEntity _jsUInt31Class; |
+ ClassEntity get jsUInt31Class => |
+ _jsUInt31Class ??= _findInterceptorsClass('JSUInt31'); |
+ |
+ FunctionEntity _findIndexForNativeSubclassType; |
+ FunctionEntity get findIndexForNativeSubclassType => |
+ _findIndexForNativeSubclassType ??= _findLibraryMember( |
+ interceptorsLibrary, 'findIndexForNativeSubclassType'); |
+ |
+ FunctionEntity _getInterceptorMethod; |
+ FunctionEntity get getInterceptorMethod => |
+ _getInterceptorMethod ??= _findInterceptorsFunction('getInterceptor'); |
+ |
+ FunctionEntity _getNativeInterceptorMethod; |
+ FunctionEntity get getNativeInterceptorMethod => |
+ _getNativeInterceptorMethod ??= |
+ _findInterceptorsFunction('getNativeInterceptor'); |
+ |
+ MemberEntity _jsIndexableLength; |
+ MemberEntity get jsIndexableLength => |
+ _jsIndexableLength ??= _findClassMember(jsIndexableClass, 'length'); |
+ |
+ ConstructorEntity _jsArrayTypedConstructor; |
+ ConstructorEntity get jsArrayTypedConstructor => |
+ _jsArrayTypedConstructor ??= _findConstructor(jsArrayClass, 'typed'); |
+ |
+ FunctionEntity _jsArrayRemoveLast; |
+ FunctionEntity get jsArrayRemoveLast => |
+ _jsArrayRemoveLast ??= _findClassMember(jsArrayClass, 'removeLast'); |
+ |
+ FunctionEntity _jsArrayAdd; |
+ FunctionEntity get jsArrayAdd => |
+ _jsArrayAdd ??= _findClassMember(jsArrayClass, 'add'); |
+ |
+ FunctionEntity _jsStringSplit; |
+ FunctionEntity get jsStringSplit => |
+ _jsStringSplit ??= _findClassMember(jsStringClass, 'split'); |
+ |
+ FunctionEntity _jsStringToString; |
+ FunctionEntity get jsStringToString => |
+ _jsStringToString ??= _findClassMember(jsStringClass, 'toString'); |
+ |
+ FunctionEntity _jsStringOperatorAdd; |
+ FunctionEntity get jsStringOperatorAdd => |
+ _jsStringOperatorAdd ??= _findClassMember(jsStringClass, '+'); |
+ |
+ // From package:js |
+ ClassEntity _jsAnnotationClass; |
+ ClassEntity get jsAnnotationClass { |
+ if (_jsAnnotationClass == null) { |
+ LibraryEntity library = _env.lookupLibrary(Uris.package_js); |
+ if (library == null) return null; |
+ _jsAnnotationClass = _findClass(library, 'JS'); |
+ } |
+ return _jsAnnotationClass; |
+ } |
+ |
+ ClassEntity _jsAnonymousClass; |
+ ClassEntity get jsAnonymousClass { |
+ if (_jsAnonymousClass == null) { |
+ LibraryEntity library = _env.lookupLibrary(Uris.package_js); |
+ if (library == null) return null; |
+ _jsAnonymousClass = _findClass(library, '_Anonymous'); |
+ } |
+ return _jsAnonymousClass; |
+ } |
+ |
+ // From dart:_js_helper |
+ // TODO(johnniwinther): Avoid the need for this (from [CheckedModeHelper]). |
+ FunctionEntity findHelperFunction(String name) => _findHelperFunction(name); |
+ |
+ FunctionEntity _findHelperFunction(String name) => |
+ _findLibraryMember(jsHelperLibrary, name); |
+ |
+ ClassEntity _findHelperClass(String name) => |
+ _findClass(jsHelperLibrary, name); |
+ |
+ ClassEntity _closureClass; |
+ ClassEntity get closureClass => _closureClass ??= _findHelperClass('Closure'); |
+ |
+ ClassEntity _boundClosureClass; |
+ ClassEntity get boundClosureClass => |
+ _boundClosureClass ??= _findHelperClass('BoundClosure'); |
+ |
+ ClassEntity _typeLiteralClass; |
+ ClassEntity get typeLiteralClass => |
+ _typeLiteralClass ??= _findHelperClass('TypeImpl'); |
+ |
+ ClassEntity _constMapLiteralClass; |
+ ClassEntity get constMapLiteralClass => |
+ _constMapLiteralClass ??= _findHelperClass('ConstantMap'); |
+ |
+ ClassEntity _typeVariableClass; |
+ ClassEntity get typeVariableClass => |
+ _typeVariableClass ??= _findHelperClass('TypeVariable'); |
+ |
+ ClassEntity _noSideEffectsClass; |
+ ClassEntity get noSideEffectsClass => |
+ _noSideEffectsClass ??= _findHelperClass('NoSideEffects'); |
+ |
+ ClassEntity _noThrowsClass; |
+ ClassEntity get noThrowsClass => |
+ _noThrowsClass ??= _findHelperClass('NoThrows'); |
+ |
+ ClassEntity _noInlineClass; |
+ ClassEntity get noInlineClass => |
+ _noInlineClass ??= _findHelperClass('NoInline'); |
+ |
+ ClassEntity _forceInlineClass; |
+ ClassEntity get forceInlineClass => |
+ _forceInlineClass ??= _findHelperClass('ForceInline'); |
+ |
+ ClassEntity _irRepresentationClass; |
+ ClassEntity get irRepresentationClass => |
+ _irRepresentationClass ??= _findHelperClass('IrRepresentation'); |
+ |
+ ClassEntity _jsInvocationMirrorClass; |
+ ClassEntity get jsInvocationMirrorClass => |
+ _jsInvocationMirrorClass ??= _findHelperClass('JSInvocationMirror'); |
+ |
+ /// Interface used to determine if an object has the JavaScript |
+ /// indexing behavior. The interface is only visible to specific libraries. |
+ ClassEntity _jsIndexingBehaviorInterface; |
+ ClassEntity get jsIndexingBehaviorInterface => |
+ _jsIndexingBehaviorInterface ??= |
+ _findHelperClass('JavaScriptIndexingBehavior'); |
+ |
+ ClassEntity get VoidRuntimeType => _findHelperClass('VoidRuntimeType'); |
+ |
+ ClassEntity get stackTraceHelperClass => _findHelperClass('_StackTrace'); |
+ |
+ ClassEntity get constantMapClass => |
+ _findHelperClass(JavaScriptMapConstant.DART_CLASS); |
+ ClassEntity get constantStringMapClass => |
+ _findHelperClass(JavaScriptMapConstant.DART_STRING_CLASS); |
+ ClassEntity get constantProtoMapClass => |
+ _findHelperClass(JavaScriptMapConstant.DART_PROTO_CLASS); |
+ ClassEntity get generalConstantMapClass => |
+ _findHelperClass(JavaScriptMapConstant.DART_GENERAL_CLASS); |
+ |
+ ClassEntity get annotationCreatesClass => _findHelperClass('Creates'); |
+ |
+ ClassEntity get annotationReturnsClass => _findHelperClass('Returns'); |
+ |
+ ClassEntity get annotationJSNameClass => _findHelperClass('JSName'); |
+ |
+ /// The class for patch annotations defined in dart:_js_helper. |
+ ClassEntity _patchAnnotationClass; |
+ ClassEntity get patchAnnotationClass => |
+ _patchAnnotationClass ??= _findHelperClass('_Patch'); |
+ |
+ /// The class for native annotations defined in dart:_js_helper. |
+ ClassEntity _nativeAnnotationClass; |
+ ClassEntity get nativeAnnotationClass => |
+ _nativeAnnotationClass ??= _findHelperClass('Native'); |
+ |
+ ConstructorEntity _typeVariableConstructor; |
+ ConstructorEntity get typeVariableConstructor => _typeVariableConstructor ??= |
+ _env.lookupConstructor(typeVariableClass, ''); |
+ |
+ FunctionEntity _invokeOnMethod; |
+ FunctionEntity get invokeOnMethod => _invokeOnMethod ??= |
+ _env.lookupClassMember(jsInvocationMirrorClass, '_getCachedInvocation'); |
+ |
+ FunctionEntity _assertTest; |
+ FunctionEntity get assertTest => |
+ _assertTest ??= _findHelperFunction('assertTest'); |
+ |
+ FunctionEntity _assertThrow; |
+ FunctionEntity get assertThrow => |
+ _assertThrow ??= _findHelperFunction('assertThrow'); |
+ |
+ FunctionEntity _assertHelper; |
+ FunctionEntity get assertHelper => |
+ _assertHelper ??= _findHelperFunction('assertHelper'); |
+ |
+ FunctionEntity _assertUnreachableMethod; |
+ FunctionEntity get assertUnreachableMethod => |
+ _assertUnreachableMethod ??= _findHelperFunction('assertUnreachable'); |
+ |
+ /// Holds the method "getIsolateAffinityTag" when dart:_js_helper has been |
+ /// loaded. |
+ FunctionEntity _getIsolateAffinityTagMarker; |
+ FunctionEntity get getIsolateAffinityTagMarker => |
+ _getIsolateAffinityTagMarker ??= |
+ _findHelperFunction('getIsolateAffinityTag'); |
+ |
+ /// Holds the method "requiresPreamble" in _js_helper. |
+ FunctionEntity _requiresPreambleMarker; |
+ FunctionEntity get requiresPreambleMarker => |
+ _requiresPreambleMarker ??= _findHelperFunction('requiresPreamble'); |
+ |
+ FunctionEntity get badMain => _findHelperFunction('badMain'); |
+ |
+ FunctionEntity get missingMain => _findHelperFunction('missingMain'); |
+ |
+ FunctionEntity get mainHasTooManyParameters => |
+ _findHelperFunction('mainHasTooManyParameters'); |
+ |
+ FunctionEntity get loadLibraryWrapper => |
+ _findHelperFunction("_loadLibraryWrapper"); |
+ |
+ FunctionEntity get boolConversionCheck => |
+ _findHelperFunction('boolConversionCheck'); |
+ |
+ FunctionEntity get _consoleTraceHelper => |
+ _findHelperFunction('consoleTraceHelper'); |
+ |
+ FunctionEntity get _postTraceHelper => _findHelperFunction('postTraceHelper'); |
+ |
+ FunctionEntity _traceHelper; |
+ FunctionEntity get traceHelper { |
+ return _traceHelper ??= JavaScriptBackend.TRACE_METHOD == 'console' |
+ ? _consoleTraceHelper |
+ : _postTraceHelper; |
+ } |
+ |
+ FunctionEntity get closureFromTearOff => |
+ _findHelperFunction('closureFromTearOff'); |
+ |
+ FunctionEntity get isJsIndexable => _findHelperFunction('isJsIndexable'); |
+ |
+ FunctionEntity get throwIllegalArgumentException => |
+ _findHelperFunction('iae'); |
+ |
+ FunctionEntity get throwIndexOutOfRangeException => |
+ _findHelperFunction('ioore'); |
+ |
+ FunctionEntity get exceptionUnwrapper => |
+ _findHelperFunction('unwrapException'); |
+ |
+ FunctionEntity get throwRuntimeError => |
+ _findHelperFunction('throwRuntimeError'); |
+ |
+ FunctionEntity get throwTypeError => _findHelperFunction('throwTypeError'); |
+ |
+ FunctionEntity get throwAbstractClassInstantiationError => |
+ _findHelperFunction('throwAbstractClassInstantiationError'); |
+ |
+ FunctionEntity _cachedCheckConcurrentModificationError; |
+ FunctionEntity get checkConcurrentModificationError => |
+ _cachedCheckConcurrentModificationError ??= |
+ _findHelperFunction('checkConcurrentModificationError'); |
+ |
+ FunctionEntity get throwConcurrentModificationError => |
+ _findHelperFunction('throwConcurrentModificationError'); |
+ |
+ FunctionEntity _checkInt; |
+ FunctionEntity get checkInt => _checkInt ??= _findHelperFunction('checkInt'); |
+ |
+ FunctionEntity _checkNum; |
+ FunctionEntity get checkNum => _checkNum ??= _findHelperFunction('checkNum'); |
+ |
+ FunctionEntity _checkString; |
+ FunctionEntity get checkString => |
+ _checkString ??= _findHelperFunction('checkString'); |
+ |
+ FunctionEntity get stringInterpolationHelper => _findHelperFunction('S'); |
+ |
+ FunctionEntity get wrapExceptionHelper => |
+ _findHelperFunction('wrapException'); |
+ |
+ FunctionEntity get throwExpressionHelper => |
+ _findHelperFunction('throwExpression'); |
+ |
+ FunctionEntity get closureConverter => |
+ _findHelperFunction('convertDartClosureToJS'); |
+ |
+ FunctionEntity get traceFromException => |
+ _findHelperFunction('getTraceFromException'); |
+ |
+ FunctionEntity get setRuntimeTypeInfo => |
+ _findHelperFunction('setRuntimeTypeInfo'); |
+ |
+ FunctionEntity get getRuntimeTypeInfo => |
+ _findHelperFunction('getRuntimeTypeInfo'); |
+ |
+ FunctionEntity get getTypeArgumentByIndex => |
+ _findHelperFunction('getTypeArgumentByIndex'); |
+ |
+ FunctionEntity get computeSignature => |
+ _findHelperFunction('computeSignature'); |
+ |
+ FunctionEntity get getRuntimeTypeArguments => |
+ _findHelperFunction('getRuntimeTypeArguments'); |
+ |
+ FunctionEntity get getRuntimeTypeArgument => |
+ _findHelperFunction('getRuntimeTypeArgument'); |
+ |
+ FunctionEntity get runtimeTypeToString => |
+ _findHelperFunction('runtimeTypeToString'); |
+ |
+ FunctionEntity get assertIsSubtype => _findHelperFunction('assertIsSubtype'); |
+ |
+ FunctionEntity get checkSubtype => _findHelperFunction('checkSubtype'); |
+ |
+ FunctionEntity get assertSubtype => _findHelperFunction('assertSubtype'); |
+ |
+ FunctionEntity get subtypeCast => _findHelperFunction('subtypeCast'); |
+ |
+ FunctionEntity get functionTypeTest => |
+ _findHelperFunction('functionTypeTest'); |
+ |
+ FunctionEntity get checkSubtypeOfRuntimeType => |
+ _findHelperFunction('checkSubtypeOfRuntimeType'); |
+ |
+ FunctionEntity get assertSubtypeOfRuntimeType => |
+ _findHelperFunction('assertSubtypeOfRuntimeType'); |
+ |
+ FunctionEntity get subtypeOfRuntimeTypeCast => |
+ _findHelperFunction('subtypeOfRuntimeTypeCast'); |
+ |
+ FunctionEntity get checkDeferredIsLoaded => |
+ _findHelperFunction('checkDeferredIsLoaded'); |
+ |
+ FunctionEntity get throwNoSuchMethod => |
+ _findHelperFunction('throwNoSuchMethod'); |
+ |
+ FunctionEntity get createRuntimeType => |
+ _findHelperFunction('createRuntimeType'); |
+ |
+ FunctionEntity get fallThroughError => |
+ _findHelperFunction("getFallThroughError"); |
+ |
+ FunctionEntity get createInvocationMirror => |
+ _findHelperFunction('createInvocationMirror'); |
+ |
+ FunctionEntity get cyclicThrowHelper => |
+ _findHelperFunction("throwCyclicInit"); |
+ |
+ FunctionEntity get defineProperty => _findHelperFunction('defineProperty'); |
+ |
+ FunctionEntity get convertRtiToRuntimeType => |
+ _findHelperFunction('convertRtiToRuntimeType'); |
+ |
+ FunctionEntity get toStringForNativeObject => |
+ _findHelperFunction('toStringForNativeObject'); |
+ |
+ FunctionEntity get hashCodeForNativeObject => |
+ _findHelperFunction('hashCodeForNativeObject'); |
+ |
+ // From dart:_internal |
+ |
+ ClassEntity _symbolImplementationClass; |
+ ClassEntity get symbolImplementationClass => |
+ _symbolImplementationClass ??= _findClass(internalLibrary, 'Symbol'); |
+ |
+ final Selector symbolValidatedConstructorSelector = |
+ new Selector.call(const PublicName('validated'), CallStructure.ONE_ARG); |
+ |
+ ConstructorEntity get symbolValidatedConstructor => |
+ _symbolValidatedConstructor ??= _findConstructor( |
+ symbolImplementationClass, symbolValidatedConstructorSelector.name); |
+ |
+ /// Returns the field that holds the internal name in the implementation class |
+ /// for `Symbol`. |
+ FieldEntity _symbolImplementationField; |
+ FieldEntity get symbolImplementationField => _symbolImplementationField ??= |
+ _env.lookupClassMember(symbolImplementationClass, '_name', |
+ required: true); |
+ |
+ ConstructorEntity _symbolValidatedConstructor; |
+ bool isSymbolValidatedConstructor(ConstructorEntity element) { |
+ if (_symbolValidatedConstructor != null) { |
+ return element == _symbolValidatedConstructor; |
+ } |
+ return false; |
+ } |
+ |
+ // From dart:_native_typed_data |
+ |
+ ClassEntity _typedArrayClass; |
+ ClassEntity get typedArrayClass => _typedArrayClass ??= _findClass( |
+ _env.lookupLibrary(Uris.dart__native_typed_data, required: true), |
+ 'NativeTypedArray'); |
+ |
+ ClassEntity _typedArrayOfIntClass; |
+ ClassEntity get typedArrayOfIntClass => _typedArrayOfIntClass ??= _findClass( |
+ _env.lookupLibrary(Uris.dart__native_typed_data, required: true), |
+ 'NativeTypedArrayOfInt'); |
+ |
+ // From dart:_js_embedded_names |
+ |
+ /// Holds the class for the [JsGetName] enum. |
+ ClassEntity _jsGetNameEnum; |
+ ClassEntity get jsGetNameEnum => _jsGetNameEnum ??= _findClass( |
+ _env.lookupLibrary(Uris.dart__js_embedded_names, required: true), |
+ 'JsGetName'); |
+ |
+ /// Holds the class for the [JsBuiltins] enum. |
+ ClassEntity _jsBuiltinEnum; |
+ ClassEntity get jsBuiltinEnum => _jsBuiltinEnum ??= _findClass( |
+ _env.lookupLibrary(Uris.dart__js_embedded_names, required: true), |
+ 'JsBuiltin'); |
+ |
+ // From dart:_isolate_helper |
+ |
+ FunctionEntity get startRootIsolate => |
+ _findLibraryMember(isolateHelperLibrary, 'startRootIsolate'); |
+ |
+ FunctionEntity get currentIsolate => |
+ _findLibraryMember(isolateHelperLibrary, '_currentIsolate'); |
+ |
+ FunctionEntity get callInIsolate => |
+ _findLibraryMember(isolateHelperLibrary, '_callInIsolate'); |
} |
/// Interface for accessing libraries, classes and members. |
@@ -318,282 +1170,3 @@ abstract class ElementEnvironment { |
/// on deferred libraries. |
bool isDeferredLoadLibraryGetter(MemberEntity member); |
} |
- |
-class CommonElementsImpl implements CommonElements { |
- final ElementEnvironment _env; |
- |
- CommonElementsImpl(this._env); |
- |
- ClassEntity findClass(LibraryEntity library, String name, |
- {bool required: true}) { |
- if (library == null) return null; |
- return _env.lookupClass(library, name, required: required); |
- } |
- |
- MemberEntity findLibraryMember(LibraryEntity library, String name, |
- {bool setter: false, bool required: true}) { |
- if (library == null) return null; |
- return _env.lookupLibraryMember(library, name, |
- setter: setter, required: required); |
- } |
- |
- MemberEntity findClassMember(ClassEntity cls, String name, |
- {bool setter: false, bool required: true}) { |
- return _env.lookupClassMember(cls, name, |
- setter: setter, required: required); |
- } |
- |
- ConstructorEntity findConstructor(ClassEntity cls, String name, |
- {bool required: true}) { |
- return _env.lookupConstructor(cls, name, required: required); |
- } |
- |
- DartType get dynamicType => _env.dynamicType; |
- |
- /// Return the raw type of [cls]. |
- InterfaceType getRawType(ClassEntity cls) { |
- return _env.getRawType(cls); |
- } |
- |
- /// Create the instantiation of [cls] with the given [typeArguments]. |
- InterfaceType createInterfaceType( |
- ClassEntity cls, List<DartType> typeArguments) { |
- return _env.createInterfaceType(cls, typeArguments); |
- } |
- |
- LibraryEntity _coreLibrary; |
- LibraryEntity get coreLibrary => |
- _coreLibrary ??= _env.lookupLibrary(Uris.dart_core, required: true); |
- |
- LibraryEntity _typedDataLibrary; |
- LibraryEntity get typedDataLibrary => |
- _typedDataLibrary ??= _env.lookupLibrary(Uris.dart__native_typed_data); |
- |
- LibraryEntity _mirrorsLibrary; |
- LibraryEntity get mirrorsLibrary => |
- _mirrorsLibrary ??= _env.lookupLibrary(Uris.dart_mirrors); |
- |
- LibraryEntity _asyncLibrary; |
- LibraryEntity get asyncLibrary => |
- _asyncLibrary ??= _env.lookupLibrary(Uris.dart_async); |
- |
- // From dart:core |
- |
- ClassEntity _objectClass; |
- ClassEntity get objectClass => |
- _objectClass ??= findClass(coreLibrary, 'Object'); |
- |
- ClassEntity _boolClass; |
- ClassEntity get boolClass => _boolClass ??= findClass(coreLibrary, 'bool'); |
- |
- ClassEntity _numClass; |
- ClassEntity get numClass => _numClass ??= findClass(coreLibrary, 'num'); |
- |
- ClassEntity _intClass; |
- ClassEntity get intClass => _intClass ??= findClass(coreLibrary, 'int'); |
- |
- ClassEntity _doubleClass; |
- ClassEntity get doubleClass => |
- _doubleClass ??= findClass(coreLibrary, 'double'); |
- |
- ClassEntity _stringClass; |
- ClassEntity get stringClass => |
- _stringClass ??= findClass(coreLibrary, 'String'); |
- |
- ClassEntity _functionClass; |
- ClassEntity get functionClass => |
- _functionClass ??= findClass(coreLibrary, 'Function'); |
- |
- FunctionEntity _functionApplyMethod; |
- FunctionEntity get functionApplyMethod => |
- _functionApplyMethod ??= findClassMember(functionClass, 'apply'); |
- |
- bool isFunctionApplyMethod(MemberEntity element) => |
- element.name == 'apply' && element.enclosingClass == functionClass; |
- |
- ClassEntity _nullClass; |
- ClassEntity get nullClass => _nullClass ??= findClass(coreLibrary, 'Null'); |
- |
- ClassEntity _listClass; |
- ClassEntity get listClass => _listClass ??= findClass(coreLibrary, 'List'); |
- |
- ClassEntity _typeClass; |
- ClassEntity get typeClass => _typeClass ??= findClass(coreLibrary, 'Type'); |
- |
- ClassEntity _mapClass; |
- ClassEntity get mapClass => _mapClass ??= findClass(coreLibrary, 'Map'); |
- |
- ClassEntity _symbolClass; |
- ClassEntity get symbolClass => |
- _symbolClass ??= findClass(coreLibrary, 'Symbol'); |
- |
- ConstructorEntity _symbolConstructor; |
- ConstructorEntity get symbolConstructor => |
- // TODO(johnniwinther): Kernel does not include redirecting factories |
- // so this cannot be found in kernel. Find a consistent way to handle |
- // this and similar cases. |
- _symbolConstructor ??= findConstructor(symbolClass, '', required: false); |
- |
- bool isSymbolConstructor(Entity e) => e == symbolConstructor; |
- |
- ClassEntity _stackTraceClass; |
- ClassEntity get stackTraceClass => |
- _stackTraceClass ??= findClass(coreLibrary, 'StackTrace'); |
- |
- ClassEntity _iterableClass; |
- ClassEntity get iterableClass => |
- _iterableClass ??= findClass(coreLibrary, 'Iterable'); |
- |
- ClassEntity _resourceClass; |
- ClassEntity get resourceClass => |
- _resourceClass ??= findClass(coreLibrary, 'Resource'); |
- |
- FunctionEntity _identicalFunction; |
- FunctionEntity get identicalFunction => |
- _identicalFunction ??= findLibraryMember(coreLibrary, 'identical'); |
- |
- // From dart:async |
- |
- ClassEntity _futureClass; |
- ClassEntity get futureClass => |
- _futureClass ??= findClass(asyncLibrary, 'Future'); |
- |
- ClassEntity _streamClass; |
- ClassEntity get streamClass => |
- _streamClass ??= findClass(asyncLibrary, 'Stream'); |
- |
- ClassEntity _deferredLibraryClass; |
- ClassEntity get deferredLibraryClass => |
- _deferredLibraryClass ??= findClass(asyncLibrary, "DeferredLibrary"); |
- |
- // From dart:mirrors |
- |
- ClassEntity _mirrorSystemClass; |
- ClassEntity get mirrorSystemClass => _mirrorSystemClass ??= |
- findClass(mirrorsLibrary, 'MirrorSystem', required: false); |
- |
- FunctionEntity _mirrorSystemGetNameFunction; |
- bool isMirrorSystemGetNameFunction(MemberEntity element) { |
- if (_mirrorSystemGetNameFunction == null) { |
- if (!element.isFunction || mirrorsLibrary == null) return false; |
- ClassEntity cls = mirrorSystemClass; |
- if (element.enclosingClass != cls) return false; |
- if (cls != null) { |
- _mirrorSystemGetNameFunction = |
- findClassMember(cls, 'getName', required: false); |
- } |
- } |
- return element == _mirrorSystemGetNameFunction; |
- } |
- |
- ClassEntity _mirrorsUsedClass; |
- ClassEntity get mirrorsUsedClass => _mirrorsUsedClass ??= |
- findClass(mirrorsLibrary, 'MirrorsUsed', required: false); |
- |
- bool isMirrorsUsedConstructor(ConstructorEntity element) => |
- mirrorsLibrary != null && mirrorsUsedClass == element.enclosingClass; |
- |
- // From dart:typed_data |
- |
- ClassEntity _typedDataClass; |
- ClassEntity get typedDataClass => |
- _typedDataClass ??= findClass(typedDataLibrary, 'NativeTypedData'); |
- |
- bool isUnnamedListConstructor(ConstructorEntity element) => |
- element.name == '' && element.enclosingClass == listClass; |
- |
- bool isFilledListConstructor(ConstructorEntity element) => |
- element.name == 'filled' && element.enclosingClass == listClass; |
- |
- // TODO(johnniwinther): Change types to `ClassEntity` when these are not |
- // called with unrelated elements. |
- bool isNumberOrStringSupertype(/*Class*/ Entity element) { |
- return element == findClass(coreLibrary, 'Comparable', required: false); |
- } |
- |
- bool isStringOnlySupertype(/*Class*/ Entity element) { |
- return element == findClass(coreLibrary, 'Pattern', required: false); |
- } |
- |
- bool isListSupertype(/*Class*/ Entity element) => element == iterableClass; |
- |
- @override |
- InterfaceType get objectType => getRawType(objectClass); |
- |
- @override |
- InterfaceType get boolType => getRawType(boolClass); |
- |
- @override |
- InterfaceType get doubleType => getRawType(doubleClass); |
- |
- @override |
- InterfaceType get functionType => getRawType(functionClass); |
- |
- @override |
- InterfaceType get intType => getRawType(intClass); |
- |
- @override |
- InterfaceType get resourceType => getRawType(resourceClass); |
- |
- @override |
- InterfaceType listType([DartType elementType]) { |
- if (elementType == null) { |
- return getRawType(listClass); |
- } |
- return createInterfaceType(listClass, [elementType]); |
- } |
- |
- @override |
- InterfaceType mapType([DartType keyType, DartType valueType]) { |
- if (keyType == null && valueType == null) { |
- return getRawType(mapClass); |
- } else if (keyType == null) { |
- keyType = dynamicType; |
- } else if (valueType == null) { |
- valueType = dynamicType; |
- } |
- return createInterfaceType(mapClass, [keyType, valueType]); |
- } |
- |
- @override |
- InterfaceType get nullType => getRawType(nullClass); |
- |
- @override |
- InterfaceType get numType => getRawType(numClass); |
- |
- @override |
- InterfaceType get stringType => getRawType(stringClass); |
- |
- @override |
- InterfaceType get symbolType => getRawType(symbolClass); |
- |
- @override |
- InterfaceType get typeType => getRawType(typeClass); |
- |
- @override |
- InterfaceType get stackTraceType => getRawType(stackTraceClass); |
- |
- @override |
- InterfaceType iterableType([DartType elementType]) { |
- if (elementType == null) { |
- return getRawType(iterableClass); |
- } |
- return createInterfaceType(iterableClass, [elementType]); |
- } |
- |
- @override |
- InterfaceType futureType([DartType elementType]) { |
- if (elementType == null) { |
- return getRawType(futureClass); |
- } |
- return createInterfaceType(futureClass, [elementType]); |
- } |
- |
- @override |
- InterfaceType streamType([DartType elementType]) { |
- if (elementType == null) { |
- return getRawType(streamClass); |
- } |
- return createInterfaceType(streamClass, [elementType]); |
- } |
-} |