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

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

Issue 2065413002: Serialize and process patch metadata (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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
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 8a2ad83eab4a14c05c820c4d7ba58447fbf2e8d2..b025533db447716f406701521ddd18bc164f0d24 100644
--- a/pkg/compiler/lib/src/serialization/element_serialization.dart
+++ b/pkg/compiler/lib/src/serialization/element_serialization.dart
@@ -122,18 +122,26 @@ class SerializerUtil {
/// Serialize the metadata of [element] into [encoder].
static void serializeMetadata(Element element, ObjectEncoder encoder) {
+ ListEncoder list;
+
+ void encodeAnnotation(MetadataAnnotation metadata) {
+ ObjectEncoder object = list.createObject();
+ object.setElement(Key.ELEMENT, metadata.annotatedElement);
+ SourceSpan sourcePosition = metadata.sourcePosition;
+ // TODO(johnniwinther): What is the base URI here?
+ object.setUri(Key.URI, sourcePosition.uri, sourcePosition.uri);
+ object.setInt(Key.OFFSET, sourcePosition.begin);
+ object.setInt(Key.LENGTH, sourcePosition.end - sourcePosition.begin);
+ object.setConstant(Key.CONSTANT, metadata.constant);
+ }
+
if (element.metadata.isNotEmpty) {
- ListEncoder list = encoder.createList(Key.METADATA);
- for (MetadataAnnotation metadata in element.metadata) {
- ObjectEncoder object = list.createObject();
- object.setElement(Key.ELEMENT, metadata.annotatedElement);
- SourceSpan sourcePosition = metadata.sourcePosition;
- // TODO(johnniwinther): What is the base URI here?
- object.setUri(Key.URI, sourcePosition.uri, sourcePosition.uri);
- object.setInt(Key.OFFSET, sourcePosition.begin);
- object.setInt(Key.LENGTH, sourcePosition.end - sourcePosition.begin);
- object.setConstant(Key.CONSTANT, metadata.constant);
- }
+ list = encoder.createList(Key.METADATA);
+ element.metadata.forEach(encodeAnnotation);
+ }
+ if (element.isPatched && element.implementation.metadata.isNotEmpty) {
+ list ??= encoder.createList(Key.METADATA);
+ element.implementation.metadata.forEach(encodeAnnotation);
}
}
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | tests/compiler/dart2js/serialization/equivalence_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698