| 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 b203ec131a418f4730880d49caad317eeb36af95..7774b75f9323b35ff00089d3126f1d9864821d50 100644
|
| --- a/pkg/compiler/lib/src/compile_time_constants.dart
|
| +++ b/pkg/compiler/lib/src/compile_time_constants.dart
|
| @@ -77,6 +77,10 @@ abstract class ConstantCompiler extends ConstantEnvironment {
|
| ConstantExpression compileMetadata(MetadataAnnotation metadata,
|
| Node node,
|
| TreeElements elements);
|
| +
|
| + /// Evaluates [constant] and caches the result.
|
| + // TODO(johnniwinther): Remove when all constants are evaluated.
|
| + void evaluate(ConstantExpression constant);
|
| }
|
|
|
| /// A [BackendConstantEnvironment] provides access to constants needed for
|
| @@ -157,6 +161,15 @@ abstract class ConstantCompilerBase implements ConstantCompiler {
|
| return compileVariable(element, isConst: true);
|
| }
|
|
|
| + @override
|
| + void evaluate(ConstantExpression constant) {
|
| + constantValueMap.putIfAbsent(constant, () {
|
| + return constant.evaluate(
|
| + new _CompilerEnvironment(compiler),
|
| + constantSystem);
|
| + });
|
| + }
|
| +
|
| ConstantExpression compileVariable(VariableElement element,
|
| {bool isConst: false}) {
|
|
|
| @@ -1342,3 +1355,14 @@ TreeElements _analyzeElementEagerly(Compiler compiler, AstElement element) {
|
| compiler.enqueuer.resolution.applyImpact(element.declaration, worldImpact);
|
| return element.resolvedAst.elements;
|
| }
|
| +
|
| +class _CompilerEnvironment implements Environment {
|
| + final Compiler compiler;
|
| +
|
| + _CompilerEnvironment(this.compiler);
|
| +
|
| + @override
|
| + String readFromEnvironment(String name) {
|
| + return compiler.fromEnvironment(name);
|
| + }
|
| +}
|
|
|