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

Unified Diff: lib/compiler/implementation/compiler.dart

Issue 10855174: Lazy implementation of final variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix tests. Created 8 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
Index: lib/compiler/implementation/compiler.dart
diff --git a/lib/compiler/implementation/compiler.dart b/lib/compiler/implementation/compiler.dart
index 69234fe7f8c32557ec96fb69ee1ee7501d6430ed..21d14664e60e6fffe47cbeb2818e17f975f95892 100644
--- a/lib/compiler/implementation/compiler.dart
+++ b/lib/compiler/implementation/compiler.dart
@@ -749,13 +749,13 @@ class Compiler implements DiagnosticListener {
progress.reset();
}
if (work.element.kind.category == ElementCategory.VARIABLE) {
- constantHandler.compileWorkItem(work);
- return null;
- } else {
- CodeBuffer codeBuffer = backend.codegen(work);
- codegenWorld.addGeneratedCode(work, codeBuffer);
- return codeBuffer.toString();
+ Constant initialValue = constantHandler.compileWorkItem(work);
+ if (initialValue != null) return null;
+ // Otherwise we need to go through the builder.
kasperl 2012/08/16 14:41:37 Maybe change the comment to explain why we have to
floitsch 2012/08/16 22:52:33 Done.
}
+ CodeBuffer codeBuffer = backend.codegen(work);
+ codegenWorld.addGeneratedCode(work, codeBuffer);
+ return codeBuffer.toString();
}
void registerInstantiatedClass(ClassElement cls) {
@@ -793,6 +793,18 @@ class Compiler implements DiagnosticListener {
() => resolver.computeFunctionType(element, signature));
}
+ bool isLazilyInitialized(VariableElement element) {
+ Constant initialValue = compileVariable(element);
+ return initialValue == null;
kasperl 2012/08/16 14:41:37 ===?
floitsch 2012/08/16 22:52:33 Done.
+ }
+
+ /** Compiles compile-time constants. Must not return `null`. */
+ Constant compileConstant(VariableElement element) {
+ return withCurrentElement(element, () {
+ return constantHandler.compileConstant(element);
+ });
+ }
+
Constant compileVariable(VariableElement element) {
return withCurrentElement(element, () {
return constantHandler.compileVariable(element);

Powered by Google App Engine
This is Rietveld 408576698