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

Unified Diff: pkg/compiler/lib/src/compile_time_constants.dart

Issue 1108913003: Use Map<FieldElement, ConstantValue> for fields in ConstructedConstantValue. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | « no previous file | pkg/compiler/lib/src/constants/values.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/compile_time_constants.dart
diff --git a/pkg/compiler/lib/src/compile_time_constants.dart b/pkg/compiler/lib/src/compile_time_constants.dart
index c5462dbff1a5d13d93a11d81fd01b8fe0ebd52ca..c16a09ceba8378ce060892a619fe6d0c31164acc 100644
--- a/pkg/compiler/lib/src/compile_time_constants.dart
+++ b/pkg/compiler/lib/src/compile_time_constants.dart
@@ -871,14 +871,16 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
ConstructorEvaluator evaluator = new ConstructorEvaluator(
constructedType, target, handler, compiler);
evaluator.evaluateConstructorFieldValues(normalizedArguments);
- List<AstConstant> fieldConstants =
+ Map<FieldElement, AstConstant> fieldConstants =
evaluator.buildFieldConstants(classElement);
-
+ Map<FieldElement, ConstantValue> fieldValues =
+ <FieldElement, ConstantValue>{};
+ fieldConstants.forEach((FieldElement field, AstConstant astConstant) {
+ fieldValues[field] = astConstant.value;
+ });
return new AstConstant(
context, node, new ConstructedConstantExpression(
- new ConstructedConstantValue(
- constructedType,
- fieldConstants.map((e) => e.value).toList()),
+ new ConstructedConstantValue(constructedType, fieldValues),
type,
constructor,
callStructure,
@@ -1098,8 +1100,10 @@ class ConstructorEvaluator extends CompileTimeConstantEvaluator {
/// Builds a normalized list of the constant values for each field in the
/// inheritance chain of [classElement].
- List<AstConstant> buildFieldConstants(ClassElement classElement) {
- List<AstConstant> fieldConstants = <AstConstant>[];
+ Map<FieldElement, AstConstant> buildFieldConstants(
+ ClassElement classElement) {
+ Map<FieldElement, AstConstant> fieldConstants =
+ <FieldElement, AstConstant>{};
classElement.implementation.forEachInstanceField(
(ClassElement enclosing, FieldElement field) {
AstConstant fieldValue = fieldValues[field];
@@ -1108,7 +1112,7 @@ class ConstructorEvaluator extends CompileTimeConstantEvaluator {
fieldValue = new AstConstant.fromDefaultValue(
field, handler.compileConstant(field));
}
- fieldConstants.add(fieldValue);
+ fieldConstants[field] = fieldValue;
},
includeSuperAndInjectedMembers: true);
return fieldConstants;
« no previous file with comments | « no previous file | pkg/compiler/lib/src/constants/values.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698