Chromium Code Reviews| Index: pkg/compiler/lib/src/js_backend/backend.dart |
| diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart |
| index 67a93675cb473c45c72901ead3210827fa22e69f..57daada8c1c4ca9e185037d815da9db8ef04ff62 100644 |
| --- a/pkg/compiler/lib/src/js_backend/backend.dart |
| +++ b/pkg/compiler/lib/src/js_backend/backend.dart |
| @@ -233,6 +233,8 @@ class JavaScriptBackend extends Backend { |
| new Uri(scheme: 'dart', path: '_js_embedded_names'); |
| static final Uri DART_ISOLATE_HELPER = |
| new Uri(scheme: 'dart', path: '_isolate_helper'); |
| + static final Uri PACKAGE_JS = |
| + new Uri(scheme: 'package', path: 'js/js.dart'); |
| static final Uri PACKAGE_LOOKUP_MAP = |
| new Uri(scheme: 'package', path: 'lookup_map/lookup_map.dart'); |
| @@ -294,6 +296,8 @@ class JavaScriptBackend extends Backend { |
| ClassElement jsBoolClass; |
| ClassElement jsPlainJavaScriptObjectClass; |
| ClassElement jsUnknownJavaScriptObjectClass; |
| + ClassElement jsJavaScriptFunctionClass; |
| + ClassElement jsJavaScriptObjectClass; |
| ClassElement jsIndexableClass; |
| ClassElement jsMutableIndexableClass; |
| @@ -331,6 +335,8 @@ class JavaScriptBackend extends Backend { |
| ClassElement forceInlineClass; |
| ClassElement irRepresentationClass; |
| + ClassElement jsAnnotationClass; |
| + |
| Element getInterceptorMethod; |
| ClassElement jsInvocationMirrorClass; |
| @@ -619,6 +625,9 @@ class JavaScriptBackend extends Backend { |
| /// Codegen support for tree-shaking entries of `LookupMap`. |
| LookupMapAnalysis lookupMapAnalysis; |
| + /// Codegen support for typed JavaScript interop. |
| + JsInteropAnalysis jsInteropAnalysis; |
| + |
| /// Support for classifying `noSuchMethod` implementations. |
| NoSuchMethodRegistry noSuchMethodRegistry; |
| @@ -653,6 +662,8 @@ class JavaScriptBackend extends Backend { |
| typeVariableHandler = new TypeVariableHandler(compiler); |
| customElementsAnalysis = new CustomElementsAnalysis(this); |
| lookupMapAnalysis = new LookupMapAnalysis(this); |
| + jsInteropAnalysis = new JsInteropAnalysis(this); |
| + |
| noSuchMethodRegistry = new NoSuchMethodRegistry(this); |
| constantCompilerTask = new JavaScriptConstantTask(compiler); |
| resolutionCallbacks = new JavaScriptResolutionCallbacks(this); |
| @@ -674,7 +685,7 @@ class JavaScriptBackend extends Backend { |
| } |
| FunctionElement resolveExternalFunction(FunctionElement element) { |
| - if (isForeign(element)) return element; |
| + if (isForeign(element) || element.isJsInterop) return element; |
| return patchResolverTask.measure(() { |
| return patchResolverTask.resolveExternalFunction(element); |
| }); |
| @@ -903,6 +914,9 @@ class JavaScriptBackend extends Backend { |
| if (enqueuer.isResolutionQueue) { |
| cls.ensureResolved(resolution); |
| cls.forEachMember((ClassElement classElement, Element member) { |
| + // TODO(jacobr): this is the wrong place to be reporting errors. |
|
sra1
2015/10/13 03:31:36
Since there is already a test that shows this prob
|
| + // Reporting the error here will result in the error being reported |
| + // multiple times. |
| if (member.name == Identifiers.call) { |
| compiler.reportErrorMessage( |
| member, |
| @@ -1077,7 +1091,9 @@ class JavaScriptBackend extends Backend { |
| } else if (Elements.isNativeOrExtendsNative(cls)) { |
| enqueue(enqueuer, getNativeInterceptorMethod, registry); |
| enqueueClass(enqueuer, jsInterceptorClass, compiler.globalDependencies); |
| + enqueueClass(enqueuer, jsJavaScriptObjectClass, registry); |
| enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, registry); |
| + enqueueClass(enqueuer, jsJavaScriptFunctionClass, registry); |
| } else if (cls == mapLiteralClass) { |
| // For map literals, the dependency between the implementation class |
| // and [Map] is not visible, so we have to add it manually. |
| @@ -1154,10 +1170,14 @@ class JavaScriptBackend extends Backend { |
| addInterceptors(jsUInt31Class, enqueuer, registry); |
| addInterceptors(jsDoubleClass, enqueuer, registry); |
| addInterceptors(jsNumberClass, enqueuer, registry); |
| + } else if (cls == jsJavaScriptObjectClass) { |
| + addInterceptors(jsJavaScriptObjectClass, enqueuer, registry); |
| } else if (cls == jsPlainJavaScriptObjectClass) { |
| addInterceptors(jsPlainJavaScriptObjectClass, enqueuer, registry); |
| } else if (cls == jsUnknownJavaScriptObjectClass) { |
| addInterceptors(jsUnknownJavaScriptObjectClass, enqueuer, registry); |
| + } else if (cls == jsJavaScriptFunctionClass) { |
| + addInterceptors(jsJavaScriptFunctionClass, enqueuer, registry); |
| } else if (Elements.isNativeOrExtendsNative(cls)) { |
| addInterceptorsForNativeClassMembers(cls, enqueuer); |
| } else if (cls == jsIndexingBehaviorInterface) { |
| @@ -1187,7 +1207,9 @@ class JavaScriptBackend extends Backend { |
| if (!enqueuer.nativeEnqueuer.hasInstantiatedNativeClasses()) return; |
| Registry registry = compiler.globalDependencies; |
| enqueue(enqueuer, getNativeInterceptorMethod, registry); |
| + enqueueClass(enqueuer, jsJavaScriptObjectClass, registry); |
| enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, registry); |
| + enqueueClass(enqueuer, jsJavaScriptFunctionClass, registry); |
| needToInitializeIsolateAffinityTag = true; |
| needToInitializeDispatchProperty = true; |
| } |
| @@ -1550,6 +1572,7 @@ class JavaScriptBackend extends Backend { |
| } |
| ClassElement defaultSuperclass(ClassElement element) { |
| + if (element.isJsInterop) return jsJavaScriptObjectClass; |
| // Native classes inherit from Interceptor. |
| return element.isNative ? jsInterceptorClass : compiler.objectClass; |
| } |
| @@ -2178,6 +2201,8 @@ class JavaScriptBackend extends Backend { |
| jsExtendableArrayClass = findClass('JSExtendableArray'); |
| jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray'); |
| jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject'); |
| + jsJavaScriptObjectClass = findClass('JavaScriptObject'); |
| + jsJavaScriptFunctionClass = findClass('JavaScriptFunction'); |
| jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject'); |
| jsIndexableClass = findClass('JSIndexable'); |
| jsMutableIndexableClass = findClass('JSMutableIndexable'); |
| @@ -2220,6 +2245,8 @@ class JavaScriptBackend extends Backend { |
| } else if (uri == Uris.dart__native_typed_data) { |
| typedArrayClass = findClass('NativeTypedArray'); |
| typedArrayOfIntClass = findClass('NativeTypedArrayOfInt'); |
| + } else if (uri == PACKAGE_JS) { |
| + jsAnnotationClass = find(library, 'Js'); |
| } |
| annotations.onLibraryScanned(library); |
| }); |
| @@ -2666,6 +2693,7 @@ class JavaScriptBackend extends Backend { |
| void onQueueClosed() { |
| lookupMapAnalysis.onQueueClosed(); |
| + jsInteropAnalysis.onQueueClosed(); |
| } |
| void onCodegenStart() { |