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

Side by Side Diff: pkg/compiler/lib/src/js_backend/backend_serialization.dart

Issue 2731163002: Split js interop registration into library/class/member elements (Closed)
Patch Set: Updated cf. comments Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/field_naming_mixin.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library js_backend.serialization; 5 library js_backend.serialization;
6 6
7 import '../common/backend_api.dart' show BackendSerialization; 7 import '../common/backend_api.dart' show BackendSerialization;
8 import '../elements/elements.dart'; 8 import '../elements/elements.dart';
9 import '../elements/resolution_types.dart'; 9 import '../elements/resolution_types.dart';
10 import '../elements/types.dart'; 10 import '../elements/types.dart';
(...skipping 21 matching lines...) Expand all
32 32
33 class JavaScriptBackendSerialization implements BackendSerialization { 33 class JavaScriptBackendSerialization implements BackendSerialization {
34 final JavaScriptBackendSerializer serializer; 34 final JavaScriptBackendSerializer serializer;
35 final JavaScriptBackendDeserializer deserializer; 35 final JavaScriptBackendDeserializer deserializer;
36 36
37 JavaScriptBackendSerialization(NativeData nativeData) 37 JavaScriptBackendSerialization(NativeData nativeData)
38 : serializer = new JavaScriptBackendSerializer(nativeData), 38 : serializer = new JavaScriptBackendSerializer(nativeData),
39 deserializer = new JavaScriptBackendDeserializer(nativeData); 39 deserializer = new JavaScriptBackendDeserializer(nativeData);
40 } 40 }
41 41
42 const Key JS_INTEROP_NAME = const Key('jsInteropName'); 42 const Key JS_INTEROP_LIBRARY_NAME = const Key('jsInteropLibraryName');
43 const Key JS_INTEROP_CLASS_NAME = const Key('jsInteropClassName');
44 const Key JS_INTEROP_MEMBER_NAME = const Key('jsInteropMemberName');
43 const Key NATIVE_MEMBER_NAME = const Key('nativeMemberName'); 45 const Key NATIVE_MEMBER_NAME = const Key('nativeMemberName');
44 const Key NATIVE_CLASS_TAG_INFO = const Key('nativeClassTagInfo'); 46 const Key NATIVE_CLASS_TAG_INFO = const Key('nativeClassTagInfo');
45 const Key NATIVE_METHOD_BEHAVIOR = const Key('nativeMethodBehavior'); 47 const Key NATIVE_METHOD_BEHAVIOR = const Key('nativeMethodBehavior');
46 const Key NATIVE_FIELD_LOAD_BEHAVIOR = const Key('nativeFieldLoadBehavior'); 48 const Key NATIVE_FIELD_LOAD_BEHAVIOR = const Key('nativeFieldLoadBehavior');
47 const Key NATIVE_FIELD_STORE_BEHAVIOR = const Key('nativeFieldStoreBehavior'); 49 const Key NATIVE_FIELD_STORE_BEHAVIOR = const Key('nativeFieldStoreBehavior');
48 50
49 class JavaScriptBackendSerializer implements SerializerPlugin { 51 class JavaScriptBackendSerializer implements SerializerPlugin {
50 final NativeDataImpl nativeData; 52 final NativeDataImpl nativeData;
51 53
52 JavaScriptBackendSerializer(this.nativeData); 54 JavaScriptBackendSerializer(this.nativeData);
53 55
54 @override 56 @override
55 void onElement(Element element, ObjectEncoder createEncoder(String tag)) { 57 void onElement(Element element, ObjectEncoder createEncoder(String tag)) {
56 ObjectEncoder encoder; 58 ObjectEncoder encoder;
57 ObjectEncoder getEncoder() { 59 ObjectEncoder getEncoder() {
58 return encoder ??= createEncoder(_BACKEND_DATA_TAG); 60 return encoder ??= createEncoder(_BACKEND_DATA_TAG);
59 } 61 }
60 62
61 String jsInteropName = nativeData.jsInteropNames[element]; 63 String jsInteropLibraryName = nativeData.jsInteropLibraryNames[element];
62 if (jsInteropName != null) { 64 if (jsInteropLibraryName != null) {
63 getEncoder().setString(JS_INTEROP_NAME, jsInteropName); 65 getEncoder().setString(JS_INTEROP_LIBRARY_NAME, jsInteropLibraryName);
66 }
67 String jsInteropClassName = nativeData.jsInteropClassNames[element];
68 if (jsInteropClassName != null) {
69 getEncoder().setString(JS_INTEROP_CLASS_NAME, jsInteropClassName);
70 }
71 String jsInteropMemberName = nativeData.jsInteropMemberNames[element];
72 if (jsInteropMemberName != null) {
73 getEncoder().setString(JS_INTEROP_MEMBER_NAME, jsInteropMemberName);
64 } 74 }
65 String nativeMemberName = nativeData.nativeMemberName[element]; 75 String nativeMemberName = nativeData.nativeMemberName[element];
66 if (nativeMemberName != null) { 76 if (nativeMemberName != null) {
67 getEncoder().setString(NATIVE_MEMBER_NAME, nativeMemberName); 77 getEncoder().setString(NATIVE_MEMBER_NAME, nativeMemberName);
68 } 78 }
69 String nativeClassTagInfo = nativeData.nativeClassTagInfo[element]; 79 String nativeClassTagInfo = nativeData.nativeClassTagInfo[element];
70 if (nativeClassTagInfo != null) { 80 if (nativeClassTagInfo != null) {
71 getEncoder().setString(NATIVE_CLASS_TAG_INFO, nativeClassTagInfo); 81 getEncoder().setString(NATIVE_CLASS_TAG_INFO, nativeClassTagInfo);
72 } 82 }
73 NativeBehavior nativeMethodBehavior = 83 NativeBehavior nativeMethodBehavior =
(...skipping 26 matching lines...) Expand all
100 110
101 class JavaScriptBackendDeserializer implements DeserializerPlugin { 111 class JavaScriptBackendDeserializer implements DeserializerPlugin {
102 final NativeDataImpl nativeData; 112 final NativeDataImpl nativeData;
103 113
104 JavaScriptBackendDeserializer(this.nativeData); 114 JavaScriptBackendDeserializer(this.nativeData);
105 115
106 @override 116 @override
107 void onElement(Element element, ObjectDecoder getDecoder(String tag)) { 117 void onElement(Element element, ObjectDecoder getDecoder(String tag)) {
108 ObjectDecoder decoder = getDecoder(_BACKEND_DATA_TAG); 118 ObjectDecoder decoder = getDecoder(_BACKEND_DATA_TAG);
109 if (decoder != null) { 119 if (decoder != null) {
110 String jsInteropName = 120 String jsInteropLibraryName =
111 decoder.getString(JS_INTEROP_NAME, isOptional: true); 121 decoder.getString(JS_INTEROP_LIBRARY_NAME, isOptional: true);
112 if (jsInteropName != null) { 122 if (jsInteropLibraryName != null) {
113 nativeData.jsInteropNames[element] = jsInteropName; 123 nativeData.jsInteropLibraryNames[element] = jsInteropLibraryName;
124 }
125 String jsInteropClassName =
126 decoder.getString(JS_INTEROP_CLASS_NAME, isOptional: true);
127 if (jsInteropClassName != null) {
128 nativeData.jsInteropClassNames[element] = jsInteropClassName;
129 }
130 String jsInteropMemberName =
131 decoder.getString(JS_INTEROP_MEMBER_NAME, isOptional: true);
132 if (jsInteropMemberName != null) {
133 nativeData.jsInteropMemberNames[element] = jsInteropMemberName;
114 } 134 }
115 String nativeMemberName = 135 String nativeMemberName =
116 decoder.getString(NATIVE_MEMBER_NAME, isOptional: true); 136 decoder.getString(NATIVE_MEMBER_NAME, isOptional: true);
117 if (nativeMemberName != null) { 137 if (nativeMemberName != null) {
118 nativeData.nativeMemberName[element] = nativeMemberName; 138 nativeData.nativeMemberName[element] = nativeMemberName;
119 } 139 }
120 String nativeClassTagInfo = 140 String nativeClassTagInfo =
121 decoder.getString(NATIVE_CLASS_TAG_INFO, isOptional: true); 141 decoder.getString(NATIVE_CLASS_TAG_INFO, isOptional: true);
122 if (nativeClassTagInfo != null) { 142 if (nativeClassTagInfo != null) {
123 nativeData.nativeClassTagInfo[element] = nativeClassTagInfo; 143 nativeData.nativeClassTagInfo[element] = nativeClassTagInfo;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 behavior.codeTemplate = js.js.parseForeignJS(behavior.codeTemplateText); 270 behavior.codeTemplate = js.js.parseForeignJS(behavior.codeTemplateText);
251 } 271 }
252 272
253 behavior.throwBehavior = 273 behavior.throwBehavior =
254 decoder.getEnum(THROW_BEHAVIOR, NativeThrowBehavior.values); 274 decoder.getEnum(THROW_BEHAVIOR, NativeThrowBehavior.values);
255 behavior.isAllocation = decoder.getBool(IS_ALLOCATION); 275 behavior.isAllocation = decoder.getBool(IS_ALLOCATION);
256 behavior.useGvn = decoder.getBool(USE_GVN); 276 behavior.useGvn = decoder.getBool(USE_GVN);
257 return behavior; 277 return behavior;
258 } 278 }
259 } 279 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/field_naming_mixin.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698