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

Unified Diff: pkg/compiler/lib/src/js_backend/namer.dart

Issue 2711183002: Store toString value in enum. (Closed)
Patch Set: Created 3 years, 10 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
Index: pkg/compiler/lib/src/js_backend/namer.dart
diff --git a/pkg/compiler/lib/src/js_backend/namer.dart b/pkg/compiler/lib/src/js_backend/namer.dart
index 7e426b2c2bfb618cd76eeecf21bddb9c72099328..c41e2b9ea1aff2c361d4fdc245ff4712c7f7c3ab 100644
--- a/pkg/compiler/lib/src/js_backend/namer.dart
+++ b/pkg/compiler/lib/src/js_backend/namer.dart
@@ -1881,6 +1881,29 @@ class ConstantNamingVisitor implements ConstantValueVisitor {
@override
void visitConstructed(ConstructedConstantValue constant, [_]) {
addRoot(constant.type.element.name);
+
+ // Recognize enum constants and only include the index.
+ final Map<FieldEntity, ConstantValue> fieldMap = constant.fields;
+ int size = fieldMap.length;
+ if (size == 1 || size == 2) {
+ FieldEntity indexField;
+ for (FieldEntity field in fieldMap.keys) {
+ String name = field.name;
+ if (name == 'index') {
+ indexField = field;
+ } else if (name == '_name') {
+ // Ingore _name field.
+ } else {
+ indexField = null;
+ break;
+ }
+ }
+ if (indexField != null) {
+ _visit(constant.fields[indexField]);
+ return;
+ }
+ }
+
// TODO(johnniwinther): This should be accessed from a codegen closed world.
codegenWorldBuilder.forEachInstanceField(constant.type.element,
(_, FieldElement field) {
« no previous file with comments | « no previous file | pkg/compiler/lib/src/parser/element_listener.dart » ('j') | pkg/compiler/lib/src/parser/element_listener.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698