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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/elements/modelx.dart

Issue 296513015: Revert "Handle metadata on nested function parameters." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 elements.modelx; 5 library elements.modelx;
6 6
7 import 'elements.dart'; 7 import 'elements.dart';
8 import '../helpers/helpers.dart'; 8 import '../helpers/helpers.dart';
9 import '../tree/tree.dart'; 9 import '../tree/tree.dart';
10 import '../util/util.dart'; 10 import '../util/util.dart';
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 'parseNode not implemented on $this.'); 54 'parseNode not implemented on $this.');
55 return null; 55 return null;
56 } 56 }
57 57
58 DartType computeType(Compiler compiler) { 58 DartType computeType(Compiler compiler) {
59 compiler.internalError(this, 59 compiler.internalError(this,
60 "computeType not implemented on $this."); 60 "computeType not implemented on $this.");
61 return null; 61 return null;
62 } 62 }
63 63
64 void addMetadata(MetadataAnnotationX annotation) { 64 void addMetadata(MetadataAnnotation annotation) {
65 assert(annotation.annotatedElement == null); 65 assert(annotation.annotatedElement == null);
66 annotation.annotatedElement = this; 66 annotation.annotatedElement = this;
67 addMetadataInternal(annotation); 67 addMetadataInternal(annotation);
68 } 68 }
69 69
70 void addMetadataInternal(MetadataAnnotation annotation) { 70 void addMetadataInternal(MetadataAnnotation annotation) {
71 metadata = metadata.prepend(annotation); 71 metadata = metadata.prepend(annotation);
72 } 72 }
73 73
74 bool get isClosure => false; 74 bool get isClosure => false;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 */ 195 */
196 Element get enclosingMember { 196 Element get enclosingMember {
197 for (Element e = this; e != null; e = e.enclosingElement) { 197 for (Element e = this; e != null; e = e.enclosingElement) {
198 if (e.isMember) return e; 198 if (e.isMember) return e;
199 } 199 }
200 return null; 200 return null;
201 } 201 }
202 202
203 Element get outermostEnclosingMemberOrTopLevel { 203 Element get outermostEnclosingMemberOrTopLevel {
204 // TODO(lrn): Why is this called "Outermost"? 204 // TODO(lrn): Why is this called "Outermost"?
205 // TODO(johnniwinther): Clean up this method: This method does not return
206 // the outermost for elements in closure classses, but some call-sites rely
207 // on that behavior.
208 for (Element e = this; e != null; e = e.enclosingElement) { 205 for (Element e = this; e != null; e = e.enclosingElement) {
209 if (e.isMember || e.isTopLevel) { 206 if (e.isMember || e.isTopLevel) {
210 return e; 207 return e;
211 } 208 }
212 } 209 }
213 return null; 210 return null;
214 } 211 }
215 212
216 ClassElement get contextClass { 213 ClassElement get contextClass {
217 ClassElement cls; 214 ClassElement cls;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 _fixedBackendName = name; 255 _fixedBackendName = name;
259 } 256 }
260 257
261 FunctionElement asFunctionElement() => null; 258 FunctionElement asFunctionElement() => null;
262 259
263 bool get isAbstract => modifiers.isAbstract; 260 bool get isAbstract => modifiers.isAbstract;
264 bool isForeign(Compiler compiler) => library == compiler.foreignLibrary; 261 bool isForeign(Compiler compiler) => library == compiler.foreignLibrary;
265 262
266 void diagnose(Element context, DiagnosticListener listener) {} 263 void diagnose(Element context, DiagnosticListener listener) {}
267 264
268 TreeElements get treeElements => analyzableElement.treeElements; 265 TreeElements get treeElements => enclosingElement.treeElements;
269
270 AnalyzableElement get analyzableElement => outermostEnclosingMemberOrTopLevel;
271 } 266 }
272 267
273 /** 268 /**
274 * Represents an unresolvable or duplicated element. 269 * Represents an unresolvable or duplicated element.
275 * 270 *
276 * An [ErroneousElement] is used instead of [:null:] to provide additional 271 * An [ErroneousElement] is used instead of [:null:] to provide additional
277 * information about the error that caused the element to be unresolvable 272 * information about the error that caused the element to be unresolvable
278 * or otherwise invalid. 273 * or otherwise invalid.
279 * 274 *
280 * Accessing any field or calling any method defined on [ErroneousElement] 275 * Accessing any field or calling any method defined on [ErroneousElement]
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 if (accessor.isGetter) { 536 if (accessor.isGetter) {
542 field.getter = accessor; 537 field.getter = accessor;
543 } else { 538 } else {
544 field.setter = accessor; 539 field.setter = accessor;
545 } 540 }
546 add(field, listener); 541 add(field, listener);
547 } 542 }
548 } 543 }
549 } 544 }
550 545
551 class CompilationUnitElementX extends ElementX 546 class CompilationUnitElementX extends ElementX with AnalyzableElement
552 implements CompilationUnitElement { 547 implements CompilationUnitElement {
553 final Script script; 548 final Script script;
554 PartOf partTag; 549 PartOf partTag;
555 Link<Element> localMembers = const Link<Element>(); 550 Link<Element> localMembers = const Link<Element>();
556 551
557 CompilationUnitElementX(Script script, LibraryElement library) 552 CompilationUnitElementX(Script script, LibraryElement library)
558 : this.script = script, 553 : this.script = script,
559 super(script.name, 554 super(script.name,
560 ElementKind.COMPILATION_UNIT, 555 ElementKind.COMPILATION_UNIT,
561 library) { 556 library) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 } 605 }
611 } 606 }
612 607
613 bool get hasMembers => !localMembers.isEmpty; 608 bool get hasMembers => !localMembers.isEmpty;
614 609
615 int compareTo(CompilationUnitElement other) { 610 int compareTo(CompilationUnitElement other) {
616 if (this == other) return 0; 611 if (this == other) return 0;
617 return '${script.readableUri}'.compareTo('${other.script.readableUri}'); 612 return '${script.readableUri}'.compareTo('${other.script.readableUri}');
618 } 613 }
619 614
620 Element get analyzableElement => library;
621
622 accept(ElementVisitor visitor) => visitor.visitCompilationUnitElement(this); 615 accept(ElementVisitor visitor) => visitor.visitCompilationUnitElement(this);
623 } 616 }
624 617
625 class Importers { 618 class Importers {
626 Map<Element, Link<Import>> importers = new Map<Element, Link<Import>>(); 619 Map<Element, Link<Import>> importers = new Map<Element, Link<Import>>();
627 620
628 Link<Import> getImports(Element element) { 621 Link<Import> getImports(Element element) {
629 Link<Import> imports = importers[element]; 622 Link<Import> imports = importers[element];
630 return imports != null ? imports : const Link<Import>(); 623 return imports != null ? imports : const Link<Import>();
631 } 624 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 importers.registerImport(ambiguousElement, import); 716 importers.registerImport(ambiguousElement, import);
724 importers.registerImport(ambiguousElement, existingImport); 717 importers.registerImport(ambiguousElement, existingImport);
725 } 718 }
726 } 719 }
727 } 720 }
728 721
729 Element operator [](String name) => importScope[name]; 722 Element operator [](String name) => importScope[name];
730 } 723 }
731 724
732 class LibraryElementX 725 class LibraryElementX
733 extends ElementX with AnalyzableElementX, PatchMixin<LibraryElementX> 726 extends ElementX with AnalyzableElement, PatchMixin<LibraryElementX>
734 implements LibraryElement { 727 implements LibraryElement {
735 final Uri canonicalUri; 728 final Uri canonicalUri;
736 CompilationUnitElement entryCompilationUnit; 729 CompilationUnitElement entryCompilationUnit;
737 Link<CompilationUnitElement> compilationUnits = 730 Link<CompilationUnitElement> compilationUnits =
738 const Link<CompilationUnitElement>(); 731 const Link<CompilationUnitElement>();
739 Link<LibraryTag> tags = const Link<LibraryTag>(); 732 Link<LibraryTag> tags = const Link<LibraryTag>();
740 LibraryName libraryTag; 733 LibraryName libraryTag;
741 bool canUseNative = false; 734 bool canUseNative = false;
742 Link<Element> localMembers = const Link<Element>(); 735 Link<Element> localMembers = const Link<Element>();
743 final ScopeX localScope = new ScopeX(); 736 final ScopeX localScope = new ScopeX();
(...skipping 30 matching lines...) Expand all
774 return (libraryTag == null) ? super.metadata : libraryTag.metadata; 767 return (libraryTag == null) ? super.metadata : libraryTag.metadata;
775 } 768 }
776 769
777 set metadata(value) { 770 set metadata(value) {
778 // The metadata is stored on [libraryTag]. 771 // The metadata is stored on [libraryTag].
779 throw new SpannableAssertionFailure(this, 'Cannot set metadata on Library'); 772 throw new SpannableAssertionFailure(this, 'Cannot set metadata on Library');
780 } 773 }
781 774
782 CompilationUnitElement get compilationUnit => entryCompilationUnit; 775 CompilationUnitElement get compilationUnit => entryCompilationUnit;
783 776
784 Element get analyzableElement => this;
785
786 void addCompilationUnit(CompilationUnitElement element) { 777 void addCompilationUnit(CompilationUnitElement element) {
787 compilationUnits = compilationUnits.prepend(element); 778 compilationUnits = compilationUnits.prepend(element);
788 } 779 }
789 780
790 void addTag(LibraryTag tag, DiagnosticListener listener) { 781 void addTag(LibraryTag tag, DiagnosticListener listener) {
791 tags = tags.prepend(tag); 782 tags = tags.prepend(tag);
792 } 783 }
793 784
794 void recordResolvedTag(LibraryDependency tag, LibraryElement library) { 785 void recordResolvedTag(LibraryDependency tag, LibraryElement library) {
795 assert(tagMapping[tag] == null); 786 assert(tagMapping[tag] == null);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 } 1001 }
1011 1002
1012 accept(ElementVisitor visitor) => visitor.visitPrefixElement(this); 1003 accept(ElementVisitor visitor) => visitor.visitPrefixElement(this);
1013 1004
1014 void markAsDeferred(Import deferredImport) { 1005 void markAsDeferred(Import deferredImport) {
1015 _deferredImport = deferredImport; 1006 _deferredImport = deferredImport;
1016 } 1007 }
1017 } 1008 }
1018 1009
1019 class TypedefElementX extends ElementX 1010 class TypedefElementX extends ElementX
1020 with AnalyzableElementX, TypeDeclarationElementX<TypedefType> 1011 with AnalyzableElement, TypeDeclarationElementX<TypedefType>
1021 implements TypedefElement { 1012 implements TypedefElement {
1022 Typedef cachedNode; 1013 Typedef cachedNode;
1023 1014
1024 /** 1015 /**
1025 * The type annotation which defines this typedef. 1016 * The type annotation which defines this typedef.
1026 */ 1017 */
1027 DartType alias; 1018 DartType alias;
1028 1019
1029 /// [:true:] if the typedef has been checked for cyclic reference. 1020 /// [:true:] if the typedef has been checked for cyclic reference.
1030 bool hasBeenCheckedForCycles = false; 1021 bool hasBeenCheckedForCycles = false;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 assert(modifiers != null); 1084 assert(modifiers != null);
1094 } 1085 }
1095 1086
1096 VariableDefinitions parseNode(Element element, DiagnosticListener listener) { 1087 VariableDefinitions parseNode(Element element, DiagnosticListener listener) {
1097 return definitions; 1088 return definitions;
1098 } 1089 }
1099 1090
1100 DartType computeType(Element element, Compiler compiler) => type; 1091 DartType computeType(Element element, Compiler compiler) => type;
1101 } 1092 }
1102 1093
1103 class VariableElementX extends ElementX with AnalyzableElementX 1094 class VariableElementX extends ElementX with AnalyzableElement
1104 implements VariableElement { 1095 implements VariableElement {
1105 final Token token; 1096 final Token token;
1106 final VariableList variables; 1097 final VariableList variables;
1107 VariableDefinitions definitionsCache; 1098 VariableDefinitions definitionsCache;
1108 Expression initializerCache; 1099 Expression initializerCache;
1109 1100
1110 Modifiers get modifiers => variables.modifiers; 1101 Modifiers get modifiers => variables.modifiers;
1111 1102
1112 VariableElementX(String name, 1103 VariableElementX(String name,
1113 ElementKind kind, 1104 ElementKind kind,
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 // by call sites of a call to a method with the other signature. 1440 // by call sites of a call to a method with the other signature.
1450 int otherTotalCount = signature.parameterCount; 1441 int otherTotalCount = signature.parameterCount;
1451 return requiredParameterCount <= otherTotalCount 1442 return requiredParameterCount <= otherTotalCount
1452 && parameterCount >= otherTotalCount; 1443 && parameterCount >= otherTotalCount;
1453 } 1444 }
1454 return true; 1445 return true;
1455 } 1446 }
1456 } 1447 }
1457 1448
1458 abstract class FunctionElementX 1449 abstract class FunctionElementX
1459 extends ElementX with AnalyzableElementX, PatchMixin<FunctionElement> 1450 extends ElementX with AnalyzableElement, PatchMixin<FunctionElement>
1460 implements FunctionElement { 1451 implements FunctionElement {
1461 DartType typeCache; 1452 DartType typeCache;
1462 final Modifiers modifiers; 1453 final Modifiers modifiers;
1463 1454
1464 List<FunctionElement> nestedClosures = new List<FunctionElement>(); 1455 List<FunctionElement> nestedClosures = new List<FunctionElement>();
1465 1456
1466 FunctionSignature functionSignatureCache; 1457 FunctionSignature functionSignatureCache;
1467 1458
1468 final bool _hasNoBody; 1459 final bool _hasNoBody;
1469 1460
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1814 new TypeVariableElementX(variableName, this, node); 1805 new TypeVariableElementX(variableName, this, node);
1815 TypeVariableType variableType = new TypeVariableType(variableElement); 1806 TypeVariableType variableType = new TypeVariableType(variableElement);
1816 variableElement.typeCache = variableType; 1807 variableElement.typeCache = variableType;
1817 arguments.addLast(variableType); 1808 arguments.addLast(variableType);
1818 } 1809 }
1819 return arguments.toLink(); 1810 return arguments.toLink();
1820 } 1811 }
1821 } 1812 }
1822 1813
1823 abstract class BaseClassElementX extends ElementX 1814 abstract class BaseClassElementX extends ElementX
1824 with AnalyzableElementX, 1815 with AnalyzableElement,
1825 TypeDeclarationElementX<InterfaceType>, 1816 TypeDeclarationElementX<InterfaceType>,
1826 PatchMixin<ClassElement>, 1817 PatchMixin<ClassElement>,
1827 ClassMemberMixin 1818 ClassMemberMixin
1828 implements ClassElement { 1819 implements ClassElement {
1829 final int id; 1820 final int id;
1830 1821
1831 DartType supertype; 1822 DartType supertype;
1832 Link<DartType> interfaces; 1823 Link<DartType> interfaces;
1833 String nativeTagInfo; 1824 String nativeTagInfo;
1834 int supertypeLoadState; 1825 int supertypeLoadState;
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
2555 assert(invariant(this, this.origin == null, 2546 assert(invariant(this, this.origin == null,
2556 message: "Origin element is a patch.")); 2547 message: "Origin element is a patch."));
2557 assert(invariant(patch, patch.origin == null, 2548 assert(invariant(patch, patch.origin == null,
2558 message: "Element is patched twice.")); 2549 message: "Element is patched twice."));
2559 assert(invariant(patch, patch.patch == null, 2550 assert(invariant(patch, patch.patch == null,
2560 message: "Patch element is patched.")); 2551 message: "Patch element is patched."));
2561 this.patch = patch; 2552 this.patch = patch;
2562 patch.origin = this; 2553 patch.origin = this;
2563 } 2554 }
2564 } 2555 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698