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

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

Issue 1278353003: Handle more unqualified SendSets (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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_nodes.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 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);
+ }
+}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698