Chromium Code Reviews| Index: pkg/compiler/lib/src/resolution/access_semantics.dart |
| diff --git a/pkg/compiler/lib/src/resolution/access_semantics.dart b/pkg/compiler/lib/src/resolution/access_semantics.dart |
| index 6aaabf6da1378a2fd6a5d93254ba5a4a192aa86c..10800dd3fdab5cf42db04de04b18886a1de7f5a8 100644 |
| --- a/pkg/compiler/lib/src/resolution/access_semantics.dart |
| +++ b/pkg/compiler/lib/src/resolution/access_semantics.dart |
| @@ -12,6 +12,7 @@ library dart2js.access_semantics; |
| import '../constants/expressions.dart'; |
| import '../elements/elements.dart'; |
| +import '../dart_types.dart'; |
| /// Enum representing the different kinds of destinations which a property |
| /// access or method or function invocation might refer to. |
| @@ -307,3 +308,124 @@ class CompoundAccessSemantics extends AccessSemantics { |
| Element get element => setter; |
| } |
| + |
| +/// Enum representing the different kinds of destinations which a constructor |
| +/// invocation might refer to. |
| +enum ConstructorAccessKind { |
| + /// An invocation of a generative constructor. |
| + /// |
| + /// For instance |
| + /// class C { |
| + /// C(); |
| + /// } |
| + /// m() => new C(); |
| + /// |
| + GENERATIVE, |
|
floitsch
2015/03/30 17:17:24
fyi.
This seems to be under discussion, but enum v
Johnni Winther
2015/03/31 09:51:14
Because they were to easy to recognize and underst
|
| + |
| + /// An invocation of a redirecting generative constructor. |
| + /// |
| + /// For instance |
| + /// class C { |
| + /// C() : this._(); |
| + /// C._(); |
| + /// } |
| + /// m() => new C(); |
| + /// |
| + REDIRECTING_GENERATIVE, |
| + |
| + /// An invocation of a factory constructor. |
| + /// |
| + /// For instance |
| + /// class C { |
| + /// factory C() => new C._(); |
| + /// C._(); |
| + /// } |
| + /// m() => new C(); |
| + /// |
| + FACTORY, |
| + |
| + /// An invocation of a redirecting factory constructor. |
| + /// |
| + /// For instance |
| + /// class C { |
| + /// factory C() = C._; |
| + /// C._(); |
| + /// } |
| + /// m() => new C(); |
| + /// |
| + REDIRECTING_FACTORY, |
| + |
| + /// An invocation of a (redirecting) generative constructor of an abstract |
| + /// class. |
| + /// |
| + /// For instance |
| + /// abstract class C { |
| + /// C(); |
| + /// } |
| + /// m() => new C(); |
| + /// |
| + ABSTRACT, |
| + |
| + /// An invocation of an unresolved constructor or an unresolved type. |
| + /// |
| + /// For instance |
| + /// class C { |
| + /// C(); |
| + /// } |
| + /// m1() => new C.unresolved(); |
| + /// m2() => new Unresolved(); |
| + /// |
| + // TODO(johnniwinther): Differentiate between error types. |
| + ERRONEOUS, |
| + |
| + /// An invocation of an ill-defined redirecting factory constructor. |
| + /// |
| + /// For instance |
| + /// class C { |
| + /// factory C() = Unresolved; |
| + /// } |
| + /// m() => new C(); |
| + /// |
| + ERRONEOUS_REDIRECTING_FACTORY, |
| +} |
| + |
| +/// Data structure used to classify the semantics of a constructor invocation. |
| +class ConstructorAccessSemantics { |
| + /// The kind of constructor invocation. |
| + final ConstructorAccessKind kind; |
| + |
| + /// The invoked constructor. |
| + final Element element; |
| + |
| + /// The type on which the constructor is invoked. |
| + final DartType type; |
| + |
| + ConstructorAccessSemantics(this.kind, this.element, this.type); |
| + |
| + /// The effect target of the access. Used to defined redirecting factory |
| + /// constructor invocations. |
| + ConstructorAccessSemantics get effectiveTargetSemantics => this; |
| + |
| + /// `true` if this invocation is erroneous. |
| + bool get isErroneous { |
| + return kind == ConstructorAccessKind.ABSTRACT || |
| + kind == ConstructorAccessKind.ERRONEOUS || |
| + kind == ConstructorAccessKind.ERRONEOUS_REDIRECTING_FACTORY; |
| + } |
| +} |
| + |
| +/// Data structure used to classify the semantics of a redirecting factory |
| +/// constructor invocation. |
| +class RedirectingFactoryConstructorAccessSemantics |
| + extends ConstructorAccessSemantics { |
| + final ConstructorAccessSemantics effectiveTargetSemantics; |
| + |
| + RedirectingFactoryConstructorAccessSemantics( |
| + ConstructorAccessKind kind, |
| + Element element, |
| + DartType type, |
| + this.effectiveTargetSemantics) |
| + : super(kind, element, type); |
| +} |
| + |
| + |