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

Unified Diff: pkg/compiler/lib/src/elements/modelx.dart

Issue 1881013002: Expand ResolvedAst to handle synthetic constructors. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: dartfmt Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/elements/elements.dart ('k') | pkg/compiler/lib/src/id_generator.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+
+ ResolvedAst get resolvedAst {
+ 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.
Johnni Winther 2016/04/12 13:59:19 Comments add per request in previous CL.
+///
+/// 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);
}
}
« no previous file with comments | « pkg/compiler/lib/src/elements/elements.dart ('k') | pkg/compiler/lib/src/id_generator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698