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

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

Issue 2975433002: Assert that we don't mix K and J elements (Closed)
Patch Set: Created 3 years, 5 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
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';
11 import '../js/js.dart' as js; 11 import '../js/js.dart' as js;
12 import '../native/native.dart'; 12 import '../native/native.dart';
13 import '../resolution/resolution_strategy.dart';
13 import '../serialization/keys.dart'; 14 import '../serialization/keys.dart';
14 import '../serialization/serialization.dart' 15 import '../serialization/serialization.dart'
15 show DeserializerPlugin, ObjectDecoder, ObjectEncoder, SerializerPlugin; 16 show DeserializerPlugin, ObjectDecoder, ObjectEncoder, SerializerPlugin;
16 import '../universe/side_effects.dart'; 17 import '../universe/side_effects.dart';
17 import 'js_backend.dart'; 18 import 'js_backend.dart';
18 import 'native_data.dart'; 19 import 'native_data.dart';
19 20
20 const String _BACKEND_DATA_TAG = 'jsBackendData'; 21 const String _BACKEND_DATA_TAG = 'jsBackendData';
21 const Key DART_TYPES_RETURNED = const Key('dartTypesReturned'); 22 const Key DART_TYPES_RETURNED = const Key('dartTypesReturned');
22 const Key THIS_TYPES_RETURNED = const Key('thisTypesReturned'); 23 const Key THIS_TYPES_RETURNED = const Key('thisTypesReturned');
(...skipping 23 matching lines...) Expand all
46 const Key NATIVE_CLASS_TAG_INFO = const Key('nativeClassTagInfo'); 47 const Key NATIVE_CLASS_TAG_INFO = const Key('nativeClassTagInfo');
47 const Key NATIVE_METHOD_BEHAVIOR = const Key('nativeMethodBehavior'); 48 const Key NATIVE_METHOD_BEHAVIOR = const Key('nativeMethodBehavior');
48 const Key NATIVE_FIELD_LOAD_BEHAVIOR = const Key('nativeFieldLoadBehavior'); 49 const Key NATIVE_FIELD_LOAD_BEHAVIOR = const Key('nativeFieldLoadBehavior');
49 const Key NATIVE_FIELD_STORE_BEHAVIOR = const Key('nativeFieldStoreBehavior'); 50 const Key NATIVE_FIELD_STORE_BEHAVIOR = const Key('nativeFieldStoreBehavior');
50 51
51 class JavaScriptBackendSerializer implements SerializerPlugin { 52 class JavaScriptBackendSerializer implements SerializerPlugin {
52 final JavaScriptBackend _backend; 53 final JavaScriptBackend _backend;
53 54
54 JavaScriptBackendSerializer(this._backend); 55 JavaScriptBackendSerializer(this._backend);
55 56
56 NativeBasicDataImpl get nativeBasicData => _backend.nativeBasicData; 57 NativeBasicDataImpl get nativeBasicData =>
58 _backend.compiler.frontendStrategy.nativeBasicData;
57 NativeDataBuilderImpl get nativeData => _backend.nativeDataBuilder; 59 NativeDataBuilderImpl get nativeData => _backend.nativeDataBuilder;
58 60
59 @override 61 @override
60 void onElement(Element element, ObjectEncoder createEncoder(String tag)) { 62 void onElement(Element element, ObjectEncoder createEncoder(String tag)) {
61 ObjectEncoder encoder; 63 ObjectEncoder encoder;
62 ObjectEncoder getEncoder() { 64 ObjectEncoder getEncoder() {
63 return encoder ??= createEncoder(_BACKEND_DATA_TAG); 65 return encoder ??= createEncoder(_BACKEND_DATA_TAG);
64 } 66 }
65 67
66 String jsInteropLibraryName = nativeData.jsInteropLibraryNames[element]; 68 String jsInteropLibraryName = nativeData.jsInteropLibraryNames[element];
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 void onData(covariant NativeBehavior behavior, ObjectEncoder encoder) { 112 void onData(covariant NativeBehavior behavior, ObjectEncoder encoder) {
111 NativeBehaviorSerialization.serializeNativeBehavior(behavior, encoder); 113 NativeBehaviorSerialization.serializeNativeBehavior(behavior, encoder);
112 } 114 }
113 } 115 }
114 116
115 class JavaScriptBackendDeserializer implements DeserializerPlugin { 117 class JavaScriptBackendDeserializer implements DeserializerPlugin {
116 final JavaScriptBackend _backend; 118 final JavaScriptBackend _backend;
117 119
118 JavaScriptBackendDeserializer(this._backend); 120 JavaScriptBackendDeserializer(this._backend);
119 121
120 NativeBasicDataBuilderImpl get nativeBasicData => 122 NativeBasicDataBuilderImpl get nativeBasicData {
121 _backend.nativeBasicDataBuilder; 123 ResolutionFrontEndStrategy frontendStrategy =
124 _backend.compiler.frontendStrategy;
125 return frontendStrategy.nativeBasicDataBuilder;
126 }
127
122 NativeDataBuilderImpl get nativeData => _backend.nativeDataBuilder; 128 NativeDataBuilderImpl get nativeData => _backend.nativeDataBuilder;
123 129
124 @override 130 @override
125 void onElement(Element element, ObjectDecoder getDecoder(String tag)) { 131 void onElement(Element element, ObjectDecoder getDecoder(String tag)) {
126 ObjectDecoder decoder = getDecoder(_BACKEND_DATA_TAG); 132 ObjectDecoder decoder = getDecoder(_BACKEND_DATA_TAG);
127 if (decoder != null) { 133 if (decoder != null) {
128 if (element is LibraryElement) { 134 if (element is LibraryElement) {
129 String jsInteropLibraryName = 135 String jsInteropLibraryName =
130 decoder.getString(JS_INTEROP_LIBRARY_NAME, isOptional: true); 136 decoder.getString(JS_INTEROP_LIBRARY_NAME, isOptional: true);
131 if (jsInteropLibraryName != null) { 137 if (jsInteropLibraryName != null) {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 behavior.codeTemplate = js.js.parseForeignJS(behavior.codeTemplateText); 294 behavior.codeTemplate = js.js.parseForeignJS(behavior.codeTemplateText);
289 } 295 }
290 296
291 behavior.throwBehavior = 297 behavior.throwBehavior =
292 decoder.getEnum(THROW_BEHAVIOR, NativeThrowBehavior.values); 298 decoder.getEnum(THROW_BEHAVIOR, NativeThrowBehavior.values);
293 behavior.isAllocation = decoder.getBool(IS_ALLOCATION); 299 behavior.isAllocation = decoder.getBool(IS_ALLOCATION);
294 behavior.useGvn = decoder.getBool(USE_GVN); 300 behavior.useGvn = decoder.getBool(USE_GVN);
295 return behavior; 301 return behavior;
296 } 302 }
297 } 303 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698