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

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

Issue 1919143002: Store constant variable initializers in elements. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 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/cps_ir/cps_ir_builder_task.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 b9cbb559d3162f0369de53c13c960cf8dcf74ec5..d000f26192bf9548ac1c80d3bdd0545f5d08c4cc 100644
--- a/pkg/compiler/lib/src/compile_time_constants.dart
+++ b/pkg/compiler/lib/src/compile_time_constants.dart
@@ -16,7 +16,7 @@ import 'constants/values.dart';
import 'core_types.dart' show CoreTypes;
import 'dart_types.dart';
import 'elements/elements.dart';
-import 'elements/modelx.dart' show FunctionElementX;
+import 'elements/modelx.dart' show FieldElementX, FunctionElementX;
import 'resolution/tree_elements.dart' show TreeElements;
import 'resolution/operators.dart';
import 'tree/tree.dart';
@@ -34,10 +34,8 @@ abstract class ConstantEnvironment {
ConstantValue getConstantValue(ConstantExpression expression);
/// Returns the constant value for the initializer of [element].
+ @deprecated
ConstantValue getConstantValueForVariable(VariableElement element);
-
- /// Returns the constant for the initializer of [element].
- ConstantExpression getConstantForVariable(VariableElement element);
}
/// A class that can compile and provide constants for variables, nodes and
@@ -54,7 +52,7 @@ abstract class ConstantCompiler extends ConstantEnvironment {
/// Computes the compile-time constant for the variable initializer,
/// if possible.
- void compileVariable(VariableElement element);
+ ConstantExpression compileVariable(VariableElement element);
/// Compiles the constant for [node].
///
@@ -156,15 +154,11 @@ abstract class ConstantCompilerBase implements ConstantCompiler {
CoreTypes get coreTypes => compiler.coreTypes;
@override
+ @deprecated
ConstantValue getConstantValueForVariable(VariableElement element) {
return getConstantValue(initialVariableValues[element.declaration]);
}
- @override
- ConstantExpression getConstantForVariable(VariableElement element) {
- return initialVariableValues[element.declaration];
- }
-
ConstantExpression compileConstant(VariableElement element) {
return internalCompileVariable(element, true, true);
}
@@ -1277,12 +1271,13 @@ class ConstructorEvaluator extends CompileTimeConstantEvaluator {
Map<FieldElement, AstConstant> fieldConstants =
<FieldElement, AstConstant>{};
classElement.implementation.forEachInstanceField(
- (ClassElement enclosing, FieldElement field) {
+ (ClassElement enclosing, FieldElementX field) {
AstConstant fieldValue = fieldValues[field];
if (fieldValue == null) {
// Use the default value.
ConstantExpression fieldExpression =
handler.internalCompileVariable(field, true, false);
+ field.constant = fieldExpression;
fieldValue = new AstConstant.fromDefaultValue(
field, fieldExpression, handler.getConstantValue(fieldExpression));
// TODO(het): If the field value doesn't typecheck due to the type
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698