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

Unified Diff: pkg/compiler/lib/src/serialization/element_serialization.dart

Issue 2088233003: Serialize erroneous element and more (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/library_loader.dart ('k') | pkg/compiler/lib/src/serialization/keys.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:
« no previous file with comments | « pkg/compiler/lib/src/library_loader.dart ('k') | pkg/compiler/lib/src/serialization/keys.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698