| OLD | NEW |
| 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 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 | 41 |
| 42 const Key JS_INTEROP_NAME = const Key('jsInteropName'); | 42 const Key JS_INTEROP_NAME = const Key('jsInteropName'); |
| 43 const Key NATIVE_MEMBER_NAME = const Key('nativeMemberName'); | 43 const Key NATIVE_MEMBER_NAME = const Key('nativeMemberName'); |
| 44 const Key NATIVE_CLASS_TAG_INFO = const Key('nativeClassTagInfo'); | 44 const Key NATIVE_CLASS_TAG_INFO = const Key('nativeClassTagInfo'); |
| 45 const Key NATIVE_METHOD_BEHAVIOR = const Key('nativeMethodBehavior'); | 45 const Key NATIVE_METHOD_BEHAVIOR = const Key('nativeMethodBehavior'); |
| 46 const Key NATIVE_FIELD_LOAD_BEHAVIOR = const Key('nativeFieldLoadBehavior'); | 46 const Key NATIVE_FIELD_LOAD_BEHAVIOR = const Key('nativeFieldLoadBehavior'); |
| 47 const Key NATIVE_FIELD_STORE_BEHAVIOR = const Key('nativeFieldStoreBehavior'); | 47 const Key NATIVE_FIELD_STORE_BEHAVIOR = const Key('nativeFieldStoreBehavior'); |
| 48 | 48 |
| 49 class JavaScriptBackendSerializer implements SerializerPlugin { | 49 class JavaScriptBackendSerializer implements SerializerPlugin { |
| 50 final NativeData nativeData; | 50 final NativeDataImpl nativeData; |
| 51 | 51 |
| 52 JavaScriptBackendSerializer(this.nativeData); | 52 JavaScriptBackendSerializer(this.nativeData); |
| 53 | 53 |
| 54 @override | 54 @override |
| 55 void onElement(Element element, ObjectEncoder createEncoder(String tag)) { | 55 void onElement(Element element, ObjectEncoder createEncoder(String tag)) { |
| 56 ObjectEncoder encoder; | 56 ObjectEncoder encoder; |
| 57 ObjectEncoder getEncoder() { | 57 ObjectEncoder getEncoder() { |
| 58 return encoder ??= createEncoder(_BACKEND_DATA_TAG); | 58 return encoder ??= createEncoder(_BACKEND_DATA_TAG); |
| 59 } | 59 } |
| 60 | 60 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 @override | 95 @override |
| 96 void onData(NativeBehavior behavior, ObjectEncoder encoder) { | 96 void onData(NativeBehavior behavior, ObjectEncoder encoder) { |
| 97 NativeBehaviorSerialization.serializeNativeBehavior(behavior, encoder); | 97 NativeBehaviorSerialization.serializeNativeBehavior(behavior, encoder); |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 | 100 |
| 101 class JavaScriptBackendDeserializer implements DeserializerPlugin { | 101 class JavaScriptBackendDeserializer implements DeserializerPlugin { |
| 102 final NativeData nativeData; | 102 final NativeDataImpl nativeData; |
| 103 | 103 |
| 104 JavaScriptBackendDeserializer(this.nativeData); | 104 JavaScriptBackendDeserializer(this.nativeData); |
| 105 | 105 |
| 106 @override | 106 @override |
| 107 void onElement(Element element, ObjectDecoder getDecoder(String tag)) { | 107 void onElement(Element element, ObjectDecoder getDecoder(String tag)) { |
| 108 ObjectDecoder decoder = getDecoder(_BACKEND_DATA_TAG); | 108 ObjectDecoder decoder = getDecoder(_BACKEND_DATA_TAG); |
| 109 if (decoder != null) { | 109 if (decoder != null) { |
| 110 String jsInteropName = | 110 String jsInteropName = |
| 111 decoder.getString(JS_INTEROP_NAME, isOptional: true); | 111 decoder.getString(JS_INTEROP_NAME, isOptional: true); |
| 112 if (jsInteropName != null) { | 112 if (jsInteropName != null) { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 behavior.codeTemplate = js.js.parseForeignJS(behavior.codeTemplateText); | 250 behavior.codeTemplate = js.js.parseForeignJS(behavior.codeTemplateText); |
| 251 } | 251 } |
| 252 | 252 |
| 253 behavior.throwBehavior = | 253 behavior.throwBehavior = |
| 254 decoder.getEnum(THROW_BEHAVIOR, NativeThrowBehavior.values); | 254 decoder.getEnum(THROW_BEHAVIOR, NativeThrowBehavior.values); |
| 255 behavior.isAllocation = decoder.getBool(IS_ALLOCATION); | 255 behavior.isAllocation = decoder.getBool(IS_ALLOCATION); |
| 256 behavior.useGvn = decoder.getBool(USE_GVN); | 256 behavior.useGvn = decoder.getBool(USE_GVN); |
| 257 return behavior; | 257 return behavior; |
| 258 } | 258 } |
| 259 } | 259 } |
| OLD | NEW |