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

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

Issue 409473002: A bit of element model cleanup. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 5 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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; 5 library elements;
6 6
7 7
8 import '../tree/tree.dart'; 8 import '../tree/tree.dart';
9 import '../util/util.dart'; 9 import '../util/util.dart';
10 import '../resolution/resolution.dart'; 10 import '../resolution/resolution.dart';
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 /// This property is `false` if this element is an initializing formal. 278 /// This property is `false` if this element is an initializing formal.
279 /// See [isInitializingFormal]. 279 /// See [isInitializingFormal].
280 bool get isParameter => kind == ElementKind.PARAMETER; 280 bool get isParameter => kind == ElementKind.PARAMETER;
281 281
282 /// `true` if this element is an initializing formal of constructor, that 282 /// `true` if this element is an initializing formal of constructor, that
283 /// is a formal of the form `this.foo`. 283 /// is a formal of the form `this.foo`.
284 bool get isInitializingFormal => kind == ElementKind.INITIALIZING_FORMAL; 284 bool get isInitializingFormal => kind == ElementKind.INITIALIZING_FORMAL;
285 285
286 bool get isStatement; 286 bool get isStatement;
287 287
288 bool get isErroneous; 288 /// `true` if this element represents a resolution error.
289 bool get isAmbiguous; 289 bool get isErroneous => kind == ElementKind.ERROR;
290 bool get isWarnOnUse; 290
291 /// `true` if this element represents an ambiguous name.
292 ///
293 /// Ambiguous names occur when two imports/exports contain different entities
294 /// by the same name. If an ambiguous name is resolved an warning or error
295 /// is produced.
296 bool get isAmbiguous => kind == ElementKind.AMBIGUOUS;
297
298 /// `true` if this element represents an entity whose access causes one or
299 /// more warnings.
300 bool get isWarnOnUse => kind == ElementKind.WARN_ON_USE;
291 301
292 bool get isClosure; 302 bool get isClosure;
293 303
294 /// `true` if the element is a (static or instance) member of a class. 304 /// `true` if the element is a (static or instance) member of a class.
305 ///
295 /// Members are constructors, methods and fields. 306 /// Members are constructors, methods and fields.
296 bool get isClassMember; 307 bool get isClassMember;
297 308
298 /// `true` if the element is a nonstatic member of a class. 309 /// `true` if the element is a nonstatic member of a class.
310 ///
299 /// Instance members are methods and fields but not constructors. 311 /// Instance members are methods and fields but not constructors.
300 bool get isInstanceMember; 312 bool get isInstanceMember;
301 313
302 /// Returns true if this [Element] is a top level element. 314 /// Returns true if this [Element] is a top level element.
303 /// That is, if it is not defined within the scope of a class. 315 /// That is, if it is not defined within the scope of a class.
304 /// 316 ///
305 /// This means whether the enclosing element is a compilation unit. 317 /// This means whether the enclosing element is a compilation unit.
306 /// With the exception of [ClosureClassElement] that is considered top level 318 /// With the exception of [ClosureClassElement] that is considered top level
307 /// as all other classes. 319 /// as all other classes.
308 bool get isTopLevel; 320 bool get isTopLevel;
(...skipping 19 matching lines...) Expand all
328 340
329 bool get impliesType; 341 bool get impliesType;
330 342
331 Token get position; 343 Token get position;
332 344
333 CompilationUnitElement get compilationUnit; 345 CompilationUnitElement get compilationUnit;
334 LibraryElement get library; 346 LibraryElement get library;
335 LibraryElement get implementationLibrary; 347 LibraryElement get implementationLibrary;
336 ClassElement get enclosingClass; 348 ClassElement get enclosingClass;
337 Element get enclosingClassOrCompilationUnit; 349 Element get enclosingClassOrCompilationUnit;
338 Element get enclosingMember;
339 Element get outermostEnclosingMemberOrTopLevel; 350 Element get outermostEnclosingMemberOrTopLevel;
340 351
341 /// The enclosing class that defines the type environment for this element. 352 /// The enclosing class that defines the type environment for this element.
342 ClassElement get contextClass; 353 ClassElement get contextClass;
343 354
344 FunctionElement asFunctionElement(); 355 FunctionElement asFunctionElement();
345 356
346 /// Is [:true:] if this element has a corresponding patch. 357 /// Is [:true:] if this element has a corresponding patch.
347 /// 358 ///
348 /// If [:true:] this element has a non-null [patch] field. 359 /// If [:true:] this element has a non-null [patch] field.
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 TargetElement element = elements[body]; 771 TargetElement element = elements[body];
761 // Labeled statements with no element on the body have no breaks. 772 // Labeled statements with no element on the body have no breaks.
762 // A different target statement only happens if the body is itself 773 // A different target statement only happens if the body is itself
763 // a break or continue for a different target. In that case, this 774 // a break or continue for a different target. In that case, this
764 // label is also always unused. 775 // label is also always unused.
765 return element == null || element.statement != body; 776 return element == null || element.statement != body;
766 } 777 }
767 } 778 }
768 779
769 /// An element representing an erroneous resolution. 780 /// An element representing an erroneous resolution.
781 ///
782 /// An [ErroneousElement] is used instead of `null` to provide additional
783 /// information about the error that caused the element to be unresolvable
784 /// or otherwise invalid.
785 ///
786 /// Accessing any field or calling any method defined on [ErroneousElement]
787 /// except [isErroneous] will currently throw an exception. (This might
788 /// change when we actually want more information on the erroneous element,
789 /// e.g., the name of the element we were trying to resolve.)
790 ///
791 /// Code that cannot not handle an [ErroneousElement] should use
792 /// `Element.isUnresolved(element)` to check for unresolvable elements instead
793 /// of `element == null`.
770 abstract class ErroneousElement extends Element implements ConstructorElement { 794 abstract class ErroneousElement extends Element implements ConstructorElement {
771 MessageKind get messageKind; 795 MessageKind get messageKind;
772 Map get messageArguments; 796 Map get messageArguments;
773 String get message; 797 String get message;
774 } 798 }
775 799
776 /// An [Element] whose usage should cause a warning. 800 /// An [Element] whose usage should cause one or more warnings.
777 abstract class WarnOnUseElement extends Element { 801 abstract class WarnOnUseElement extends Element {
778 /// The element whose usage cause a warning. 802 /// The element whose usage cause a warning.
779 Element get wrappedElement; 803 Element get wrappedElement;
780 804
781 /// Reports the attached warning and returns the wrapped element. 805 /// Reports the attached warning and returns the wrapped element.
782 /// [usageSpannable] is used to report messages on the reference of 806 /// [usageSpannable] is used to report messages on the reference of
783 /// [wrappedElement]. 807 /// [wrappedElement].
784 Element unwrap(DiagnosticListener listener, Spannable usageSpannable); 808 Element unwrap(DiagnosticListener listener, Spannable usageSpannable);
785 } 809 }
786 810
787 /// An element representing the ambiguous resolution of a name. 811 /// An ambiguous element represents multiple elements accessible by the same
812 /// name.
813 ///
814 /// Ambiguous elements are created during handling of import/export scopes. If
815 /// an ambiguous element is encountered during resolution a warning/error is
816 /// reported.
788 abstract class AmbiguousElement extends Element { 817 abstract class AmbiguousElement extends Element {
789 MessageKind get messageKind; 818 MessageKind get messageKind;
790 Map get messageArguments; 819 Map get messageArguments;
791 Element get existingElement; 820 Element get existingElement;
792 Element get newElement; 821 Element get newElement;
793 } 822 }
794 823
795 // TODO(kasperl): This probably shouldn't be called an element. It's 824 // TODO(kasperl): This probably shouldn't be called an element. It's
796 // just an interface shared by classes and libraries. 825 // just an interface shared by classes and libraries.
797 abstract class ScopeContainerElement implements Element { 826 abstract class ScopeContainerElement implements Element {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 } 980 }
952 981
953 /// A top level, static or instance field, a formal parameter or local variable. 982 /// A top level, static or instance field, a formal parameter or local variable.
954 abstract class VariableElement extends ExecutableElement { 983 abstract class VariableElement extends ExecutableElement {
955 Expression get initializer; 984 Expression get initializer;
956 } 985 }
957 986
958 /// An entity that defines a local entity (memory slot) in generated code. 987 /// An entity that defines a local entity (memory slot) in generated code.
959 /// 988 ///
960 /// Parameters, local variables and local functions (can) define local entity 989 /// Parameters, local variables and local functions (can) define local entity
961 /// and thus implement [Local] through [LocalElement]. For 990 /// and thus implement [Local] through [LocalElement]. For non-element locals,
962 /// non-element locals, like `this` and boxes, specialized [Local] class are 991 /// like `this` and boxes, specialized [Local] classes are created.
963 /// created.
964 /// 992 ///
965 /// Type variables can introduce locals in factories and constructors 993 /// Type variables can introduce locals in factories and constructors
966 /// but since one type variable can introduce different locals in different 994 /// but since one type variable can introduce different locals in different
967 /// factories and constructors it is not itself a [Local] but instead 995 /// factories and constructors it is not itself a [Local] but instead
968 /// a non-element [Local] is created through a specialized class. 996 /// a non-element [Local] is created through a specialized class.
969 // TODO(johnniwinther): Should [Local] have `isAssignable` or `type`? 997 // TODO(johnniwinther): Should [Local] have `isAssignable` or `type`?
970 abstract class Local extends Entity { 998 abstract class Local extends Entity {
971 /// The context in which this local is defined. 999 /// The context in which this local is defined.
972 ExecutableElement get executableContext; 1000 ExecutableElement get executableContext;
973 } 1001 }
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 bool get isDeclaredByField; 1544 bool get isDeclaredByField;
1517 1545
1518 /// Returns `true` if this member is abstract. 1546 /// Returns `true` if this member is abstract.
1519 bool get isAbstract; 1547 bool get isAbstract;
1520 1548
1521 /// If abstract, [implementation] points to the overridden concrete member, 1549 /// If abstract, [implementation] points to the overridden concrete member,
1522 /// if any. Otherwise [implementation] points to the member itself. 1550 /// if any. Otherwise [implementation] points to the member itself.
1523 Member get implementation; 1551 Member get implementation;
1524 } 1552 }
1525 1553
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/closure.dart ('k') | sdk/lib/_internal/compiler/implementation/elements/modelx.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698