| Index: pkg/compiler/lib/src/js_backend/backend_helpers.dart
|
| diff --git a/pkg/compiler/lib/src/js_backend/backend_helpers.dart b/pkg/compiler/lib/src/js_backend/backend_helpers.dart
|
| index 6967ca8a2c75d1c5f808f3cdf368953c054cbd7c..974cddc1161dd71f3727150aa4e091a3c7f9b657 100644
|
| --- a/pkg/compiler/lib/src/js_backend/backend_helpers.dart
|
| +++ b/pkg/compiler/lib/src/js_backend/backend_helpers.dart
|
| @@ -25,6 +25,7 @@ import '../elements/elements.dart'
|
| import '../library_loader.dart' show LoadedLibraries;
|
| import '../universe/call_structure.dart' show CallStructure;
|
| import '../universe/selector.dart' show Selector;
|
| +import 'constant_system_javascript.dart';
|
| import 'js_backend.dart';
|
|
|
| /// Helper classes and functions for the JavaScript backend.
|
| @@ -181,7 +182,7 @@ class BackendHelpers {
|
|
|
| ClassElement _symbolImplementationClass;
|
| ClassElement get symbolImplementationClass {
|
| - return _symbolImplementationClass ??= find(internalLibrary, 'Symbol');
|
| + return _symbolImplementationClass ??= _find(internalLibrary, 'Symbol');
|
| }
|
|
|
| final Selector symbolValidatedConstructorSelector =
|
| @@ -202,12 +203,14 @@ class BackendHelpers {
|
| }
|
|
|
| // TODO(johnniwinther): Make these private.
|
| - // TODO(johnniwinther): Split into findHelperFunction and findHelperClass and
|
| + // TODO(johnniwinther): Split into _findHelperFunction and _findHelperClass and
|
| // add a check that the element has the expected kind.
|
| - Element findHelper(String name) => find(jsHelperLibrary, name);
|
| - Element findAsyncHelper(String name) => find(asyncLibrary, name);
|
| - Element findInterceptor(String name) => find(interceptorsLibrary, name);
|
| - Element find(LibraryElement library, String name) {
|
| + Element _findHelper(String name) => _find(jsHelperLibrary, name);
|
| + FunctionElement _findHelperFunction(String name) =>
|
| + _find(jsHelperLibrary, name);
|
| + Element _findAsyncHelper(String name) => _find(asyncLibrary, name);
|
| + Element _findInterceptor(String name) => _find(interceptorsLibrary, name);
|
| + Element _find(LibraryElement library, String name) {
|
| Element element = library.implementation.findLocal(name);
|
| assert(invariant(library, element != null,
|
| message: "Element '$name' not found in '${library.canonicalUri}'."));
|
| @@ -245,7 +248,7 @@ class BackendHelpers {
|
| void initializeHelperClasses(DiagnosticReporter reporter) {
|
| final List missingHelperClasses = [];
|
| ClassElement lookupHelperClass(String name) {
|
| - ClassElement result = findHelper(name);
|
| + ClassElement result = _findHelper(name);
|
| if (result == null) {
|
| missingHelperClasses.add(name);
|
| }
|
| @@ -267,11 +270,11 @@ class BackendHelpers {
|
| Uri uri = library.canonicalUri;
|
|
|
| FunctionElement findMethod(String name) {
|
| - return find(library, name);
|
| + return _find(library, name);
|
| }
|
|
|
| ClassElement findClass(String name) {
|
| - return find(library, name);
|
| + return _find(library, name);
|
| }
|
|
|
| if (uri == DART_INTERCEPTORS) {
|
| @@ -302,10 +305,10 @@ class BackendHelpers {
|
| jsMutableIndexableClass = findClass('JSMutableIndexable');
|
| } else if (uri == DART_JS_HELPER) {
|
| initializeHelperClasses(reporter);
|
| - assertTest = findHelper('assertTest');
|
| - assertThrow = findHelper('assertThrow');
|
| - assertHelper = findHelper('assertHelper');
|
| - assertUnreachableMethod = findHelper('assertUnreachable');
|
| + assertTest = _findHelper('assertTest');
|
| + assertThrow = _findHelper('assertThrow');
|
| + assertHelper = _findHelper('assertHelper');
|
| + assertUnreachableMethod = _findHelper('assertUnreachable');
|
|
|
| typeLiteralClass = findClass('TypeImpl');
|
| constMapLiteralClass = findClass('ConstantMap');
|
| @@ -323,21 +326,21 @@ class BackendHelpers {
|
|
|
| requiresPreambleMarker = findMethod('requiresPreamble');
|
| } else if (uri == DART_JS_MIRRORS) {
|
| - disableTreeShakingMarker = find(library, 'disableTreeShaking');
|
| - preserveMetadataMarker = find(library, 'preserveMetadata');
|
| - preserveUrisMarker = find(library, 'preserveUris');
|
| - preserveLibraryNamesMarker = find(library, 'preserveLibraryNames');
|
| + disableTreeShakingMarker = _find(library, 'disableTreeShaking');
|
| + preserveMetadataMarker = _find(library, 'preserveMetadata');
|
| + preserveUrisMarker = _find(library, 'preserveUris');
|
| + preserveLibraryNamesMarker = _find(library, 'preserveLibraryNames');
|
| } else if (uri == DART_JS_NAMES) {
|
| - preserveNamesMarker = find(library, 'preserveNames');
|
| + preserveNamesMarker = _find(library, 'preserveNames');
|
| } else if (uri == DART_EMBEDDED_NAMES) {
|
| - jsGetNameEnum = find(library, 'JsGetName');
|
| - jsBuiltinEnum = find(library, 'JsBuiltin');
|
| + jsGetNameEnum = _find(library, 'JsGetName');
|
| + jsBuiltinEnum = _find(library, 'JsBuiltin');
|
| } else if (uri == Uris.dart__native_typed_data) {
|
| typedArrayClass = findClass('NativeTypedArray');
|
| typedArrayOfIntClass = findClass('NativeTypedArrayOfInt');
|
| } else if (uri == PACKAGE_JS) {
|
| - jsAnnotationClass = find(library, 'JS');
|
| - jsAnonymousClass = find(library, '_Anonymous');
|
| + jsAnnotationClass = _find(library, 'JS');
|
| + jsAnonymousClass = _find(library, '_Anonymous');
|
| }
|
| }
|
|
|
| @@ -463,23 +466,23 @@ class BackendHelpers {
|
| }
|
|
|
| Element get badMain {
|
| - return findHelper('badMain');
|
| + return _findHelper('badMain');
|
| }
|
|
|
| Element get missingMain {
|
| - return findHelper('missingMain');
|
| + return _findHelper('missingMain');
|
| }
|
|
|
| Element get mainHasTooManyParameters {
|
| - return findHelper('mainHasTooManyParameters');
|
| + return _findHelper('mainHasTooManyParameters');
|
| }
|
|
|
| MethodElement get loadLibraryWrapper {
|
| - return findHelper("_loadLibraryWrapper");
|
| + return _findHelper("_loadLibraryWrapper");
|
| }
|
|
|
| Element get boolConversionCheck {
|
| - return findHelper('boolConversionCheck');
|
| + return _findHelper('boolConversionCheck');
|
| }
|
|
|
| MethodElement _traceHelper;
|
| @@ -491,148 +494,148 @@ class BackendHelpers {
|
| }
|
|
|
| MethodElement get _consoleTraceHelper {
|
| - return findHelper('consoleTraceHelper');
|
| + return _findHelper('consoleTraceHelper');
|
| }
|
|
|
| MethodElement get _postTraceHelper {
|
| - return findHelper('postTraceHelper');
|
| + return _findHelper('postTraceHelper');
|
| }
|
|
|
| FunctionElement get closureFromTearOff {
|
| - return findHelper('closureFromTearOff');
|
| + return _findHelper('closureFromTearOff');
|
| }
|
|
|
| Element get isJsIndexable {
|
| - return findHelper('isJsIndexable');
|
| + return _findHelper('isJsIndexable');
|
| }
|
|
|
| Element get throwIllegalArgumentException {
|
| - return findHelper('iae');
|
| + return _findHelper('iae');
|
| }
|
|
|
| Element get throwIndexOutOfRangeException {
|
| - return findHelper('ioore');
|
| + return _findHelper('ioore');
|
| }
|
|
|
| Element get exceptionUnwrapper {
|
| - return findHelper('unwrapException');
|
| + return _findHelper('unwrapException');
|
| }
|
|
|
| Element get throwRuntimeError {
|
| - return findHelper('throwRuntimeError');
|
| + return _findHelper('throwRuntimeError');
|
| }
|
|
|
| Element get throwTypeError {
|
| - return findHelper('throwTypeError');
|
| + return _findHelper('throwTypeError');
|
| }
|
|
|
| Element get throwAbstractClassInstantiationError {
|
| - return findHelper('throwAbstractClassInstantiationError');
|
| + return _findHelper('throwAbstractClassInstantiationError');
|
| }
|
|
|
| Element get checkConcurrentModificationError {
|
| if (cachedCheckConcurrentModificationError == null) {
|
| cachedCheckConcurrentModificationError =
|
| - findHelper('checkConcurrentModificationError');
|
| + _findHelper('checkConcurrentModificationError');
|
| }
|
| return cachedCheckConcurrentModificationError;
|
| }
|
|
|
| Element get throwConcurrentModificationError {
|
| - return findHelper('throwConcurrentModificationError');
|
| + return _findHelper('throwConcurrentModificationError');
|
| }
|
|
|
| - Element get checkInt => _checkInt ??= findHelper('checkInt');
|
| + Element get checkInt => _checkInt ??= _findHelper('checkInt');
|
| Element _checkInt;
|
|
|
| - Element get checkNum => _checkNum ??= findHelper('checkNum');
|
| + Element get checkNum => _checkNum ??= _findHelper('checkNum');
|
| Element _checkNum;
|
|
|
| - Element get checkString => _checkString ??= findHelper('checkString');
|
| + Element get checkString => _checkString ??= _findHelper('checkString');
|
| Element _checkString;
|
|
|
| Element get stringInterpolationHelper {
|
| - return findHelper('S');
|
| + return _findHelper('S');
|
| }
|
|
|
| Element get wrapExceptionHelper {
|
| - return findHelper(r'wrapException');
|
| + return _findHelper(r'wrapException');
|
| }
|
|
|
| Element get throwExpressionHelper {
|
| - return findHelper('throwExpression');
|
| + return _findHelper('throwExpression');
|
| }
|
|
|
| Element get closureConverter {
|
| - return findHelper('convertDartClosureToJS');
|
| + return _findHelper('convertDartClosureToJS');
|
| }
|
|
|
| Element get traceFromException {
|
| - return findHelper('getTraceFromException');
|
| + return _findHelper('getTraceFromException');
|
| }
|
|
|
| Element get setRuntimeTypeInfo {
|
| - return findHelper('setRuntimeTypeInfo');
|
| + return _findHelper('setRuntimeTypeInfo');
|
| }
|
|
|
| Element get getRuntimeTypeInfo {
|
| - return findHelper('getRuntimeTypeInfo');
|
| + return _findHelper('getRuntimeTypeInfo');
|
| }
|
|
|
| Element get getTypeArgumentByIndex {
|
| - return findHelper('getTypeArgumentByIndex');
|
| + return _findHelper('getTypeArgumentByIndex');
|
| }
|
|
|
| Element get computeSignature {
|
| - return findHelper('computeSignature');
|
| + return _findHelper('computeSignature');
|
| }
|
|
|
| Element get getRuntimeTypeArguments {
|
| - return findHelper('getRuntimeTypeArguments');
|
| + return _findHelper('getRuntimeTypeArguments');
|
| }
|
|
|
| Element get getRuntimeTypeArgument {
|
| - return findHelper('getRuntimeTypeArgument');
|
| + return _findHelper('getRuntimeTypeArgument');
|
| }
|
|
|
| Element get runtimeTypeToString {
|
| - return findHelper('runtimeTypeToString');
|
| + return _findHelper('runtimeTypeToString');
|
| }
|
|
|
| Element get assertIsSubtype {
|
| - return findHelper('assertIsSubtype');
|
| + return _findHelper('assertIsSubtype');
|
| }
|
|
|
| Element get checkSubtype {
|
| - return findHelper('checkSubtype');
|
| + return _findHelper('checkSubtype');
|
| }
|
|
|
| Element get assertSubtype {
|
| - return findHelper('assertSubtype');
|
| + return _findHelper('assertSubtype');
|
| }
|
|
|
| Element get subtypeCast {
|
| - return findHelper('subtypeCast');
|
| + return _findHelper('subtypeCast');
|
| }
|
|
|
| Element get checkSubtypeOfRuntimeType {
|
| - return findHelper('checkSubtypeOfRuntimeType');
|
| + return _findHelper('checkSubtypeOfRuntimeType');
|
| }
|
|
|
| Element get assertSubtypeOfRuntimeType {
|
| - return findHelper('assertSubtypeOfRuntimeType');
|
| + return _findHelper('assertSubtypeOfRuntimeType');
|
| }
|
|
|
| Element get subtypeOfRuntimeTypeCast {
|
| - return findHelper('subtypeOfRuntimeTypeCast');
|
| + return _findHelper('subtypeOfRuntimeTypeCast');
|
| }
|
|
|
| Element get checkDeferredIsLoaded {
|
| - return findHelper('checkDeferredIsLoaded');
|
| + return _findHelper('checkDeferredIsLoaded');
|
| }
|
|
|
| Element get throwNoSuchMethod {
|
| - return findHelper('throwNoSuchMethod');
|
| + return _findHelper('throwNoSuchMethod');
|
| }
|
|
|
| Element get genericNoSuchMethod =>
|
| @@ -648,75 +651,75 @@ class BackendHelpers {
|
| MethodElement _malformedTypeError;
|
|
|
| Element get createRuntimeType {
|
| - return findHelper('createRuntimeType');
|
| + return _findHelper('createRuntimeType');
|
| }
|
|
|
| Element get fallThroughError {
|
| - return findHelper("getFallThroughError");
|
| + return _findHelper("getFallThroughError");
|
| }
|
|
|
| Element get createInvocationMirror {
|
| - return findHelper('createInvocationMirror');
|
| + return _findHelper('createInvocationMirror');
|
| }
|
|
|
| Element get cyclicThrowHelper {
|
| - return findHelper("throwCyclicInit");
|
| + return _findHelper("throwCyclicInit");
|
| }
|
|
|
| Element get asyncHelper {
|
| - return findAsyncHelper("_asyncHelper");
|
| + return _findAsyncHelper("_asyncHelper");
|
| }
|
|
|
| Element get wrapBody {
|
| - return findAsyncHelper("_wrapJsFunctionForAsync");
|
| + return _findAsyncHelper("_wrapJsFunctionForAsync");
|
| }
|
|
|
| Element get yieldStar {
|
| - ClassElement classElement = findAsyncHelper("_IterationMarker");
|
| + ClassElement classElement = _findAsyncHelper("_IterationMarker");
|
| classElement.ensureResolved(resolution);
|
| return classElement.lookupLocalMember("yieldStar");
|
| }
|
|
|
| Element get yieldSingle {
|
| - ClassElement classElement = findAsyncHelper("_IterationMarker");
|
| + ClassElement classElement = _findAsyncHelper("_IterationMarker");
|
| classElement.ensureResolved(resolution);
|
| return classElement.lookupLocalMember("yieldSingle");
|
| }
|
|
|
| Element get syncStarUncaughtError {
|
| - ClassElement classElement = findAsyncHelper("_IterationMarker");
|
| + ClassElement classElement = _findAsyncHelper("_IterationMarker");
|
| classElement.ensureResolved(resolution);
|
| return classElement.lookupLocalMember("uncaughtError");
|
| }
|
|
|
| Element get asyncStarHelper {
|
| - return findAsyncHelper("_asyncStarHelper");
|
| + return _findAsyncHelper("_asyncStarHelper");
|
| }
|
|
|
| Element get streamOfController {
|
| - return findAsyncHelper("_streamOfController");
|
| + return _findAsyncHelper("_streamOfController");
|
| }
|
|
|
| Element get endOfIteration {
|
| - ClassElement classElement = findAsyncHelper("_IterationMarker");
|
| + ClassElement classElement = _findAsyncHelper("_IterationMarker");
|
| classElement.ensureResolved(resolution);
|
| return classElement.lookupLocalMember("endOfIteration");
|
| }
|
|
|
| Element get syncStarIterable {
|
| - ClassElement classElement = findAsyncHelper("_SyncStarIterable");
|
| + ClassElement classElement = _findAsyncHelper("_SyncStarIterable");
|
| classElement.ensureResolved(resolution);
|
| return classElement;
|
| }
|
|
|
| Element get futureImplementation {
|
| - ClassElement classElement = findAsyncHelper('_Future');
|
| + ClassElement classElement = _findAsyncHelper('_Future');
|
| classElement.ensureResolved(resolution);
|
| return classElement;
|
| }
|
|
|
| Element get controllerStream {
|
| - ClassElement classElement = findAsyncHelper("_ControllerStream");
|
| + ClassElement classElement = _findAsyncHelper("_ControllerStream");
|
| classElement.ensureResolved(resolution);
|
| return classElement;
|
| }
|
| @@ -728,13 +731,13 @@ class BackendHelpers {
|
| }
|
|
|
| Element get syncCompleterConstructor {
|
| - ClassElement classElement = find(asyncLibrary, "Completer");
|
| + ClassElement classElement = _find(asyncLibrary, "Completer");
|
| classElement.ensureResolved(resolution);
|
| return classElement.lookupConstructor("sync");
|
| }
|
|
|
| Element get asyncStarController {
|
| - ClassElement classElement = findAsyncHelper("_AsyncStarStreamController");
|
| + ClassElement classElement = _findAsyncHelper("_AsyncStarStreamController");
|
| classElement.ensureResolved(resolution);
|
| return classElement;
|
| }
|
| @@ -745,65 +748,90 @@ class BackendHelpers {
|
| }
|
|
|
| Element get streamIteratorConstructor {
|
| - ClassElement classElement = find(asyncLibrary, "StreamIterator");
|
| + ClassElement classElement = _find(asyncLibrary, "StreamIterator");
|
| classElement.ensureResolved(resolution);
|
| return classElement.lookupConstructor("");
|
| }
|
|
|
| ClassElement get VoidRuntimeType {
|
| - return findHelper('VoidRuntimeType');
|
| + return _findHelper('VoidRuntimeType');
|
| }
|
|
|
| ClassElement get RuntimeType {
|
| - return findHelper('RuntimeType');
|
| + return _findHelper('RuntimeType');
|
| }
|
|
|
| ClassElement get RuntimeFunctionType {
|
| - return findHelper('RuntimeFunctionType');
|
| + return _findHelper('RuntimeFunctionType');
|
| }
|
|
|
| ClassElement get RuntimeTypePlain {
|
| - return findHelper('RuntimeTypePlain');
|
| + return _findHelper('RuntimeTypePlain');
|
| }
|
|
|
| ClassElement get RuntimeTypeGeneric {
|
| - return findHelper('RuntimeTypeGeneric');
|
| + return _findHelper('RuntimeTypeGeneric');
|
| }
|
|
|
| ClassElement get DynamicRuntimeType {
|
| - return findHelper('DynamicRuntimeType');
|
| + return _findHelper('DynamicRuntimeType');
|
| + }
|
| +
|
| + MethodElement get getDynamicRuntimeType {
|
| + // TODO(johnniwinther): Support this in mocks.
|
| + return jsHelperLibrary.find('getDynamicRuntimeType');
|
| + }
|
| +
|
| + MethodElement get getVoidRuntimeType {
|
| + // TODO(johnniwinther): Support this in mocks.
|
| + return jsHelperLibrary.find('getVoidRuntimeType');
|
| + }
|
| +
|
| + MethodElement get buildInterfaceType {
|
| + // TODO(johnniwinther): Support this in mocks.
|
| + return jsHelperLibrary.find('buildInterfaceType');
|
| + }
|
| +
|
| + MethodElement get buildFunctionType {
|
| + // TODO(johnniwinther): Support this in mocks.
|
| + return jsHelperLibrary.find('buildFunctionType');
|
| + }
|
| +
|
| + MethodElement get buildNamedFunctionType {
|
| + // TODO(johnniwinther): Support this in mocks.
|
| + return jsHelperLibrary.find('buildNamedFunctionType');
|
| }
|
|
|
| MethodElement get functionTypeTestMetaHelper {
|
| - return findHelper('functionTypeTestMetaHelper');
|
| + return _findHelper('functionTypeTestMetaHelper');
|
| }
|
|
|
| MethodElement get defineProperty {
|
| - return findHelper('defineProperty');
|
| + return _findHelper('defineProperty');
|
| }
|
|
|
| Element get startRootIsolate {
|
| - return find(isolateHelperLibrary, START_ROOT_ISOLATE);
|
| + return _find(isolateHelperLibrary, START_ROOT_ISOLATE);
|
| }
|
|
|
| Element get currentIsolate {
|
| - return find(isolateHelperLibrary, '_currentIsolate');
|
| + return _find(isolateHelperLibrary, '_currentIsolate');
|
| }
|
|
|
| Element get callInIsolate {
|
| - return find(isolateHelperLibrary, '_callInIsolate');
|
| + return _find(isolateHelperLibrary, '_callInIsolate');
|
| }
|
|
|
| Element get findIndexForNativeSubclassType {
|
| - return findInterceptor('findIndexForNativeSubclassType');
|
| + return _findInterceptor('findIndexForNativeSubclassType');
|
| }
|
|
|
| Element get convertRtiToRuntimeType {
|
| - return findHelper('convertRtiToRuntimeType');
|
| + return _findHelper('convertRtiToRuntimeType');
|
| }
|
|
|
| ClassElement get stackTraceClass {
|
| - return findHelper('_StackTrace');
|
| + return _findHelper('_StackTrace');
|
| }
|
|
|
| MethodElement _objectNoSuchMethod;
|
| @@ -815,4 +843,33 @@ class BackendHelpers {
|
| }
|
| return _objectNoSuchMethod;
|
| }
|
| +
|
| + ClassElement get constantMapClass =>
|
| + _findHelper(JavaScriptMapConstant.DART_CLASS);
|
| + ClassElement get constantStringMapClass =>
|
| + _findHelper(JavaScriptMapConstant.DART_STRING_CLASS);
|
| + ClassElement get constantProtoMapClass =>
|
| + _findHelper(JavaScriptMapConstant.DART_PROTO_CLASS);
|
| + ClassElement get generalConstantMapClass =>
|
| + _findHelper(JavaScriptMapConstant.DART_GENERAL_CLASS);
|
| +
|
| + ClassElement get annotationCreatesClass {
|
| + return _findHelper('Creates');
|
| + }
|
| +
|
| + ClassElement get annotationReturnsClass {
|
| + return _findHelper('Returns');
|
| + }
|
| +
|
| + ClassElement get annotationJSNameClass {
|
| + return _findHelper('JSName');
|
| + }
|
| +
|
| + MethodElement get toStringForNativeObject {
|
| + return _findHelper('toStringForNativeObject');
|
| + }
|
| +
|
| + MethodElement get hashCodeForNativeObject {
|
| + return _findHelper('hashCodeForNativeObject');
|
| + }
|
| }
|
|
|