Index: pkg/compiler/lib/src/js_backend/native_data.dart |
diff --git a/pkg/compiler/lib/src/js_backend/native_data.dart b/pkg/compiler/lib/src/js_backend/native_data.dart |
index 5029821e0f105e48883b1300041833553466850c..67f495368e14d6ae2a612d3bef18f33a62ed3703 100644 |
--- a/pkg/compiler/lib/src/js_backend/native_data.dart |
+++ b/pkg/compiler/lib/src/js_backend/native_data.dart |
@@ -30,6 +30,9 @@ abstract class NativeBasicData { |
/// Returns `true` if [element] or any of its superclasses is native. |
bool isNativeOrExtendsNative(ClassEntity element); |
+ /// Returns `true` if js interop features are used. |
+ bool get isJsInteropUsed; |
+ |
/// Returns `true` if [element] is a JsInterop library. |
bool isJsInteropLibrary(LibraryEntity element); |
@@ -79,6 +82,9 @@ abstract class NativeData extends NativeBasicData { |
/// Returns the explicit js interop name for library [element]. |
String getJsInteropLibraryName(LibraryEntity element); |
+ /// Returns `true` if [element] has an `@Anonymous` annotation. |
+ bool isAnonymousJsInteropClass(ClassEntity element); |
+ |
/// Returns the explicit js interop name for class [element]. |
String getJsInteropClassName(ClassEntity element); |
@@ -132,6 +138,9 @@ abstract class NativeDataBuilder { |
/// Sets the explicit js interop [name] for the library [element]. |
void setJsInteropLibraryName(LibraryEntity element, String name); |
+ /// Marks [element] as having an `@Anonymous` annotation. |
+ void markJsInteropClassAsAnonymous(ClassEntity element); |
+ |
/// Sets the explicit js interop [name] for the class [element]. |
void setJsInteropClassName(ClassEntity element, String name); |
@@ -219,6 +228,9 @@ class NativeBasicDataImpl implements NativeBasicData { |
return nativeClassTagInfo[cls].isNonLeaf; |
} |
+ bool get isJsInteropUsed => |
+ jsInteropLibraries.isNotEmpty || jsInteropClasses.isNotEmpty; |
+ |
/// Returns `true` if [element] is explicitly marked as part of JsInterop. |
bool isJsInteropLibrary(LibraryEntity element) { |
return jsInteropLibraries.contains(element); |
@@ -264,6 +276,7 @@ class NativeDataImpl implements NativeDataBuilder, NativeData { |
/// The JavaScript names for elements implemented via typed JavaScript |
/// interop. |
Map<LibraryEntity, String> jsInteropLibraryNames = <LibraryEntity, String>{}; |
+ Set<ClassEntity> anonymousJsInteropClasses = new Set<ClassEntity>(); |
Map<ClassEntity, String> jsInteropClassNames = <ClassEntity, String>{}; |
/// The JavaScript names for elements implemented via typed JavaScript |
@@ -309,6 +322,16 @@ class NativeDataImpl implements NativeDataBuilder, NativeData { |
jsInteropLibraryNames[element] = name; |
} |
+ @override |
+ bool isAnonymousJsInteropClass(ClassEntity element) { |
+ return anonymousJsInteropClasses.contains(element); |
+ } |
+ |
+ @override |
+ void markJsInteropClassAsAnonymous(ClassEntity element) { |
+ anonymousJsInteropClasses.add(element); |
+ } |
+ |
/// Sets the explicit js interop [name] for the class [element]. |
void setJsInteropClassName(ClassEntity element, String name) { |
assert(invariant(element, _nativeBasicData.isJsInteropClass(element), |
@@ -347,6 +370,8 @@ class NativeDataImpl implements NativeDataBuilder, NativeData { |
bool hasNativeTagsForcedNonLeaf(ClassEntity cls) => |
_nativeBasicData.hasNativeTagsForcedNonLeaf(cls); |
+ bool get isJsInteropUsed => _nativeBasicData.isJsInteropUsed; |
+ |
/// Returns `true` if [element] is a JsInterop library. |
bool isJsInteropLibrary(LibraryEntity element) => |
_nativeBasicData.isJsInteropLibrary(element); |