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

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

Issue 2060183002: Serialize metadata (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comment. Created 4 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 | « pkg/compiler/lib/src/common/backend_api.dart ('k') | 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 bbabcf9f9aaf521a67cad7c5d96b3117f4471026..71962e88957bcc163fdc0d7df455753022b6ab8c 100644
--- a/pkg/compiler/lib/src/compile_time_constants.dart
+++ b/pkg/compiler/lib/src/compile_time_constants.dart
@@ -165,7 +165,9 @@ abstract class ConstantCompilerBase implements ConstantCompiler {
@override
@deprecated
ConstantValue getConstantValueForVariable(VariableElement element) {
- return getConstantValue(initialVariableValues[element.declaration]);
+ ConstantExpression constant = initialVariableValues[element.declaration];
+ // TODO(johnniwinther): Support eager evaluation of the constant.
+ return constant != null ? getConstantValue(constant) : null;
}
ConstantExpression compileConstant(VariableElement element) {
@@ -320,8 +322,27 @@ abstract class ConstantCompilerBase implements ConstantCompiler {
return constantValueMap.containsKey(expression);
}
+ @override
ConstantValue getConstantValue(ConstantExpression expression) {
- return constantValueMap[expression];
+ assert(invariant(CURRENT_ELEMENT_SPANNABLE, expression != null,
+ message: "ConstantExpression is null in getConstantValue."));
+ // TODO(johnniwinther): ensure expressions have been evaluated at this
+ // point. This can't be enabled today due to dartbug.com/26406.
+ if (compiler.serialization.supportsDeserialization) {
+ evaluate(expression);
+ }
+ ConstantValue value = constantValueMap[expression];
+ if (value == null &&
+ expression != null &&
+ expression.kind == ConstantExpressionKind.ERRONEOUS) {
+ // TODO(johnniwinther): When the Dart constant system sees a constant
+ // expression as erroneous but the JavaScript constant system finds it ok
+ // we have store a constant value for the erroneous constant expression.
+ // Ensure the computed constant expressions are always the same; that only
+ // the constant values may be different.
+ value = new NullConstantValue();
+ }
+ return value;
}
ConstantExpression compileNode(Node node, TreeElements elements,
@@ -359,7 +380,7 @@ class DartConstantCompiler extends ConstantCompilerBase {
Node node, TreeElements definitions,
{bool isConst: true}) {
ConstantExpression constant = definitions.getConstant(node);
- if (constant != null && getConstantValue(constant) != null) {
+ if (constant != null && hasConstantValue(constant)) {
return constant;
}
constant =
« no previous file with comments | « pkg/compiler/lib/src/common/backend_api.dart ('k') | pkg/compiler/lib/src/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698