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 268eb3f79eb4c62732e558613dbd620dbc547a28..d71fa17d72562b881cfa116af510c11fcebffc12 100644 |
--- a/pkg/compiler/lib/src/js_backend/native_data.dart |
+++ b/pkg/compiler/lib/src/js_backend/native_data.dart |
@@ -16,9 +16,11 @@ import '../elements/elements.dart' |
import '../elements/entities.dart'; |
import '../native/behavior.dart' show NativeBehavior; |
-/// Additional element information for native classes and methods and js-interop |
-/// methods. |
-abstract class NativeData { |
+/// Basic information for native classes and methods and js-interop |
+/// classes. |
+/// |
+/// This information is computed during loading using [NativeClassDataBuilder]. |
+abstract class NativeClassData { |
/// Returns `true` if [cls] corresponds to a native JavaScript class. |
/// |
/// A class is marked as native either through the `@Native(...)` annotation |
@@ -26,6 +28,9 @@ abstract class NativeData { |
/// mechanism allowed for user libraries. |
bool isNativeClass(ClassEntity element); |
+ /// Returns `true` if [element] or any of its superclasses is native. |
+ bool isNativeOrExtendsNative(ClassElement element); |
+ |
/// Returns `true` if [element] corresponds to a native JavaScript member. |
/// |
/// A member is marked as native either through the native mechanism |
@@ -34,8 +39,23 @@ abstract class NativeData { |
/// libraries. |
bool isNativeMember(MemberEntity element); |
- /// Returns `true` if [element] or any of its superclasses is native. |
- bool isNativeOrExtendsNative(ClassElement element); |
+ /// Returns `true` if [element] is a JsInterop class. |
+ bool isJsInteropClass(ClassElement element); |
+} |
+ |
+/// Additional element information for native classes and methods and js-interop |
+/// methods. |
+/// |
+/// This information is computed during resolution using [NativeDataBuilder]. |
+abstract class NativeData extends NativeClassData { |
+ /// Returns the [NativeBehavior] for calling the native [method]. |
+ NativeBehavior getNativeMethodBehavior(MethodElement method); |
+ |
+ /// Returns the [NativeBehavior] for reading from the native [field]. |
+ NativeBehavior getNativeFieldLoadBehavior(FieldElement field); |
+ |
+ /// Returns the [NativeBehavior] for writing to the native [field]. |
+ NativeBehavior getNativeFieldStoreBehavior(FieldElement field); |
/// Returns `true` if the name of [element] is fixed for the generated |
/// JavaScript. |
@@ -51,21 +71,9 @@ abstract class NativeData { |
/// Returns `true` if [cls] has a `!nonleaf` tag word. |
bool hasNativeTagsForcedNonLeaf(ClassElement cls); |
- /// Returns the [NativeBehavior] for calling the native [method]. |
- NativeBehavior getNativeMethodBehavior(MethodElement method); |
- |
- /// Returns the [NativeBehavior] for reading from the native [field]. |
- NativeBehavior getNativeFieldLoadBehavior(FieldElement field); |
- |
- /// Returns the [NativeBehavior] for writing to the native [field]. |
- NativeBehavior getNativeFieldStoreBehavior(FieldElement field); |
- |
/// Returns `true` if [element] is part of JsInterop. |
bool isJsInterop(Element element); |
- /// Returns `true` if [element] is a JsInterop class. |
- bool isJsInteropClass(ClassElement element); |
- |
/// Returns `true` if [element] is a JsInterop method. |
bool isJsInteropMethod(MethodElement element); |
@@ -77,7 +85,7 @@ abstract class NativeData { |
String getUnescapedJSInteropName(String name); |
} |
-abstract class NativeDataBuilder { |
+abstract class NativeClassDataBuilder { |
/// Sets the native tag info for [cls]. |
/// |
/// The tag info string contains comma-separated 'words' which are either |
@@ -92,6 +100,15 @@ abstract class NativeDataBuilder { |
/// [element] in the generated JavaScript. |
void setNativeMemberName(MemberElement element, String name); |
+ /// Returns [element] as an explicit part of JsInterop. The js interop name is |
+ /// expected to be computed later. |
+ void markAsJsInterop(Element element); |
+ |
+ /// Sets the explicit js interop [name] for [element]. |
+ void setJsInteropName(Element element, String name); |
+} |
+ |
+abstract class NativeDataBuilder { |
/// Registers the [behavior] for calling the native [method]. |
void setNativeMethodBehavior(MethodElement method, NativeBehavior behavior); |
@@ -100,16 +117,10 @@ abstract class NativeDataBuilder { |
/// Registers the [behavior] for writing to the native [field]. |
void setNativeFieldStoreBehavior(FieldElement field, NativeBehavior behavior); |
- |
- /// Returns [element] as an explicit part of JsInterop. The js interop name is |
- /// expected to be computed later. |
- void markAsJsInterop(Element element); |
- |
- /// Sets the explicit js interop [name] for [element]. |
- void setJsInteropName(Element element, String name); |
} |
-class NativeDataImpl implements NativeData, NativeDataBuilder { |
+class NativeDataImpl |
+ implements NativeData, NativeDataBuilder, NativeClassDataBuilder { |
/// The JavaScript names for elements implemented via typed JavaScript |
/// interop. |
Map<Element, String> jsInteropNames = <Element, String>{}; |