| 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.elements; | 5 library dart2js.serialization.elements; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../constants/constructors.dart'; | 8 import '../constants/constructors.dart'; |
| 9 import '../constants/expressions.dart'; | 9 import '../constants/expressions.dart'; |
| 10 import '../elements/resolution_types.dart'; | 10 import '../elements/resolution_types.dart'; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 ]; | 95 ]; |
| 96 | 96 |
| 97 /// Interface for a function that can serialize a set of element kinds. | 97 /// Interface for a function that can serialize a set of element kinds. |
| 98 abstract class ElementSerializer { | 98 abstract class ElementSerializer { |
| 99 /// Returns the [SerializedElementKind] for [element] if this serializer | 99 /// Returns the [SerializedElementKind] for [element] if this serializer |
| 100 /// supports serialization of [element] or `null` otherwise. | 100 /// supports serialization of [element] or `null` otherwise. |
| 101 SerializedElementKind getSerializedKind(Element element); | 101 SerializedElementKind getSerializedKind(Element element); |
| 102 | 102 |
| 103 /// Serializes [element] into the [encoder] using the [kind] computed | 103 /// Serializes [element] into the [encoder] using the [kind] computed |
| 104 /// by [getSerializedKind]. | 104 /// by [getSerializedKind]. |
| 105 void serialize( | 105 void serialize(covariant Element element, ObjectEncoder encoder, |
| 106 Element element, ObjectEncoder encoder, SerializedElementKind kind); | 106 SerializedElementKind kind); |
| 107 } | 107 } |
| 108 | 108 |
| 109 class SerializerUtil { | 109 class SerializerUtil { |
| 110 /// Serialize the declared members of [element] into [encoder]. | 110 /// Serialize the declared members of [element] into [encoder]. |
| 111 static void serializeMembers( | 111 static void serializeMembers( |
| 112 Iterable<Element> members, ObjectEncoder encoder) { | 112 Iterable<Element> members, ObjectEncoder encoder) { |
| 113 MapEncoder mapEncoder = encoder.createMap(Key.MEMBERS); | 113 MapEncoder mapEncoder = encoder.createMap(Key.MEMBERS); |
| 114 for (Element member in members) { | 114 for (Element member in members) { |
| 115 String name = member.name; | 115 String name = member.name; |
| 116 if (member.isSetter) { | 116 if (member.isSetter) { |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 enclosingElement, existingElement, newElement); | 949 enclosingElement, existingElement, newElement); |
| 950 case SerializedElementKind.EXTERNAL_LIBRARY: | 950 case SerializedElementKind.EXTERNAL_LIBRARY: |
| 951 case SerializedElementKind.EXTERNAL_LIBRARY_MEMBER: | 951 case SerializedElementKind.EXTERNAL_LIBRARY_MEMBER: |
| 952 case SerializedElementKind.EXTERNAL_CLASS_MEMBER: | 952 case SerializedElementKind.EXTERNAL_CLASS_MEMBER: |
| 953 case SerializedElementKind.EXTERNAL_CONSTRUCTOR: | 953 case SerializedElementKind.EXTERNAL_CONSTRUCTOR: |
| 954 break; | 954 break; |
| 955 } | 955 } |
| 956 throw new UnsupportedError("Unexpected element kind '${elementKind}."); | 956 throw new UnsupportedError("Unexpected element kind '${elementKind}."); |
| 957 } | 957 } |
| 958 } | 958 } |
| OLD | NEW |