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

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

Issue 1170673002: Begin to compute constant expressions in resolution. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix BinaryConstantExpression.getKnownType Created 5 years, 6 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/compiler.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 a1c37688a01b33dd4361e689ec7eab00fda1fd89..848ea68f32d6db5a23ea0694460aa9e615b1543a 100644
--- a/pkg/compiler/lib/src/compile_time_constants.dart
+++ b/pkg/compiler/lib/src/compile_time_constants.dart
@@ -248,6 +248,10 @@ abstract class ConstantCompilerBase implements ConstantCompiler {
return expression;
}
+ void cacheConstantValue(ConstantExpression expression, ConstantValue value) {
+ constantValueMap[expression] = value;
+ }
+
ConstantExpression compileNodeWithDefinitions(Node node,
TreeElements definitions,
{bool isConst: true}) {
@@ -256,7 +260,7 @@ abstract class ConstantCompilerBase implements ConstantCompiler {
this, definitions, compiler, isConst: isConst);
AstConstant constant = evaluator.evaluate(node);
if (constant != null) {
- constantValueMap[constant.expression] = constant.value;
+ cacheConstantValue(constant.expression, constant.value);
return constant.expression;
}
return null;
@@ -302,7 +306,7 @@ class DartConstantCompiler extends ConstantCompilerBase {
TreeElements definitions,
{bool isConst: true}) {
ConstantExpression constant = definitions.getConstant(node);
- if (constant != null) {
+ if (constant != null && getConstantValue(constant) != null) {
return constant;
}
constant =
« no previous file with comments | « no previous file | pkg/compiler/lib/src/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698