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

Unified Diff: pkg/analyzer/lib/src/dart/constant/evaluation.dart

Issue 2772943002: store constructor and arguments for constant values (Closed)
Patch Set: clean up pubspec Created 3 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/lib/src/dart/constant/value.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/constant/evaluation.dart
diff --git a/pkg/analyzer/lib/src/dart/constant/evaluation.dart b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
index 2e0d063e80d1220a2c72c794010625cd64a073d0..6243f47f13c8b058261503dc35b691c6d67beebf 100644
--- a/pkg/analyzer/lib/src/dart/constant/evaluation.dart
+++ b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
@@ -422,7 +422,8 @@ class ConstantEvaluationEngine {
List<Expression> arguments,
ConstructorElement constructor,
ConstantVisitor constantVisitor,
- ErrorReporter errorReporter) {
+ ErrorReporter errorReporter,
+ {ConstructorInvocation invocation}) {
if (!getConstructorImpl(constructor).isCycleFree) {
// It's not safe to evaluate this constructor, so bail out.
// TODO(paulberry): ensure that a reasonable error message is produced
@@ -434,6 +435,7 @@ class ConstantEvaluationEngine {
int argumentCount = arguments.length;
List<DartObjectImpl> argumentValues =
new List<DartObjectImpl>(argumentCount);
+ List<DartObjectImpl> positionalArguments = <DartObjectImpl>[];
List<Expression> argumentNodes = new List<Expression>(argumentCount);
HashMap<String, DartObjectImpl> namedArgumentValues =
new HashMap<String, DartObjectImpl>();
@@ -448,10 +450,16 @@ class ConstantEvaluationEngine {
namedArgumentNodes[name] = argument;
argumentValues[i] = typeProvider.nullObject;
} else {
- argumentValues[i] = constantVisitor._valueOf(argument);
+ var argumentValue = constantVisitor._valueOf(argument);
+ argumentValues[i] = argumentValue;
+ positionalArguments.add(argumentValue);
argumentNodes[i] = argument;
}
}
+ if (invocation == null) {
+ invocation = new ConstructorInvocation(
+ constructor, positionalArguments, namedArgumentValues);
+ }
constructor = followConstantRedirectionChain(constructor);
InterfaceType definingClass = constructor.returnType as InterfaceType;
if (constructor.isFactory) {
@@ -709,7 +717,8 @@ class ConstantEvaluationEngine {
initializer.argumentList.arguments,
constructor,
initializerVisitor,
- errorReporter);
+ errorReporter,
+ invocation: invocation);
}
}
}
@@ -727,7 +736,8 @@ class ConstantEvaluationEngine {
superArguments, initializerVisitor, errorReporter);
}
}
- return new DartObjectImpl(definingClass, new GenericState(fieldMap));
+ return new DartObjectImpl(
+ definingClass, new GenericState(fieldMap, invocation: invocation));
}
void evaluateSuperConstructorCall(
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/constant/value.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698