Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1019)

Unified Diff: pkg/compiler/lib/src/js_backend/native_data.dart

Issue 2045223002: Compute and cache element NativeBehavior during resolution. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Temporarily skip compilation subtest Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/js_backend/js_backend.dart ('k') | pkg/compiler/lib/src/native/behavior.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+ }
}
« no previous file with comments | « pkg/compiler/lib/src/js_backend/js_backend.dart ('k') | pkg/compiler/lib/src/native/behavior.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698