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

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

Issue 2898403002: Use failedAt in more places (Closed)
Patch Set: merge; address comments Created 3 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 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 '../elements/resolution_types.dart'; 9 import '../elements/resolution_types.dart';
10 import '../diagnostics/messages.dart'; 10 import '../diagnostics/messages.dart';
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 } 481 }
482 482
483 /// Serialize a reference from [context] to an [element] which might be a member 483 /// Serialize a reference from [context] to an [element] which might be a member
484 /// of an unnamed mixin application. If it is, [element] is by serialized 484 /// of an unnamed mixin application. If it is, [element] is by serialized
485 /// indirectly by name in the [nameKey] of [encoder], otherwise [element] is 485 /// indirectly by name in the [nameKey] of [encoder], otherwise [element] is
486 /// serialized directly in [elementKey] in [encoder]. 486 /// serialized directly in [elementKey] in [encoder].
487 void serializeElementReference(Element context, Key elementKey, Key nameKey, 487 void serializeElementReference(Element context, Key elementKey, Key nameKey,
488 ObjectEncoder encoder, Element element) { 488 ObjectEncoder encoder, Element element) {
489 if (element.isGenerativeConstructor && 489 if (element.isGenerativeConstructor &&
490 element.enclosingClass.isUnnamedMixinApplication) { 490 element.enclosingClass.isUnnamedMixinApplication) {
491 assert(invariant(element, element.isConstructor, 491 assert(
492 message: "Unexpected reference of forwarding constructor " 492 element.isConstructor,
493 failedAt(
494 element,
495 "Unexpected reference of forwarding constructor "
493 "${element} from $context.")); 496 "${element} from $context."));
494 encoder.setString(nameKey, element.name); 497 encoder.setString(nameKey, element.name);
495 } else { 498 } else {
496 encoder.setElement(elementKey, element); 499 encoder.setElement(elementKey, element);
497 } 500 }
498 } 501 }
499 502
500 /// Deserialize a reference from [context] to an [Element] which might be a 503 /// Deserialize a reference from [context] to an [Element] which might be a
501 /// member of an unnamed mixin application. If it is, the [Element] is by 504 /// member of an unnamed mixin application. If it is, the [Element] is by
502 /// deserialized indirectly by name from [nameKey] in [decoder], otherwise 505 /// deserialized indirectly by name from [nameKey] in [decoder], otherwise
503 /// the [Element] is deserialized directly from [elementKey] in [encoder]. 506 /// the [Element] is deserialized directly from [elementKey] in [encoder].
504 Element deserializeElementReference( 507 Element deserializeElementReference(
505 Element context, Key elementKey, Key nameKey, ObjectDecoder decoder, 508 Element context, Key elementKey, Key nameKey, ObjectDecoder decoder,
506 {bool isOptional: false}) { 509 {bool isOptional: false}) {
507 Element element = decoder.getElement(elementKey, isOptional: true); 510 Element element = decoder.getElement(elementKey, isOptional: true);
508 if (element == null) { 511 if (element == null) {
509 String elementName = decoder.getString(nameKey, isOptional: isOptional); 512 String elementName = decoder.getString(nameKey, isOptional: isOptional);
510 if (elementName == null) { 513 if (elementName == null) {
511 return null; 514 return null;
512 } 515 }
513 ClassElement cls; 516 ClassElement cls;
514 if (context is ClassElement) { 517 if (context is ClassElement) {
515 assert(invariant(NO_LOCATION_SPANNABLE, context.isNamedMixinApplication, 518 assert(
516 message: "Unexpected reference of forwarding constructor " 519 context.isNamedMixinApplication,
520 failedAt(
521 NO_LOCATION_SPANNABLE,
522 "Unexpected reference of forwarding constructor "
517 "'${elementName}' from $context.")); 523 "'${elementName}' from $context."));
518 cls = context; 524 cls = context;
519 } else { 525 } else {
520 assert(invariant(NO_LOCATION_SPANNABLE, context.isConstructor, 526 assert(
521 message: "Unexpected reference of forwarding constructor " 527 context.isConstructor,
528 failedAt(
529 NO_LOCATION_SPANNABLE,
530 "Unexpected reference of forwarding constructor "
522 "'${elementName}' from $context.")); 531 "'${elementName}' from $context."));
523 cls = context.enclosingClass; 532 cls = context.enclosingClass;
524 } 533 }
525 ClassElement superclass = cls.superclass; 534 ClassElement superclass = cls.superclass;
526 element = superclass.lookupConstructor(elementName); 535 element = superclass.lookupConstructor(elementName);
527 assert(invariant(NO_LOCATION_SPANNABLE, element != null, 536 assert(
528 message: "Unresolved reference of forwarding constructor " 537 element != null,
538 failedAt(
539 NO_LOCATION_SPANNABLE,
540 "Unresolved reference of forwarding constructor "
529 "'${elementName}' from $context.")); 541 "'${elementName}' from $context."));
530 } 542 }
531 return element; 543 return element;
532 } 544 }
533 545
534 void serializeMessageArguments( 546 void serializeMessageArguments(
535 ObjectEncoder encoder, Key key, Map<String, dynamic> messageArguments) { 547 ObjectEncoder encoder, Key key, Map<String, dynamic> messageArguments) {
536 if (messageArguments.isNotEmpty) { 548 if (messageArguments.isNotEmpty) {
537 MapEncoder mapEncoder = encoder.createMap(Key.ARGUMENTS); 549 MapEncoder mapEncoder = encoder.createMap(Key.ARGUMENTS);
538 messageArguments.forEach((String key, var value) { 550 messageArguments.forEach((String key, var value) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 ObjectDecoder sourceSpanDecoder = 595 ObjectDecoder sourceSpanDecoder =
584 object.getObject(Key.SOURCE_SPAN, isOptional: true); 596 object.getObject(Key.SOURCE_SPAN, isOptional: true);
585 if (sourceSpanDecoder != null) { 597 if (sourceSpanDecoder != null) {
586 sourceSpan = deserializeSourceSpan(sourceSpanDecoder); 598 sourceSpan = deserializeSourceSpan(sourceSpanDecoder);
587 } 599 }
588 MessageKind messageKind = object.getEnum(Key.KIND, MessageKind.values); 600 MessageKind messageKind = object.getEnum(Key.KIND, MessageKind.values);
589 Map<String, dynamic> messageArguments = 601 Map<String, dynamic> messageArguments =
590 deserializeMessageArguments(object, Key.ARGUMENTS); 602 deserializeMessageArguments(object, Key.ARGUMENTS);
591 return new WrappedMessage(sourceSpan, messageKind, messageArguments); 603 return new WrappedMessage(sourceSpan, messageKind, messageArguments);
592 } 604 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/serialization/serialization.dart ('k') | pkg/compiler/lib/src/serialization/system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698