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

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

Issue 2863073003: Access NativeData only through ClosedWorld (Closed)
Patch Set: Created 3 years, 7 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';
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 const Key NATIVE_METHOD_BEHAVIOR = const Key('nativeMethodBehavior'); 47 const Key NATIVE_METHOD_BEHAVIOR = const Key('nativeMethodBehavior');
48 const Key NATIVE_FIELD_LOAD_BEHAVIOR = const Key('nativeFieldLoadBehavior'); 48 const Key NATIVE_FIELD_LOAD_BEHAVIOR = const Key('nativeFieldLoadBehavior');
49 const Key NATIVE_FIELD_STORE_BEHAVIOR = const Key('nativeFieldStoreBehavior'); 49 const Key NATIVE_FIELD_STORE_BEHAVIOR = const Key('nativeFieldStoreBehavior');
50 50
51 class JavaScriptBackendSerializer implements SerializerPlugin { 51 class JavaScriptBackendSerializer implements SerializerPlugin {
52 final JavaScriptBackend _backend; 52 final JavaScriptBackend _backend;
53 53
54 JavaScriptBackendSerializer(this._backend); 54 JavaScriptBackendSerializer(this._backend);
55 55
56 NativeBasicDataImpl get nativeBasicData => _backend.nativeBasicData; 56 NativeBasicDataImpl get nativeBasicData => _backend.nativeBasicData;
57 NativeDataImpl get nativeData => _backend.nativeData; 57 NativeDataBuilderImpl get nativeData => _backend.nativeDataBuilder;
58 58
59 @override 59 @override
60 void onElement(Element element, ObjectEncoder createEncoder(String tag)) { 60 void onElement(Element element, ObjectEncoder createEncoder(String tag)) {
61 ObjectEncoder encoder; 61 ObjectEncoder encoder;
62 ObjectEncoder getEncoder() { 62 ObjectEncoder getEncoder() {
63 return encoder ??= createEncoder(_BACKEND_DATA_TAG); 63 return encoder ??= createEncoder(_BACKEND_DATA_TAG);
64 } 64 }
65 65
66 String jsInteropLibraryName = nativeData.jsInteropLibraryNames[element]; 66 String jsInteropLibraryName = nativeData.jsInteropLibraryNames[element];
67 if (jsInteropLibraryName != null) { 67 if (jsInteropLibraryName != null) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 } 113 }
114 114
115 class JavaScriptBackendDeserializer implements DeserializerPlugin { 115 class JavaScriptBackendDeserializer implements DeserializerPlugin {
116 final JavaScriptBackend _backend; 116 final JavaScriptBackend _backend;
117 117
118 JavaScriptBackendDeserializer(this._backend); 118 JavaScriptBackendDeserializer(this._backend);
119 119
120 NativeBasicDataBuilderImpl get nativeBasicData => 120 NativeBasicDataBuilderImpl get nativeBasicData =>
121 _backend.nativeBasicDataBuilder; 121 _backend.nativeBasicDataBuilder;
122 NativeDataImpl get nativeData => _backend.nativeData; 122 NativeDataBuilderImpl get nativeData => _backend.nativeDataBuilder;
123 123
124 @override 124 @override
125 void onElement(Element element, ObjectDecoder getDecoder(String tag)) { 125 void onElement(Element element, ObjectDecoder getDecoder(String tag)) {
126 ObjectDecoder decoder = getDecoder(_BACKEND_DATA_TAG); 126 ObjectDecoder decoder = getDecoder(_BACKEND_DATA_TAG);
127 if (decoder != null) { 127 if (decoder != null) {
128 if (element is LibraryElement) { 128 if (element is LibraryElement) {
129 String jsInteropLibraryName = 129 String jsInteropLibraryName =
130 decoder.getString(JS_INTEROP_LIBRARY_NAME, isOptional: true); 130 decoder.getString(JS_INTEROP_LIBRARY_NAME, isOptional: true);
131 if (jsInteropLibraryName != null) { 131 if (jsInteropLibraryName != null) {
132 nativeData.jsInteropLibraryNames[element] = jsInteropLibraryName; 132 nativeData.jsInteropLibraryNames[element] = jsInteropLibraryName;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 behavior.codeTemplate = js.js.parseForeignJS(behavior.codeTemplateText); 288 behavior.codeTemplate = js.js.parseForeignJS(behavior.codeTemplateText);
289 } 289 }
290 290
291 behavior.throwBehavior = 291 behavior.throwBehavior =
292 decoder.getEnum(THROW_BEHAVIOR, NativeThrowBehavior.values); 292 decoder.getEnum(THROW_BEHAVIOR, NativeThrowBehavior.values);
293 behavior.isAllocation = decoder.getBool(IS_ALLOCATION); 293 behavior.isAllocation = decoder.getBool(IS_ALLOCATION);
294 behavior.useGvn = decoder.getBool(USE_GVN); 294 behavior.useGvn = decoder.getBool(USE_GVN);
295 return behavior; 295 return behavior;
296 } 296 }
297 } 297 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/js_backend/frequency_namer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698