| 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 49a207dff8ab6c4f735b885425c0e5e10d25d8d0..42712f00d36c71500561012bf8bf5994b58e2253 100644
|
| --- a/pkg/compiler/lib/src/js_backend/native_data.dart
|
| +++ b/pkg/compiler/lib/src/js_backend/native_data.dart
|
| @@ -6,7 +6,8 @@ library js_backend.native_data;
|
|
|
| import '../common.dart';
|
| import '../elements/elements.dart'
|
| - show ClassElement, Element, FunctionElement, MemberElement;
|
| + show ClassElement, Element, FieldElement, FunctionElement, MemberElement;
|
| +import '../native/behavior.dart' show NativeBehavior;
|
|
|
| /// Additional element information for native classes and methods and js-interop
|
| /// methods.
|
| @@ -22,6 +23,19 @@ class NativeData {
|
| /// [setNativeClassTagInfo].
|
| Map<ClassElement, String> nativeClassTagInfo = <ClassElement, String>{};
|
|
|
| + // TODO(johnniwinther): Serialize these.
|
| + /// Cache for [NativeBehavior]s for calling native methods.
|
| + Map<FunctionElement, NativeBehavior> nativeMethodBehavior =
|
| + <FunctionElement, NativeBehavior>{};
|
| +
|
| + /// Cache for [NativeBehavior]s for reading from native fields.
|
| + Map<MemberElement, NativeBehavior> nativeFieldLoadBehavior =
|
| + <FieldElement, NativeBehavior>{};
|
| +
|
| + /// Cache for [NativeBehavior]s for writing to native fields.
|
| + Map<MemberElement, NativeBehavior> nativeFieldStoreBehavior =
|
| + <FieldElement, NativeBehavior>{};
|
| +
|
| /// Returns `true` if [element] is explicitly marked as part of JsInterop.
|
| bool _isJsInterop(Element element) {
|
| return jsInteropNames.containsKey(element.declaration);
|
| @@ -163,4 +177,44 @@ class NativeData {
|
| bool hasNativeTagsForcedNonLeaf(ClassElement cls) {
|
| return getNativeTagsOfClassRaw(cls).contains('!nonleaf');
|
| }
|
| +
|
| + /// Returns the [NativeBehavior] for calling the native [method].
|
| + NativeBehavior getNativeMethodBehavior(FunctionElement method) {
|
| + assert(invariant(method, nativeMethodBehavior.containsKey(method),
|
| + message: "No native method behavior has been computed for $method."));
|
| + return nativeMethodBehavior[method];
|
| + }
|
| +
|
| + /// Returns the [NativeBehavior] for reading from the native [field].
|
| + NativeBehavior getNativeFieldLoadBehavior(FieldElement field) {
|
| + assert(invariant(field, nativeFieldLoadBehavior.containsKey(field),
|
| + message: "No native field load behavior has been "
|
| + "computed for $field."));
|
| + return nativeFieldLoadBehavior[field];
|
| + }
|
| +
|
| + /// Returns the [NativeBehavior] for writing to the native [field].
|
| + NativeBehavior getNativeFieldStoreBehavior(FieldElement field) {
|
| + assert(invariant(field, nativeFieldStoreBehavior.containsKey(field),
|
| + message: "No native field store behavior has been "
|
| + "computed for $field."));
|
| + return nativeFieldStoreBehavior[field];
|
| + }
|
| +
|
| + /// Registers the [behavior] for calling the native [method].
|
| + void setNativeMethodBehavior(
|
| + FunctionElement method, NativeBehavior behavior) {
|
| + nativeMethodBehavior[method] = behavior;
|
| + }
|
| +
|
| + /// Registers the [behavior] for reading from the native [field].
|
| + void setNativeFieldLoadBehavior(FieldElement field, NativeBehavior behavior) {
|
| + nativeFieldLoadBehavior[field] = behavior;
|
| + }
|
| +
|
| + /// Registers the [behavior] for writing to the native [field].
|
| + void setNativeFieldStoreBehavior(
|
| + FieldElement field, NativeBehavior behavior) {
|
| + nativeFieldStoreBehavior[field] = behavior;
|
| + }
|
| }
|
|
|