Index: pkg/compiler/lib/src/elements/modelx.dart |
diff --git a/pkg/compiler/lib/src/elements/modelx.dart b/pkg/compiler/lib/src/elements/modelx.dart |
index fe64aec668ac6495265542ec7491aa686b54b3e3..20a32abd5f03d76ed42b94f4d4762f5623fab65b 100644 |
--- a/pkg/compiler/lib/src/elements/modelx.dart |
+++ b/pkg/compiler/lib/src/elements/modelx.dart |
@@ -2355,6 +2355,16 @@ class SynthesizedConstructorElementX extends ConstructorElementX { |
bool get isSynthesized => true; |
+ bool get hasResolvedAst => true; |
Siggi Cherem (dart-lang)
2016/04/12 17:52:57
by now do all declarations have `hasResolvedAst` t
Johnni Winther
2016/04/13 10:18:12
Soon-ish. I want to move the whole logic out of th
|
+ |
+ ResolvedAst get resolvedAst { |
Siggi Cherem (dart-lang)
2016/04/12 17:52:57
should we make this a final field that is allocate
Johnni Winther
2016/04/13 10:18:12
Done. Not final though, it references this.
|
+ return new SynthesizedResolvedAst( |
+ this, |
+ isDefaultConstructor |
+ ? ResolvedAstKind.DEFAULT_CONSTRUCTOR |
+ : ResolvedAstKind.FORWARDING_CONSTRUCTOR); |
+ } |
+ |
DartType get type { |
if (isDefaultConstructor) { |
return super.type; |
@@ -2694,6 +2704,31 @@ abstract class ClassElementX extends BaseClassElementX { |
} |
} |
+/// This element is used to encode an enum class. |
+/// |
+/// For instance |
+/// |
+/// enum A { b, c, } |
+/// |
+/// is modelled as |
+/// |
+/// class A { |
+/// final int index; |
+/// |
+/// const A(this.index); |
+/// |
+/// String toString() { |
+/// return const <int, A>{0: 'A.b', 1: 'A.c'}[index]; |
+/// } |
+/// |
+/// static const A b = const A(0); |
+/// static const A c = const A(1); |
+/// |
+/// static const List<A> values = const <A>[b, c]; |
+/// } |
+/// |
+/// where the `A` class is encoded using this element. |
+/// |
class EnumClassElementX extends ClassElementX |
implements EnumClassElement, DeclarationSite { |
final Enum node; |
@@ -2737,6 +2772,31 @@ class EnumClassElementX extends ClassElementX |
DeclarationSite get declarationSite => this; |
} |
+/// This element is used to encode the implicit constructor in an enum class. |
+/// |
+/// For instance |
+/// |
+/// enum A { b, c, } |
+/// |
+/// is modelled as |
+/// |
+/// class A { |
+/// final int index; |
+/// |
+/// const A(this.index); |
+/// |
+/// String toString() { |
+/// return const <int, A>{0: 'A.b', 1: 'A.c'}[index]; |
+/// } |
+/// |
+/// static const A b = const A(0); |
+/// static const A c = const A(1); |
+/// |
+/// static const List<A> values = const <A>[b, c]; |
+/// } |
+/// |
+/// where the `const A(...)` constructor is encoded using this element. |
+/// |
class EnumConstructorElementX extends ConstructorElementX { |
final FunctionExpression node; |
@@ -2758,6 +2818,31 @@ class EnumConstructorElementX extends ConstructorElementX { |
SourceSpan get sourcePosition => enclosingClass.sourcePosition; |
} |
+/// This element is used to encode the implicit methods in an enum class. |
+/// |
+/// For instance |
+/// |
+/// enum A { b, c, } |
+/// |
+/// is modelled as |
+/// |
+/// class A { |
+/// final int index; |
+/// |
+/// const A(this.index); |
+/// |
+/// String toString() { |
+/// return const <int, A>{0: 'A.b', 1: 'A.c'}[index]; |
+/// } |
+/// |
+/// static const A b = const A(0); |
+/// static const A c = const A(1); |
+/// |
+/// static const List<A> values = const <A>[b, c]; |
+/// } |
+/// |
+/// where the `toString` method is encoded using this element. |
+/// |
class EnumMethodElementX extends MethodElementX { |
final FunctionExpression node; |
@@ -2775,6 +2860,32 @@ class EnumMethodElementX extends MethodElementX { |
SourceSpan get sourcePosition => enclosingClass.sourcePosition; |
} |
+/// This element is used to encode the initializing formal of the implicit |
+/// constructor in an enum class. |
+/// |
+/// For instance |
+/// |
+/// enum A { b, c, } |
+/// |
+/// is modelled as |
+/// |
+/// class A { |
+/// final int index; |
+/// |
+/// const A(this.index); |
+/// |
+/// String toString() { |
+/// return const <int, A>{0: 'A.b', 1: 'A.c'}[index]; |
+/// } |
+/// |
+/// static const A b = const A(0); |
+/// static const A c = const A(1); |
+/// |
+/// static const List<A> values = const <A>[b, c]; |
+/// } |
+/// |
+/// where the `this.index` formal is encoded using this element. |
+/// |
class EnumFormalElementX extends InitializingFormalElementX { |
EnumFormalElementX( |
ConstructorElement constructor, |
@@ -2789,6 +2900,31 @@ class EnumFormalElementX extends InitializingFormalElementX { |
SourceSpan get sourcePosition => enclosingClass.sourcePosition; |
} |
+/// This element is used to encode the implicitly fields in an enum class. |
+/// |
+/// For instance |
+/// |
+/// enum A { b, c, } |
+/// |
+/// is modelled as |
+/// |
+/// class A { |
+/// final int index; |
+/// |
+/// const A(this.index); |
+/// |
+/// String toString() { |
+/// return const <int, A>{0: 'A.b', 1: 'A.c'}[index]; |
+/// } |
+/// |
+/// static const A b = const A(0); |
+/// static const A c = const A(1); |
+/// |
+/// static const List<A> values = const <A>[b, c]; |
+/// } |
+/// |
+/// where the `index` and `values` fields are encoded using this element. |
+/// |
class EnumFieldElementX extends FieldElementX { |
EnumFieldElementX(Identifier name, EnumClassElementX enumClass, |
VariableList variableList, Node definition, |
@@ -2803,6 +2939,31 @@ class EnumFieldElementX extends FieldElementX { |
SourceSpan get sourcePosition => enclosingClass.sourcePosition; |
} |
+/// This element is used to encode the constant value in an enum class. |
+/// |
+/// For instance |
+/// |
+/// enum A { b, c, } |
+/// |
+/// is modelled as |
+/// |
+/// class A { |
+/// final int index; |
+/// |
+/// const A(this.index); |
+/// |
+/// String toString() { |
+/// return const <int, A>{0: 'A.b', 1: 'A.c'}[index]; |
+/// } |
+/// |
+/// static const A b = const A(0); |
+/// static const A c = const A(1); |
+/// |
+/// static const List<A> values = const <A>[b, c]; |
+/// } |
+/// |
+/// where the `b` and `c` fields are encoded using this element. |
+/// |
class EnumConstantElementX extends EnumFieldElementX |
implements EnumConstantElement { |
final int index; |
@@ -2818,8 +2979,7 @@ class EnumConstantElementX extends EnumFieldElementX |
@override |
SourceSpan get sourcePosition { |
- return new SourceSpan( |
- enclosingClass.sourcePosition.uri, |
+ return new SourceSpan(enclosingClass.sourcePosition.uri, |
position.charOffset, position.charEnd); |
} |
} |
@@ -3126,7 +3286,7 @@ abstract class AstElementMixin implements AstElement { |
} |
ResolvedAst get resolvedAst { |
- return new ResolvedAst( |
+ return new ParsedResolvedAst( |
declaration, definingElement.node, definingElement.treeElements); |
} |
} |