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

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

Issue 2012163003: Fix several element properties in serialization. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: dartfmt Created 4 years, 7 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 /// Implementation of the element model used for deserialiation. 5 /// Implementation of the element model used for deserialiation.
6 /// 6 ///
7 /// These classes are created by [ElementDeserializer] triggered by the 7 /// These classes are created by [ElementDeserializer] triggered by the
8 /// [Deserializer]. 8 /// [Deserializer].
9 9
10 library dart2js.serialization.modelz; 10 library dart2js.serialization.modelz;
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 if (members == null) return; 294 if (members == null) return;
295 members.forEachKey((String key) { 295 members.forEachKey((String key) {
296 Element member = members.getElement(key); 296 Element member = members.getElement(key);
297 if (member != null) { 297 if (member != null) {
298 f(member); 298 f(member);
299 } 299 }
300 }); 300 });
301 } 301 }
302 } 302 }
303 303
304 class AbstractFieldElementZ extends ElementZ implements AbstractFieldElement { 304 class AbstractFieldElementZ extends ElementZ
305 with AbstractFieldElementCommon
306 implements AbstractFieldElement {
305 final String name; 307 final String name;
306 final GetterElementZ getter; 308 final GetterElementZ getter;
307 final SetterElementZ setter; 309 final SetterElementZ setter;
308 310
309 AbstractFieldElementZ(this.name, this.getter, this.setter) { 311 AbstractFieldElementZ(this.name, this.getter, this.setter) {
310 if (getter != null) { 312 if (getter != null) {
311 getter.abstractField = this; 313 getter.abstractField = this;
312 getter.setter = setter; 314 getter.setter = setter;
313 } 315 }
314 if (setter != null) { 316 if (setter != null) {
(...skipping 24 matching lines...) Expand all
339 Element get enclosingElement => _canonicalElement.enclosingElement; 341 Element get enclosingElement => _canonicalElement.enclosingElement;
340 342
341 @override 343 @override
342 int get sourceOffset => _canonicalElement.sourceOffset; 344 int get sourceOffset => _canonicalElement.sourceOffset;
343 345
344 @override 346 @override
345 SourceSpan get sourcePosition => _canonicalElement.sourcePosition; 347 SourceSpan get sourcePosition => _canonicalElement.sourcePosition;
346 348
347 @override 349 @override
348 ClassElement get enclosingClass => _canonicalElement.enclosingClass; 350 ClassElement get enclosingClass => _canonicalElement.enclosingClass;
351
352 @override
353 bool get isClassMember => _canonicalElement.isClassMember;
354
355 @override
356 bool get isInstanceMember => _canonicalElement.isInstanceMember;
357
358 @override
359 bool get isStatic => _canonicalElement.isStatic;
360
361 @override
362 bool get isTopLevel => _canonicalElement.isTopLevel;
349 } 363 }
350 364
351 class LibraryElementZ extends DeserializedElementZ 365 class LibraryElementZ extends DeserializedElementZ
352 with AnalyzableElementMixin, ContainerMixin, LibraryElementCommon 366 with AnalyzableElementMixin, ContainerMixin, LibraryElementCommon
353 implements LibraryElement { 367 implements LibraryElement {
354 Uri _canonicalUri; 368 Uri _canonicalUri;
355 CompilationUnitElement _entryCompilationUnit; 369 CompilationUnitElement _entryCompilationUnit;
356 Link<CompilationUnitElement> _compilationUnits; 370 Link<CompilationUnitElement> _compilationUnits;
357 List<ImportElement> _imports; 371 List<ImportElement> _imports;
358 List<ExportElement> _exports; 372 List<ExportElement> _exports;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 @override 575 @override
562 CompilationUnitElement get compilationUnit => this; 576 CompilationUnitElement get compilationUnit => this;
563 577
564 @override 578 @override
565 Element get enclosingElement => library; 579 Element get enclosingElement => library;
566 580
567 @override 581 @override
568 SourceSpan get sourcePosition => new SourceSpan(script.resourceUri, 0, 0); 582 SourceSpan get sourcePosition => new SourceSpan(script.resourceUri, 0, 0);
569 583
570 @override 584 @override
585 bool get isTopLevel => false;
586
587 @override
571 accept(ElementVisitor visitor, arg) { 588 accept(ElementVisitor visitor, arg) {
572 return visitor.visitCompilationUnitElement(this, arg); 589 return visitor.visitCompilationUnitElement(this, arg);
573 } 590 }
574 591
575 @override 592 @override
576 void forEachLocalMember(f(Element element)) { 593 void forEachLocalMember(f(Element element)) {
577 if (_members == null) { 594 if (_members == null) {
578 _members = _decoder.getElements(Key.ELEMENTS, isOptional: true); 595 _members = _decoder.getElements(Key.ELEMENTS, isOptional: true);
579 } 596 }
580 _members.forEach(f); 597 _members.forEach(f);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 679
663 abstract class InstanceMemberMixin implements DeserializedElementZ { 680 abstract class InstanceMemberMixin implements DeserializedElementZ {
664 @override 681 @override
665 bool get isTopLevel => false; 682 bool get isTopLevel => false;
666 683
667 @override 684 @override
668 bool get isStatic => false; 685 bool get isStatic => false;
669 686
670 @override 687 @override
671 bool get isInstanceMember => true; 688 bool get isInstanceMember => true;
689
690 @override
691 bool get isClassMember => true;
672 } 692 }
673 693
674 abstract class StaticMemberMixin implements DeserializedElementZ { 694 abstract class StaticMemberMixin implements DeserializedElementZ {
675 @override 695 @override
676 bool get isTopLevel => false; 696 bool get isTopLevel => false;
677 697
678 @override 698 @override
679 bool get isStatic => true; 699 bool get isStatic => true;
700
701 @override
702 bool get isClassMember => true;
680 } 703 }
681 704
682 abstract class TypedElementMixin implements DeserializedElementZ, TypedElement { 705 abstract class TypedElementMixin implements DeserializedElementZ, TypedElement {
683 DartType _type; 706 DartType _type;
684 707
685 @override 708 @override
686 DartType get type { 709 DartType get type {
687 if (_type == null) { 710 if (_type == null) {
688 _type = _decoder.getType(Key.TYPE); 711 _type = _decoder.getType(Key.TYPE);
689 } 712 }
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 ClassElementCommon, 976 ClassElementCommon,
954 ClassElementMixin, 977 ClassElementMixin,
955 class_members.ClassMemberMixin, 978 class_members.ClassMemberMixin,
956 TypeDeclarationMixin<InterfaceType>, 979 TypeDeclarationMixin<InterfaceType>,
957 AnalyzableElementMixin, 980 AnalyzableElementMixin,
958 AstElementMixinZ, 981 AstElementMixinZ,
959 MixinApplicationElementCommon, 982 MixinApplicationElementCommon,
960 MixinApplicationElementMixin { 983 MixinApplicationElementMixin {
961 final String name; 984 final String name;
962 final ClassElement _subclass; 985 final ClassElement _subclass;
963 final InterfaceType supertype; 986 final InterfaceType _supertypeBase;
964 final Link<DartType> interfaces; 987 final InterfaceType _mixinBase;
988 InterfaceType _supertype;
989 Link<DartType> _interfaces;
965 OrderedTypeSet _allSupertypesAndSelf; 990 OrderedTypeSet _allSupertypesAndSelf;
966 Link<ConstructorElement> _constructors; 991 Link<ConstructorElement> _constructors;
967 992
968 UnnamedMixinApplicationElementZ( 993 UnnamedMixinApplicationElementZ(
969 ClassElement subclass, InterfaceType supertype, InterfaceType mixin) 994 ClassElement subclass, InterfaceType supertype, InterfaceType mixin)
970 : this._subclass = subclass, 995 : this._subclass = subclass,
971 this.supertype = supertype, 996 this._supertypeBase = supertype,
972 this.interfaces = const Link<DartType>().prepend(mixin), 997 this._mixinBase = mixin,
973 this.name = "${supertype.name}+${mixin.name}"; 998 this.name = "${supertype.name}+${mixin.name}";
974 999
975 @override 1000 @override
976 CompilationUnitElement get compilationUnit => _subclass.compilationUnit; 1001 CompilationUnitElement get compilationUnit => _subclass.compilationUnit;
977 1002
978 @override 1003 @override
979 bool get isTopLevel => true; 1004 bool get isTopLevel => true;
980 1005
981 @override 1006 @override
1007 bool get isAbstract => true;
1008
1009 @override
982 bool get isUnnamedMixinApplication => true; 1010 bool get isUnnamedMixinApplication => true;
983 1011
984 Link<ConstructorElement> get constructors { 1012 Link<ConstructorElement> get constructors {
985 if (_constructors == null) { 1013 if (_constructors == null) {
986 LinkBuilder<ConstructorElement> builder = 1014 LinkBuilder<ConstructorElement> builder =
987 new LinkBuilder<ConstructorElement>(); 1015 new LinkBuilder<ConstructorElement>();
988 for (ConstructorElement definingConstructor in superclass.constructors) { 1016 for (ConstructorElement definingConstructor in superclass.constructors) {
989 if (definingConstructor.isGenerativeConstructor && 1017 if (definingConstructor.isGenerativeConstructor &&
990 definingConstructor.memberName.isAccessibleFrom(library)) { 1018 definingConstructor.memberName.isAccessibleFrom(library)) {
991 ForwardingConstructorElementZ constructor = 1019 ForwardingConstructorElementZ constructor =
(...skipping 25 matching lines...) Expand all
1017 TypeVariableType typeVariable = typeVariables[type.element.index]; 1045 TypeVariableType typeVariable = typeVariables[type.element.index];
1018 SyntheticTypeVariableElementZ typeVariableElement = typeVariable.element; 1046 SyntheticTypeVariableElementZ typeVariableElement = typeVariable.element;
1019 typeVariableElement._type = typeVariable; 1047 typeVariableElement._type = typeVariable;
1020 typeVariableElement._bound = 1048 typeVariableElement._bound =
1021 type.element.bound.subst(typeVariables, _subclass.typeVariables); 1049 type.element.bound.subst(typeVariables, _subclass.typeVariables);
1022 } 1050 }
1023 return typeVariables; 1051 return typeVariables;
1024 } 1052 }
1025 1053
1026 @override 1054 @override
1055 InterfaceType get supertype {
1056 if (_supertype == null) {
1057 // Substitute the type variables in [_supertypeBase] provided by
1058 // [_subclass] with the type variables in this unnamed mixin application.
1059 //
1060 // For instance
1061 // class S<S.T> {}
1062 // class M<M.T> {}
1063 // class C<C.T> extends S<C.T> with M<C.T> {}
1064 // the unnamed mixin application should be
1065 // abstract class S+M<S+M.T> extends S<S+M.T> implements M<S+M.T> {}
1066 // but the supertype is provided as S<C.T> and we need to substitute S+M.T
1067 // for C.T.
1068 _supertype = _supertypeBase.subst(typeVariables, _subclass.typeVariables);
1069 }
1070 return _supertype;
1071 }
1072
1073 @override
1074 Link<DartType> get interfaces {
1075 if (_interfaces == null) {
1076 // Substitute the type variables in [_mixinBase] provided by
1077 // [_subclass] with the type variables in this unnamed mixin application.
1078 //
1079 // For instance
1080 // class S<S.T> {}
1081 // class M<M.T> {}
1082 // class C<C.T> extends S<C.T> with M<C.T> {}
1083 // the unnamed mixin application should be
1084 // abstract class S+M<S+M.T> extends S<S+M.T> implements M<S+M.T> {}
1085 // but the mixin is provided as M<C.T> and we need to substitute S+M.T
1086 // for C.T.
1087 _interfaces = const Link<DartType>()
1088 .prepend(_mixinBase.subst(typeVariables, _subclass.typeVariables));
1089 }
1090 return _interfaces;
1091 }
1092
1093 @override
1027 accept(ElementVisitor visitor, arg) { 1094 accept(ElementVisitor visitor, arg) {
1028 return visitor.visitMixinApplicationElement(this, arg); 1095 return visitor.visitMixinApplicationElement(this, arg);
1029 } 1096 }
1030 1097
1031 @override 1098 @override
1032 OrderedTypeSet get allSupertypesAndSelf { 1099 OrderedTypeSet get allSupertypesAndSelf {
1033 if (_allSupertypesAndSelf == null) { 1100 if (_allSupertypesAndSelf == null) {
1034 _allSupertypesAndSelf = new OrderedTypeSetBuilder(this) 1101 _allSupertypesAndSelf = new OrderedTypeSetBuilder(this)
1035 .createOrderedTypeSet(supertype, interfaces); 1102 .createOrderedTypeSet(supertype, interfaces);
1036 } 1103 }
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 return enclosingClass.thisType.substByContext(newType); 1353 return enclosingClass.thisType.substByContext(newType);
1287 } 1354 }
1288 1355
1289 @override 1356 @override
1290 DartType computeType(Resolution resolution) => type; 1357 DartType computeType(Resolution resolution) => type;
1291 1358
1292 @override 1359 @override
1293 bool get isConst => false; 1360 bool get isConst => false;
1294 1361
1295 @override 1362 @override
1363 bool get isClassMember => true;
1364
1365 @override
1296 ConstantConstructor get constantConstructor => null; 1366 ConstantConstructor get constantConstructor => null;
1297 1367
1298 @override 1368 @override
1299 bool get hasEffectiveTarget => true; 1369 bool get hasEffectiveTarget => true;
1300 1370
1301 @override 1371 @override
1302 ConstructorElement get effectiveTarget => this; 1372 ConstructorElement get effectiveTarget => this;
1303 1373
1304 @override 1374 @override
1305 Element get enclosingElement => enclosingClass; 1375 Element get enclosingElement => enclosingClass;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 accept(ElementVisitor visitor, arg) { 1556 accept(ElementVisitor visitor, arg) {
1487 return visitor.visitMethodElement(this, arg); 1557 return visitor.visitMethodElement(this, arg);
1488 } 1558 }
1489 1559
1490 @override 1560 @override
1491 AsyncMarker get asyncMarker { 1561 AsyncMarker get asyncMarker {
1492 return _decoder.getEnum(Key.ASYNC_MARKER, AsyncMarker.values); 1562 return _decoder.getEnum(Key.ASYNC_MARKER, AsyncMarker.values);
1493 } 1563 }
1494 1564
1495 @override 1565 @override
1566 bool get isAbstract => _decoder.getBool(Key.IS_ABSTRACT);
1567
1568 @override
1496 bool get isOperator => _decoder.getBool(Key.IS_OPERATOR); 1569 bool get isOperator => _decoder.getBool(Key.IS_OPERATOR);
1497 } 1570 }
1498 1571
1499 class TopLevelFunctionElementZ extends FunctionElementZ 1572 class TopLevelFunctionElementZ extends FunctionElementZ
1500 with LibraryMemberMixin { 1573 with LibraryMemberMixin {
1501 TopLevelFunctionElementZ(ObjectDecoder decoder) : super(decoder); 1574 TopLevelFunctionElementZ(ObjectDecoder decoder) : super(decoder);
1502 } 1575 }
1503 1576
1504 class StaticFunctionElementZ extends FunctionElementZ 1577 class StaticFunctionElementZ extends FunctionElementZ
1505 with ClassMemberMixin, StaticMemberMixin { 1578 with ClassMemberMixin, StaticMemberMixin {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 1660
1588 @override 1661 @override
1589 ElementKind get kind => ElementKind.GETTER; 1662 ElementKind get kind => ElementKind.GETTER;
1590 1663
1591 @override 1664 @override
1592 accept(ElementVisitor visitor, arg) { 1665 accept(ElementVisitor visitor, arg) {
1593 return visitor.visitGetterElement(this, arg); 1666 return visitor.visitGetterElement(this, arg);
1594 } 1667 }
1595 1668
1596 @override 1669 @override
1670 bool get isAbstract => _decoder.getBool(Key.IS_ABSTRACT);
1671
1672 @override
1597 AsyncMarker get asyncMarker => AsyncMarker.SYNC; 1673 AsyncMarker get asyncMarker => AsyncMarker.SYNC;
1598 } 1674 }
1599 1675
1600 class TopLevelGetterElementZ extends GetterElementZ with LibraryMemberMixin { 1676 class TopLevelGetterElementZ extends GetterElementZ with LibraryMemberMixin {
1601 TopLevelGetterElementZ(ObjectDecoder decoder) : super(decoder); 1677 TopLevelGetterElementZ(ObjectDecoder decoder) : super(decoder);
1602 } 1678 }
1603 1679
1604 class StaticGetterElementZ extends GetterElementZ 1680 class StaticGetterElementZ extends GetterElementZ
1605 with ClassMemberMixin, StaticMemberMixin { 1681 with ClassMemberMixin, StaticMemberMixin {
1606 StaticGetterElementZ(ObjectDecoder decoder) : super(decoder); 1682 StaticGetterElementZ(ObjectDecoder decoder) : super(decoder);
(...skipping 20 matching lines...) Expand all
1627 1703
1628 @override 1704 @override
1629 ElementKind get kind => ElementKind.SETTER; 1705 ElementKind get kind => ElementKind.SETTER;
1630 1706
1631 @override 1707 @override
1632 accept(ElementVisitor visitor, arg) { 1708 accept(ElementVisitor visitor, arg) {
1633 return visitor.visitSetterElement(this, arg); 1709 return visitor.visitSetterElement(this, arg);
1634 } 1710 }
1635 1711
1636 @override 1712 @override
1713 bool get isAbstract => _decoder.getBool(Key.IS_ABSTRACT);
1714
1715 @override
1637 AsyncMarker get asyncMarker => AsyncMarker.SYNC; 1716 AsyncMarker get asyncMarker => AsyncMarker.SYNC;
1638 } 1717 }
1639 1718
1640 class TopLevelSetterElementZ extends SetterElementZ with LibraryMemberMixin { 1719 class TopLevelSetterElementZ extends SetterElementZ with LibraryMemberMixin {
1641 TopLevelSetterElementZ(ObjectDecoder decoder) : super(decoder); 1720 TopLevelSetterElementZ(ObjectDecoder decoder) : super(decoder);
1642 } 1721 }
1643 1722
1644 class StaticSetterElementZ extends SetterElementZ 1723 class StaticSetterElementZ extends SetterElementZ
1645 with ClassMemberMixin, StaticMemberMixin { 1724 with ClassMemberMixin, StaticMemberMixin {
1646 StaticSetterElementZ(ObjectDecoder decoder) : super(decoder); 1725 StaticSetterElementZ(ObjectDecoder decoder) : super(decoder);
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
2160 } 2239 }
2161 2240
2162 @override 2241 @override
2163 ElementKind get kind => ElementKind.PREFIX; 2242 ElementKind get kind => ElementKind.PREFIX;
2164 2243
2165 @override 2244 @override
2166 Element lookupLocalMember(String memberName) { 2245 Element lookupLocalMember(String memberName) {
2167 return _unsupported('lookupLocalMember'); 2246 return _unsupported('lookupLocalMember');
2168 } 2247 }
2169 } 2248 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698