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

Unified Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 1007013003: Provide value for values field in enums (issue 22722) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 | « no previous file | pkg/analyzer/test/generated/all_the_rest_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index d204a71ec39d589fefd505939dfa191e16935624..eaa80a47742dac6bf2329a9f04b943d941abd7d3 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -3731,7 +3731,7 @@ class EnumMemberBuilder extends RecursiveAstVisitor<Object> {
indexField.type = intType;
fields.add(indexField);
getters.add(_createGetter(indexField));
- FieldElementImpl valuesField = new FieldElementImpl("values", -1);
+ ConstFieldElementImpl valuesField = new ConstFieldElementImpl.con2("values", -1);
valuesField.static = true;
valuesField.const3 = true;
valuesField.synthetic = true;
@@ -3742,6 +3742,7 @@ class EnumMemberBuilder extends RecursiveAstVisitor<Object> {
// Build the enum constants.
//
NodeList<EnumConstantDeclaration> constants = node.constants;
+ List<DartObjectImpl> constantValues = new List<DartObjectImpl>();
int constantCount = constants.length;
for (int i = 0; i < constantCount; i++) {
SimpleIdentifier constantName = constants[i].name;
@@ -3758,12 +3759,17 @@ class EnumMemberBuilder extends RecursiveAstVisitor<Object> {
fieldMap[indexFieldName] = new DartObjectImpl(intType, new IntState(i));
DartObjectImpl value =
new DartObjectImpl(enumType, new GenericState(fieldMap));
+ constantValues.add(value);
constantField.evaluationResult = new EvaluationResultImpl.con1(value);
fields.add(constantField);
getters.add(_createGetter(constantField));
constantName.staticElement = constantField;
}
//
+ // Build the value of the 'values' field.
+ //
+ valuesField.evaluationResult = new EvaluationResultImpl.con1(new DartObjectImpl(valuesField.type, new ListState(constantValues)));
+ //
// Finish building the enum.
//
enumElement.fields = fields;
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/all_the_rest_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698