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

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

Issue 1809533004: Support serialization of WorldImpact (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 4 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library js_backend.serialization;
6
7 import '../common/backend_api.dart' show
8 BackendSerialization;
9 import '../elements/elements.dart';
10 import '../serialization/serialization.dart' show
11 DeserializerPlugin,
12 ObjectDecoder,
13 ObjectEncoder,
14 SerializerPlugin;
15 import '../serialization/keys.dart';
16 import 'js_backend.dart';
17
18 const String _BACKEND_DATA_TAG = 'jsBackendData';
19
20 class JavaScriptBackendSerialization implements BackendSerialization {
21 final JavaScriptBackendSerializer serializer;
22 final JavaScriptBackendDeserializer deserializer;
23
24 JavaScriptBackendSerialization(JavaScriptBackend backend)
25 : serializer = new JavaScriptBackendSerializer(backend),
26 deserializer = new JavaScriptBackendDeserializer(backend);
27 }
28
29 class JavaScriptBackendSerializer implements SerializerPlugin {
30 final JavaScriptBackend backend;
31
32 JavaScriptBackendSerializer(this.backend);
33
34 @override
35 void onElement(Element element, ObjectEncoder createEncoder(String tag)) {
36 // TODO(johnniwinther): Add more data, e.g. js-interop names, native tags,
37 // etc.
38 String nativeName = backend.nativeData.nativeMemberName[element];
39 if (nativeName != null) {
40 ObjectEncoder encoder = createEncoder(_BACKEND_DATA_TAG);
41 encoder.setString(Key.NAME, nativeName);
42 }
43 }
44 }
45
46 class JavaScriptBackendDeserializer implements DeserializerPlugin {
47 final JavaScriptBackend backend;
48
49 JavaScriptBackendDeserializer(this.backend);
50
51 @override
52 void onElement(Element element, ObjectDecoder getDecoder(String tag)) {
53 ObjectDecoder decoder = getDecoder(_BACKEND_DATA_TAG);
54 if (decoder != null) {
55 String nativeName = decoder.getString(Key.NAME);
56 backend.nativeData.nativeMemberName[element] = nativeName;
57 }
58 }
59 }
60
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | 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