Index: pkg/compiler/lib/src/serialization/element_serialization.dart |
diff --git a/pkg/compiler/lib/src/serialization/element_serialization.dart b/pkg/compiler/lib/src/serialization/element_serialization.dart |
index b025533db447716f406701521ddd18bc164f0d24..3182596edc2b453e5ae3cdc9a66a0a5809beb096 100644 |
--- a/pkg/compiler/lib/src/serialization/element_serialization.dart |
+++ b/pkg/compiler/lib/src/serialization/element_serialization.dart |
@@ -9,6 +9,7 @@ import '../constants/constructors.dart'; |
import '../constants/expressions.dart'; |
import '../dart_types.dart'; |
import '../elements/elements.dart'; |
+import '../elements/modelx.dart' show ErroneousElementX; |
import 'constant_serialization.dart'; |
import 'keys.dart'; |
import 'modelz.dart'; |
@@ -17,6 +18,7 @@ import 'serialization_util.dart'; |
/// Enum kinds used for encoding [Element]s. |
enum SerializedElementKind { |
+ ERROR, |
LIBRARY, |
COMPILATION_UNIT, |
CLASS, |
@@ -63,6 +65,7 @@ enum SerializedElementKind { |
/// and [ConstantExpression] that the serialized [Element] depends upon are also |
/// serialized. |
const List<ElementSerializer> ELEMENT_SERIALIZERS = const [ |
+ const ErrorSerializer(), |
const LibrarySerializer(), |
const CompilationUnitSerializer(), |
const ClassSerializer(), |
@@ -193,6 +196,30 @@ class SerializerUtil { |
} |
} |
+class ErrorSerializer implements ElementSerializer { |
+ const ErrorSerializer(); |
+ |
+ SerializedElementKind getSerializedKind(Element element) { |
+ if (element.isError) { |
+ return SerializedElementKind.ERROR; |
+ } |
+ return null; |
+ } |
+ |
+ void serialize(ErroneousElement element, ObjectEncoder encoder, |
+ SerializedElementKind kind) { |
+ encoder.setElement(Key.ENCLOSING, element.enclosingElement); |
+ encoder.setString(Key.NAME, element.name); |
+ encoder.setEnum(Key.MESSAGE_KIND, element.messageKind); |
+ if (element.messageArguments.isNotEmpty) { |
+ MapEncoder mapEncoder = encoder.createMap(Key.ARGUMENTS); |
+ element.messageArguments.forEach((String key, String value) { |
+ mapEncoder.setString(key, value); |
+ }); |
+ } |
+ } |
+} |
+ |
class LibrarySerializer implements ElementSerializer { |
const LibrarySerializer(); |
@@ -705,6 +732,19 @@ class ElementDeserializer { |
static Element deserialize( |
ObjectDecoder decoder, SerializedElementKind elementKind) { |
switch (elementKind) { |
+ case SerializedElementKind.ERROR: |
+ Element enclosing = decoder.getElement(Key.ENCLOSING); |
+ String name = decoder.getString(Key.NAME); |
+ MessageKind messageKind = |
+ decoder.getEnum(Key.MESSAGE_KIND, MessageKind.values); |
+ Map<String, String> arguments = <String, String>{}; |
+ MapDecoder mapDecoder = decoder.getMap(Key.ARGUMENTS, isOptional: true); |
+ if (mapDecoder != null) { |
+ mapDecoder.forEachKey((String key) { |
+ arguments[key] = mapDecoder.getString(key); |
+ }); |
+ } |
+ return new ErroneousElementX(messageKind, arguments, name, enclosing); |
case SerializedElementKind.LIBRARY: |
return new LibraryElementZ(decoder); |
case SerializedElementKind.COMPILATION_UNIT: |