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

Unified Diff: frog/leg/compile_time_constants.dart

Issue 9703074: Call the compile-time constant handler inside bodies. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. Created 8 years, 9 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 | frog/leg/ssa/builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/compile_time_constants.dart
diff --git a/frog/leg/compile_time_constants.dart b/frog/leg/compile_time_constants.dart
index 8b5c6b22e2fc0d6a5d9f4ba02fc043ae16727332..1ed9a78e3204b81e3966c76c961675b896488bf6 100644
--- a/frog/leg/compile_time_constants.dart
+++ b/frog/leg/compile_time_constants.dart
@@ -495,7 +495,8 @@ class ConstantHandler extends CompilerTask {
assert(pendingVariables.isEmpty());
}
- compileVariable(VariableElement element) {
+ Constant compileVariable(VariableElement element) {
+ // TODO(floitsch): wrap this method in 'measure'.
if (initialVariableValues.containsKey(element)) {
Constant result = initialVariableValues[element];
return result;
@@ -511,32 +512,37 @@ class ConstantHandler extends CompilerTask {
TreeElements definitions) {
return measure(() {
Node node = element.parseNode(compiler);
- assert(node !== null);
+ if (pendingVariables.contains(element)) {
+ MessageKind kind = MessageKind.CYCLIC_COMPILE_TIME_CONSTANTS;
+ compiler.reportError(node,
+ new CompileTimeConstantError(kind, const []));
+ }
+ pendingVariables.add(element);
+
SendSet assignment = node.asSendSet();
- var value;
+ Constant value;
if (assignment === null) {
// No initial value.
value = new NullConstant();
} else {
- if (pendingVariables.contains(element)) {
- MessageKind kind = MessageKind.CYCLIC_COMPILE_TIME_CONSTANTS;
- compiler.reportError(node,
- new CompileTimeConstantError(kind, const []));
- }
- pendingVariables.add(element);
-
Node right = assignment.arguments.head;
- CompileTimeConstantEvaluator evaluator =
- new CompileTimeConstantEvaluator(this, definitions, compiler);
- value = evaluator.evaluate(right);
-
- pendingVariables.remove(element);
+ value = compileNodeWithDefinitions(right, definitions);
}
initialVariableValues[element] = value;
+ pendingVariables.remove(element);
return value;
});
}
+ Constant compileNodeWithDefinitions(Node node, TreeElements definitions) {
+ return measure(() {
+ assert(node !== null);
+ CompileTimeConstantEvaluator evaluator =
+ new CompileTimeConstantEvaluator(this, definitions, compiler);
+ return evaluator.evaluate(node);
+ });
+ }
+
/**
* Returns a [List] of static non final fields that need to be initialized.
* The list must be evaluated in order since the fields might depend on each
« no previous file with comments | « no previous file | frog/leg/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698