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

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

Issue 296463003: Handle metadata on nested function parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update comment. 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(MetadataAnnotation annotation) { 64 void addMetadata(MetadataAnnotationX 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 * Returns the member enclosing this element or the element itself if it is a 193 * Returns the member enclosing this element or the element itself if it is a
194 * member. If no enclosing element is found, [:null:] is returned. 194 * member. If no enclosing element is found, [:null:] is returned.
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 {
karlklose 2014/05/22 06:27:29 Add a TODO to remove this helper or give it a bett
Johnni Winther 2014/05/22 10:09:09 Done.
204 // TODO(lrn): Why is this called "Outermost"? 204 // TODO(johnniwinther): Fix this for members of a closure class.
205 for (Element e = this; e != null; e = e.enclosingElement) { 205 for (Element e = this; e != null; e = e.enclosingElement) {
206 if (e.isMember || e.isTopLevel) { 206 if (e.isMember || e.isTopLevel) {
207 return e; 207 return e;
208 } 208 }
209 } 209 }
210 return null; 210 return null;
211 } 211 }
212 212
213 ClassElement get contextClass { 213 ClassElement get contextClass {
214 ClassElement cls; 214 ClassElement cls;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 257
258 FunctionElement asFunctionElement() => null; 258 FunctionElement asFunctionElement() => null;
259 259
260 bool get isAbstract => modifiers.isAbstract; 260 bool get isAbstract => modifiers.isAbstract;
261 bool isForeign(Compiler compiler) => library == compiler.foreignLibrary; 261 bool isForeign(Compiler compiler) => library == compiler.foreignLibrary;
262 262
263 FunctionElement get targetConstructor => null; 263 FunctionElement get targetConstructor => null;
264 264
265 void diagnose(Element context, DiagnosticListener listener) {} 265 void diagnose(Element context, DiagnosticListener listener) {}
266 266
267 TreeElements get treeElements => enclosingElement.treeElements; 267 TreeElements get treeElements => analyzableElement.treeElements;
268
269 Element get analyzableElement => outermostEnclosingMemberOrTopLevel;
268 } 270 }
269 271
270 /** 272 /**
271 * Represents an unresolvable or duplicated element. 273 * Represents an unresolvable or duplicated element.
272 * 274 *
273 * An [ErroneousElement] is used instead of [:null:] to provide additional 275 * An [ErroneousElement] is used instead of [:null:] to provide additional
274 * information about the error that caused the element to be unresolvable 276 * information about the error that caused the element to be unresolvable
275 * or otherwise invalid. 277 * or otherwise invalid.
276 * 278 *
277 * Accessing any field or calling any method defined on [ErroneousElement] 279 * Accessing any field or calling any method defined on [ErroneousElement]
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 if (accessor.isGetter) { 536 if (accessor.isGetter) {
535 field.getter = accessor; 537 field.getter = accessor;
536 } else { 538 } else {
537 field.setter = accessor; 539 field.setter = accessor;
538 } 540 }
539 add(field, listener); 541 add(field, listener);
540 } 542 }
541 } 543 }
542 } 544 }
543 545
544 class CompilationUnitElementX extends ElementX with AnalyzableElement 546 class CompilationUnitElementX extends ElementX
545 implements CompilationUnitElement { 547 implements CompilationUnitElement {
546 final Script script; 548 final Script script;
547 PartOf partTag; 549 PartOf partTag;
548 Link<Element> localMembers = const Link<Element>(); 550 Link<Element> localMembers = const Link<Element>();
549 551
550 CompilationUnitElementX(Script script, LibraryElement library) 552 CompilationUnitElementX(Script script, LibraryElement library)
551 : this.script = script, 553 : this.script = script,
552 super(script.name, 554 super(script.name,
553 ElementKind.COMPILATION_UNIT, 555 ElementKind.COMPILATION_UNIT,
554 library) { 556 library) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 } 605 }
604 } 606 }
605 607
606 bool get hasMembers => !localMembers.isEmpty; 608 bool get hasMembers => !localMembers.isEmpty;
607 609
608 int compareTo(CompilationUnitElement other) { 610 int compareTo(CompilationUnitElement other) {
609 if (this == other) return 0; 611 if (this == other) return 0;
610 return '${script.readableUri}'.compareTo('${other.script.readableUri}'); 612 return '${script.readableUri}'.compareTo('${other.script.readableUri}');
611 } 613 }
612 614
615 Element get analyzableElement => library;
616
613 accept(ElementVisitor visitor) => visitor.visitCompilationUnitElement(this); 617 accept(ElementVisitor visitor) => visitor.visitCompilationUnitElement(this);
614 } 618 }
615 619
616 class Importers { 620 class Importers {
617 Map<Element, Link<Import>> importers = new Map<Element, Link<Import>>(); 621 Map<Element, Link<Import>> importers = new Map<Element, Link<Import>>();
618 622
619 Link<Import> getImports(Element element) { 623 Link<Import> getImports(Element element) {
620 Link<Import> imports = importers[element]; 624 Link<Import> imports = importers[element];
621 return imports != null ? imports : const Link<Import>(); 625 return imports != null ? imports : const Link<Import>();
622 } 626 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 return (libraryTag == null) ? super.metadata : libraryTag.metadata; 769 return (libraryTag == null) ? super.metadata : libraryTag.metadata;
766 } 770 }
767 771
768 set metadata(value) { 772 set metadata(value) {
769 // The metadata is stored on [libraryTag]. 773 // The metadata is stored on [libraryTag].
770 throw new SpannableAssertionFailure(this, 'Cannot set metadata on Library'); 774 throw new SpannableAssertionFailure(this, 'Cannot set metadata on Library');
771 } 775 }
772 776
773 CompilationUnitElement get compilationUnit => entryCompilationUnit; 777 CompilationUnitElement get compilationUnit => entryCompilationUnit;
774 778
779 Element get analyzableElement => this;
780
775 void addCompilationUnit(CompilationUnitElement element) { 781 void addCompilationUnit(CompilationUnitElement element) {
776 compilationUnits = compilationUnits.prepend(element); 782 compilationUnits = compilationUnits.prepend(element);
777 } 783 }
778 784
779 void addTag(LibraryTag tag, DiagnosticListener listener) { 785 void addTag(LibraryTag tag, DiagnosticListener listener) {
780 tags = tags.prepend(tag); 786 tags = tags.prepend(tag);
781 } 787 }
782 788
783 void recordResolvedTag(LibraryDependency tag, LibraryElement library) { 789 void recordResolvedTag(LibraryDependency tag, LibraryElement library) {
784 assert(tagMapping[tag] == null); 790 assert(tagMapping[tag] == null);
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after
2563 assert(invariant(this, this.origin == null, 2569 assert(invariant(this, this.origin == null,
2564 message: "Origin element is a patch.")); 2570 message: "Origin element is a patch."));
2565 assert(invariant(patch, patch.origin == null, 2571 assert(invariant(patch, patch.origin == null,
2566 message: "Element is patched twice.")); 2572 message: "Element is patched twice."));
2567 assert(invariant(patch, patch.patch == null, 2573 assert(invariant(patch, patch.patch == null,
2568 message: "Patch element is patched.")); 2574 message: "Patch element is patched."));
2569 this.patch = patch; 2575 this.patch = patch;
2570 patch.origin = this; 2576 patch.origin = this;
2571 } 2577 }
2572 } 2578 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698