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

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: Address comments and move some code from compiler to backend. Created 8 years, 3 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 1b68df8719f13412a70e87a49c951672b67cbc8f..f732d44fb7f99b64ad6ff936be9027e11f485797 100644
--- a/lib/compiler/implementation/compiler.dart
+++ b/lib/compiler/implementation/compiler.dart
@@ -718,11 +718,7 @@ class Compiler implements DiagnosticListener {
}
progress.reset();
}
- if (work.element.kind.category == ElementCategory.VARIABLE) {
- constantHandler.compileWorkItem(work);
- } else {
- backend.codegen(work);
- }
+ backend.codegen(work);
}
void registerInstantiatedClass(ClassElement cls) {
@@ -756,6 +752,18 @@ class Compiler implements DiagnosticListener {
() => resolver.computeFunctionType(element, signature));
}
+ bool isLazilyInitialized(VariableElement element) {
+ Constant initialValue = compileVariable(element);
+ return initialValue === null;
+ }
+
+ /** Compiles compile-time constants. Must not return `null`. */
ahe 2012/09/05 09:34:35 [: null :]
ahe 2012/09/05 09:34:35 What happens if element isn't a constant?
floitsch 2012/09/05 10:43:16 Done.
floitsch 2012/09/05 10:43:16 Then an error is reported. Updated comment.
+ Constant compileConstant(VariableElement element) {
+ return withCurrentElement(element, () {
+ return constantHandler.compileConstant(element);
+ });
+ }
+
Constant compileVariable(VariableElement element) {
return withCurrentElement(element, () {
return constantHandler.compileVariable(element);
« no previous file with comments | « lib/compiler/implementation/compile_time_constants.dart ('k') | lib/compiler/implementation/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698