| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart2js.serialization; | 5 library dart2js.serialization; |
| 6 | 6 |
| 7 import '../elements/elements.dart'; | 7 import '../elements/elements.dart'; |
| 8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
| 9 import '../dart_types.dart'; | 9 import '../dart_types.dart'; |
| 10 import '../util/enumset.dart'; | 10 import '../util/enumset.dart'; |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 | 850 |
| 851 /// Plugin for serializing additional data for an [Element]. | 851 /// Plugin for serializing additional data for an [Element]. |
| 852 class SerializerPlugin { | 852 class SerializerPlugin { |
| 853 const SerializerPlugin(); | 853 const SerializerPlugin(); |
| 854 | 854 |
| 855 /// Called upon the serialization of [element]. | 855 /// Called upon the serialization of [element]. |
| 856 /// | 856 /// |
| 857 /// Use [creatorEncoder] to create a data object with id [tag] for storing | 857 /// Use [creatorEncoder] to create a data object with id [tag] for storing |
| 858 /// additional data for [element]. | 858 /// additional data for [element]. |
| 859 void onElement(Element element, ObjectEncoder createEncoder(String tag)) {} | 859 void onElement(Element element, ObjectEncoder createEncoder(String tag)) {} |
| 860 |
| 861 /// Called to serialize custom [data]. |
| 862 void onData(var data, ObjectEncoder encoder) {} |
| 860 } | 863 } |
| 861 | 864 |
| 862 /// Plugin for deserializing additional data for an [Element]. | 865 /// Plugin for deserializing additional data for an [Element]. |
| 863 class DeserializerPlugin { | 866 class DeserializerPlugin { |
| 864 const DeserializerPlugin(); | 867 const DeserializerPlugin(); |
| 865 | 868 |
| 866 /// Called upon the deserialization of [element]. | 869 /// Called upon the deserialization of [element]. |
| 867 /// | 870 /// |
| 868 /// Use [getDecoder] to retrieve the data object with id [tag] stored for | 871 /// Use [getDecoder] to retrieve the data object with id [tag] stored for |
| 869 /// [element]. If not object is stored for [tag], [getDecoder] returns `null`. | 872 /// [element]. If not object is stored for [tag], [getDecoder] returns `null`. |
| 870 void onElement(Element element, ObjectDecoder getDecoder(String tag)) {} | 873 void onElement(Element element, ObjectDecoder getDecoder(String tag)) {} |
| 874 |
| 875 /// Called to deserialize custom data from [decoder]. |
| 876 dynamic onData(ObjectDecoder decoder); |
| 871 } | 877 } |
| 872 | 878 |
| 873 /// Context for parallel deserialization. | 879 /// Context for parallel deserialization. |
| 874 class DeserializationContext { | 880 class DeserializationContext { |
| 875 Map<Uri, LibraryElement> _uriMap = <Uri, LibraryElement>{}; | 881 Map<Uri, LibraryElement> _uriMap = <Uri, LibraryElement>{}; |
| 876 List<Deserializer> deserializers = <Deserializer>[]; | 882 List<Deserializer> deserializers = <Deserializer>[]; |
| 877 | 883 |
| 878 LibraryElement lookupLibrary(Uri uri) { | 884 LibraryElement lookupLibrary(Uri uri) { |
| 879 return _uriMap.putIfAbsent(uri, () { | 885 return _uriMap.putIfAbsent(uri, () { |
| 880 for (Deserializer deserializer in deserializers) { | 886 for (Deserializer deserializer in deserializers) { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 | 1040 |
| 1035 /// Returns the value used to store [key] as a property in the encoding an | 1041 /// Returns the value used to store [key] as a property in the encoding an |
| 1036 /// [ObjectValue]. | 1042 /// [ObjectValue]. |
| 1037 /// | 1043 /// |
| 1038 /// Different encodings have different restrictions and capabilities as how | 1044 /// Different encodings have different restrictions and capabilities as how |
| 1039 /// to store a [Key] value. For instance: A JSON encoding needs to convert | 1045 /// to store a [Key] value. For instance: A JSON encoding needs to convert |
| 1040 /// [Key] to a [String] to store it in a JSON object; a Dart encoding can | 1046 /// [Key] to a [String] to store it in a JSON object; a Dart encoding can |
| 1041 /// choose to store a [Key] as an [int] or as the [Key] itself. | 1047 /// choose to store a [Key] as an [int] or as the [Key] itself. |
| 1042 getObjectPropertyValue(Key key); | 1048 getObjectPropertyValue(Key key); |
| 1043 } | 1049 } |
| OLD | NEW |