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

Side by Side Diff: pkg/compiler/lib/src/resolution/class_hierarchy.dart

Issue 1811173003: Support per-library serialization. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 8 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.resolution.class_hierarchy; 5 library dart2js.resolution.class_hierarchy;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/resolution.dart' show 8 import '../common/resolution.dart' show
9 Feature; 9 Feature;
10 import '../compiler.dart' show 10 import '../compiler.dart' show
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 final TypeDeclarationElement enclosingElement; 48 final TypeDeclarationElement enclosingElement;
49 TypeDeclarationElement get element => enclosingElement; 49 TypeDeclarationElement get element => enclosingElement;
50 50
51 TypeDefinitionVisitor(Compiler compiler, 51 TypeDefinitionVisitor(Compiler compiler,
52 TypeDeclarationElement element, 52 TypeDeclarationElement element,
53 ResolutionRegistry registry) 53 ResolutionRegistry registry)
54 : this.enclosingElement = element, 54 : this.enclosingElement = element,
55 scope = Scope.buildEnclosingScope(element), 55 scope = Scope.buildEnclosingScope(element),
56 super(compiler, registry); 56 super(compiler, registry);
57 57
58 DartType get objectType => compiler.coreTypes.objectType; 58 CoreTypes get coreTypes => compiler.coreTypes;
59
60 DartType get objectType => coreTypes.objectType;
61
59 62
60 void resolveTypeVariableBounds(NodeList node) { 63 void resolveTypeVariableBounds(NodeList node) {
61 if (node == null) return; 64 if (node == null) return;
62 65
63 Setlet<String> nameSet = new Setlet<String>(); 66 Setlet<String> nameSet = new Setlet<String>();
64 // Resolve the bounds of type variables. 67 // Resolve the bounds of type variables.
65 Iterator<DartType> types = element.typeVariables.iterator; 68 Iterator<DartType> types = element.typeVariables.iterator;
66 Link<Node> nodeLink = node.nodes; 69 Link<Node> nodeLink = node.nodes;
67 while (!nodeLink.isEmpty) { 70 while (!nodeLink.isEmpty) {
68 types.moveNext(); 71 types.moveNext();
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 DartType visitEnum(Enum node) { 241 DartType visitEnum(Enum node) {
239 if (element == null) { 242 if (element == null) {
240 throw reporter.internalError(node, 'element is null'); 243 throw reporter.internalError(node, 'element is null');
241 } 244 }
242 if (element.resolutionState != STATE_STARTED) { 245 if (element.resolutionState != STATE_STARTED) {
243 throw reporter.internalError(element, 246 throw reporter.internalError(element,
244 'cyclic resolution of class $element'); 247 'cyclic resolution of class $element');
245 } 248 }
246 249
247 InterfaceType enumType = element.computeType(resolution); 250 InterfaceType enumType = element.computeType(resolution);
248 element.supertype = compiler.coreTypes.objectType; 251 element.supertype = objectType;
249 element.interfaces = const Link<DartType>(); 252 element.interfaces = const Link<DartType>();
250 calculateAllSupertypes(element); 253 calculateAllSupertypes(element);
251 254
252 if (node.names.nodes.isEmpty) { 255 if (node.names.nodes.isEmpty) {
253 reporter.reportErrorMessage( 256 reporter.reportErrorMessage(
254 node, 257 node,
255 MessageKind.EMPTY_ENUM_DECLARATION, 258 MessageKind.EMPTY_ENUM_DECLARATION,
256 {'enumName': element.name}); 259 {'enumName': element.name});
257 } 260 }
258 261
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 * where ++ stands for list concatenation. 575 * where ++ stands for list concatenation.
573 * 576 *
574 * This order makes sure that if a class implements an interface twice with 577 * This order makes sure that if a class implements an interface twice with
575 * different type arguments, the type used in the most specific class comes 578 * different type arguments, the type used in the most specific class comes
576 * first. 579 * first.
577 */ 580 */
578 void calculateAllSupertypes(BaseClassElementX cls) { 581 void calculateAllSupertypes(BaseClassElementX cls) {
579 if (cls.allSupertypesAndSelf != null) return; 582 if (cls.allSupertypesAndSelf != null) return;
580 final DartType supertype = cls.supertype; 583 final DartType supertype = cls.supertype;
581 if (supertype != null) { 584 if (supertype != null) {
582 OrderedTypeSetBuilder allSupertypes = new OrderedTypeSetBuilder(cls); 585 cls.allSupertypesAndSelf =
583 // TODO(15296): Collapse these iterations to one when the order is not 586 new OrderedTypeSetBuilder(
584 // needed. 587 cls, reporter: reporter, objectType: coreTypes.objectType)
585 allSupertypes.add(compiler, supertype); 588 .createOrderedTypeSet(supertype, cls.interfaces);
586 for (Link<DartType> interfaces = cls.interfaces;
587 !interfaces.isEmpty;
588 interfaces = interfaces.tail) {
589 allSupertypes.add(compiler, interfaces.head);
590 }
591
592 addAllSupertypes(allSupertypes, supertype);
593 for (Link<DartType> interfaces = cls.interfaces;
594 !interfaces.isEmpty;
595 interfaces = interfaces.tail) {
596 addAllSupertypes(allSupertypes, interfaces.head);
597 }
598 allSupertypes.add(compiler, cls.computeType(resolution));
599 cls.allSupertypesAndSelf = allSupertypes.toTypeSet();
600 } else { 589 } else {
601 assert(cls == compiler.coreClasses.objectClass); 590 assert(cls == compiler.coreClasses.objectClass);
602 cls.allSupertypesAndSelf = 591 cls.allSupertypesAndSelf =
603 new OrderedTypeSet.singleton(cls.computeType(resolution)); 592 new OrderedTypeSet.singleton(cls.computeType(resolution));
604 } 593 }
605 } 594 }
606 595
607 /**
608 * Adds [type] and all supertypes of [type] to [allSupertypes] while
609 * substituting type variables.
610 */
611 void addAllSupertypes(OrderedTypeSetBuilder allSupertypes,
612 InterfaceType type) {
613 ClassElement classElement = type.element;
614 Link<DartType> supertypes = classElement.allSupertypes;
615 assert(invariant(element, supertypes != null,
616 message: "Supertypes not computed on $classElement "
617 "during resolution of $element"));
618 while (!supertypes.isEmpty) {
619 DartType supertype = supertypes.head;
620 allSupertypes.add(compiler, supertype.substByContext(type));
621 supertypes = supertypes.tail;
622 }
623 }
624
625 isBlackListed(DartType type) { 596 isBlackListed(DartType type) {
626 LibraryElement lib = element.library; 597 LibraryElement lib = element.library;
627 CoreTypes coreTypes = compiler.coreTypes;
628 return 598 return
629 !identical(lib, compiler.coreLibrary) && 599 !identical(lib, compiler.coreLibrary) &&
630 !compiler.backend.isBackendLibrary(lib) && 600 !compiler.backend.isBackendLibrary(lib) &&
631 (type.isDynamic || 601 (type.isDynamic ||
632 type == coreTypes.boolType || 602 type == coreTypes.boolType ||
633 type == coreTypes.numType || 603 type == coreTypes.numType ||
634 type == coreTypes.intType || 604 type == coreTypes.intType ||
635 type == coreTypes.doubleType || 605 type == coreTypes.doubleType ||
636 type == coreTypes.stringType || 606 type == coreTypes.stringType ||
637 type == coreTypes.nullType); 607 type == coreTypes.nullType);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 if (e == null || !e.impliesType) { 690 if (e == null || !e.impliesType) {
721 reporter.reportErrorMessage( 691 reporter.reportErrorMessage(
722 node.selector, 692 node.selector,
723 MessageKind.CANNOT_RESOLVE_TYPE, 693 MessageKind.CANNOT_RESOLVE_TYPE,
724 {'typeName': node.selector}); 694 {'typeName': node.selector});
725 return; 695 return;
726 } 696 }
727 loadSupertype(e, node); 697 loadSupertype(e, node);
728 } 698 }
729 } 699 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ordered_typeset.dart ('k') | pkg/compiler/lib/src/serialization/element_serialization.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698