Index: pkg/front_end/lib/src/fasta/kernel/kernel_enum_builder.dart |
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_enum_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_enum_builder.dart |
index 0e29eee0ab2bb744deb4b13ed3f1770fff140450..6c44b1f74f183f04c08e0ace3e1daa22092bf9e0 100644 |
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_enum_builder.dart |
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_enum_builder.dart |
@@ -54,7 +54,7 @@ import '../names.dart' show indexGetName; |
class KernelEnumBuilder extends SourceClassBuilder |
implements EnumBuilder<KernelTypeBuilder, InterfaceType> { |
- final List<String> constants; |
+ final List<Object> constantNamesAndOffsets; |
final MapLiteral toStringMap; |
@@ -67,7 +67,7 @@ class KernelEnumBuilder extends SourceClassBuilder |
String name, |
Map<String, Builder> members, |
Class cls, |
- this.constants, |
+ this.constantNamesAndOffsets, |
this.toStringMap, |
this.intType, |
this.stringType, |
@@ -79,11 +79,11 @@ class KernelEnumBuilder extends SourceClassBuilder |
factory KernelEnumBuilder( |
List<MetadataBuilder> metadata, |
String name, |
- List<String> constants, |
+ List<Object> constantNamesAndOffsets, |
KernelLibraryBuilder parent, |
int charOffset, |
int charEndOffset) { |
- constants ??= const <String>[]; |
+ constantNamesAndOffsets ??= const <Object>[]; |
// TODO(ahe): These types shouldn't be looked up in scope, they come |
// directly from dart:core. |
KernelTypeBuilder intType = parent.addType( |
@@ -144,18 +144,15 @@ class KernelEnumBuilder extends SourceClassBuilder |
charEndOffset); |
members["toString"] = toStringBuilder; |
String className = name; |
- for (String name in constants) { |
+ for (int i = 0; i < constantNamesAndOffsets.length; i += 2) { |
+ String name = constantNamesAndOffsets[i]; |
+ int charOffset = constantNamesAndOffsets[i + 1]; |
if (members.containsKey(name)) { |
inputError(null, null, "Duplicated name: $name"); |
continue; |
} |
KernelFieldBuilder fieldBuilder = new KernelFieldBuilder( |
- null, |
- selfType, |
- name, |
- constMask | staticMask, |
- parent, |
- charOffset); // TODO(ahe): Get charOffset from [name]. |
+ null, selfType, name, constMask | staticMask, parent, charOffset); |
members[name] = fieldBuilder; |
toStringEntries.add(new MapEntry( |
new IntLiteral(index), new StringLiteral("$className.$name"))); |
@@ -167,7 +164,7 @@ class KernelEnumBuilder extends SourceClassBuilder |
name, |
members, |
cls, |
- constants, |
+ constantNamesAndOffsets, |
toStringMap, |
intType, |
stringType, |
@@ -190,7 +187,7 @@ class KernelEnumBuilder extends SourceClassBuilder |
} |
Class build(KernelLibraryBuilder libraryBuilder) { |
- if (constants.isEmpty) { |
+ if (constantNamesAndOffsets.isEmpty) { |
libraryBuilder.addCompileTimeError( |
-1, "An enum declaration can't be empty."); |
} |
@@ -206,7 +203,8 @@ class KernelEnumBuilder extends SourceClassBuilder |
new DirectPropertyGet(new ThisExpression(), indexField) |
]))); |
List<Expression> values = <Expression>[]; |
- for (String name in constants) { |
+ for (int i = 0; i < constantNamesAndOffsets.length; i += 2) { |
+ String name = constantNamesAndOffsets[i]; |
KernelFieldBuilder builder = members[name]; |
values.add(new StaticGet(builder.build(libraryBuilder))); |
} |
@@ -222,7 +220,8 @@ class KernelEnumBuilder extends SourceClassBuilder |
new VariableGet(constructor.function.positionalParameters.single)) |
..parent = constructor); |
int index = 0; |
- for (String constant in constants) { |
+ for (int i = 0; i < constantNamesAndOffsets.length; i += 2) { |
+ String constant = constantNamesAndOffsets[i]; |
KernelFieldBuilder field = members[constant]; |
field.build(libraryBuilder); |
Arguments arguments = |