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

Side by Side Diff: pkg/compiler/lib/src/serialization/serialization_util.dart

Issue 2125793003: Serialize WarnOnUseElement (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.util; 5 library dart2js.serialization.util;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../constants/expressions.dart'; 8 import '../constants/expressions.dart';
9 import '../dart_types.dart'; 9 import '../dart_types.dart';
10 import '../diagnostics/messages.dart';
10 import '../elements/elements.dart'; 11 import '../elements/elements.dart';
12 import '../elements/modelx.dart' show WrappedMessage;
11 import '../resolution/access_semantics.dart'; 13 import '../resolution/access_semantics.dart';
12 import '../resolution/operators.dart'; 14 import '../resolution/operators.dart';
13 import '../resolution/send_structure.dart'; 15 import '../resolution/send_structure.dart';
14 import '../universe/call_structure.dart'; 16 import '../universe/call_structure.dart';
15 import '../universe/selector.dart'; 17 import '../universe/selector.dart';
16 import 'keys.dart'; 18 import 'keys.dart';
17 import 'serialization.dart'; 19 import 'serialization.dart';
18 20
19 /// Serialize [name] into [encoder]. 21 /// Serialize [name] into [encoder].
20 void serializeName(Name name, ObjectEncoder encoder) { 22 void serializeName(Name name, ObjectEncoder encoder) {
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 cls = context.enclosingClass; 521 cls = context.enclosingClass;
520 } 522 }
521 ClassElement superclass = cls.superclass; 523 ClassElement superclass = cls.superclass;
522 element = superclass.lookupConstructor(elementName); 524 element = superclass.lookupConstructor(elementName);
523 assert(invariant(NO_LOCATION_SPANNABLE, element != null, 525 assert(invariant(NO_LOCATION_SPANNABLE, element != null,
524 message: "Unresolved reference of forwarding constructor " 526 message: "Unresolved reference of forwarding constructor "
525 "'${elementName}' from $context.")); 527 "'${elementName}' from $context."));
526 } 528 }
527 return element; 529 return element;
528 } 530 }
531
532 void serializeMessageArguments(
533 ObjectEncoder encoder, Key key, Map<String, dynamic> messageArguments) {
534 if (messageArguments.isNotEmpty) {
535 MapEncoder mapEncoder = encoder.createMap(Key.ARGUMENTS);
536 messageArguments.forEach((String key, var value) {
537 mapEncoder.setString(key, Message.convertToString(value));
538 });
539 }
540 }
541
542 Map<String, String> deserializeMessageArguments(
543 ObjectDecoder decoder, Key key) {
544 Map<String, String> arguments = <String, String>{};
545 MapDecoder mapDecoder = decoder.getMap(key, isOptional: true);
546 if (mapDecoder != null) {
547 mapDecoder.forEachKey((String key) {
548 arguments[key] = mapDecoder.getString(key);
549 });
550 }
551 return arguments;
552 }
553
554 void serializeSourceSpan(ObjectEncoder encoder, SourceSpan sourceSpan) {
555 encoder.setUri(Key.URI, sourceSpan.uri, sourceSpan.uri);
556 encoder.setInt(Key.OFFSET, sourceSpan.begin);
557 encoder.setInt(Key.LENGTH, sourceSpan.end - sourceSpan.begin);
558 }
559
560 SourceSpan deserializeSourceSpan(ObjectDecoder decoder) {
561 Uri uri = decoder.getUri(Key.URI);
562 int offset = decoder.getInt(Key.OFFSET);
563 int length = decoder.getInt(Key.LENGTH);
564 return new SourceSpan(uri, offset, offset + length);
565 }
566
567 void serializeWrappedMessage(
568 ObjectEncoder encoder, Key key, WrappedMessage message) {
569 ObjectEncoder object = encoder.createObject(key);
570 if (message.sourceSpan != null) {
571 serializeSourceSpan(
572 object.createObject(Key.SOURCE_SPAN), message.sourceSpan);
573 }
574 object.setEnum(Key.KIND, message.messageKind);
575 serializeMessageArguments(object, Key.ARGUMENTS, message.messageArguments);
576 }
577
578 WrappedMessage deserializeWrappedMessage(ObjectDecoder decoder, Key key) {
579 ObjectDecoder object = decoder.getObject(key);
580 SourceSpan sourceSpan;
581 ObjectDecoder sourceSpanDecoder =
582 object.getObject(Key.SOURCE_SPAN, isOptional: true);
583 if (sourceSpanDecoder != null) {
584 sourceSpan = deserializeSourceSpan(sourceSpanDecoder);
585 }
586 MessageKind messageKind = object.getEnum(Key.KIND, MessageKind.values);
587 Map<String, dynamic> messageArguments =
588 deserializeMessageArguments(object, Key.ARGUMENTS);
589 return new WrappedMessage(sourceSpan, messageKind, messageArguments);
590 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/serialization/keys.dart ('k') | tests/compiler/dart2js/serialization/equivalence_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698