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

Side by Side 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: rebase wrt CL 10832351. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 5
6 /** 6 /**
7 * If true, print a warning for each method that was resolved, but not 7 * If true, print a warning for each method that was resolved, but not
8 * compiled. 8 * compiled.
9 */ 9 */
10 final bool REPORT_EXCESS_RESOLUTION = false; 10 final bool REPORT_EXCESS_RESOLUTION = false;
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 // TODO(ahe): Add structured diagnostics to the compiler API and 758 // TODO(ahe): Add structured diagnostics to the compiler API and
759 // use it to separate this from the --verbose option. 759 // use it to separate this from the --verbose option.
760 if (phase == PHASE_COMPILING) { 760 if (phase == PHASE_COMPILING) {
761 log('Compiled ${codegenWorld.generatedCode.length} methods.'); 761 log('Compiled ${codegenWorld.generatedCode.length} methods.');
762 } else { 762 } else {
763 log('Recompiled ${world.recompilationCandidates.processed} methods.'); 763 log('Recompiled ${world.recompilationCandidates.processed} methods.');
764 } 764 }
765 progress.reset(); 765 progress.reset();
766 } 766 }
767 if (work.element.kind.category == ElementCategory.VARIABLE) { 767 if (work.element.kind.category == ElementCategory.VARIABLE) {
768 constantHandler.compileWorkItem(work); 768 Constant initialValue = constantHandler.compileWorkItem(work);
769 } else { 769 if (initialValue != null) return;
kasperl 2012/08/17 09:30:04 !==
floitsch 2012/09/04 17:32:21 Done.
770 backend.codegen(work); 770 // If the constant-handler was not able to produce a result we have to
771 // go through the builder (below) to generate the lazy initializer for
772 // the static variable.
771 } 773 }
774 backend.codegen(work);
772 } 775 }
773 776
774 void registerInstantiatedClass(ClassElement cls) { 777 void registerInstantiatedClass(ClassElement cls) {
775 enqueuer.resolution.registerInstantiatedClass(cls); 778 enqueuer.resolution.registerInstantiatedClass(cls);
776 enqueuer.codegen.registerInstantiatedClass(cls); 779 enqueuer.codegen.registerInstantiatedClass(cls);
777 } 780 }
778 781
779 Type resolveTypeAnnotation(Element element, TypeAnnotation annotation) { 782 Type resolveTypeAnnotation(Element element, TypeAnnotation annotation) {
780 return resolver.resolveTypeAnnotation(element, annotation); 783 return resolver.resolveTypeAnnotation(element, annotation);
781 } 784 }
(...skipping 13 matching lines...) Expand all
795 return withCurrentElement(element, 798 return withCurrentElement(element,
796 () => resolver.resolveTypedef(element)); 799 () => resolver.resolveTypedef(element));
797 } 800 }
798 801
799 FunctionType computeFunctionType(Element element, 802 FunctionType computeFunctionType(Element element,
800 FunctionSignature signature) { 803 FunctionSignature signature) {
801 return withCurrentElement(element, 804 return withCurrentElement(element,
802 () => resolver.computeFunctionType(element, signature)); 805 () => resolver.computeFunctionType(element, signature));
803 } 806 }
804 807
808 bool isLazilyInitialized(VariableElement element) {
809 Constant initialValue = compileVariable(element);
810 return initialValue === null;
811 }
812
813 /** Compiles compile-time constants. Must not return `null`. */
814 Constant compileConstant(VariableElement element) {
815 return withCurrentElement(element, () {
816 return constantHandler.compileConstant(element);
817 });
818 }
819
805 Constant compileVariable(VariableElement element) { 820 Constant compileVariable(VariableElement element) {
806 return withCurrentElement(element, () { 821 return withCurrentElement(element, () {
807 return constantHandler.compileVariable(element); 822 return constantHandler.compileVariable(element);
808 }); 823 });
809 } 824 }
810 825
811 reportWarning(Node node, var message) { 826 reportWarning(Node node, var message) {
812 if (message is TypeWarning) { 827 if (message is TypeWarning) {
813 // TODO(ahe): Don't supress these warning when the type checker 828 // TODO(ahe): Don't supress these warning when the type checker
814 // is more complete. 829 // is more complete.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 final endOffset = end.charOffset + end.slowCharCount; 970 final endOffset = end.charOffset + end.slowCharCount;
956 971
957 // [begin] and [end] might be the same for the same empty token. This 972 // [begin] and [end] might be the same for the same empty token. This
958 // happens for instance when scanning '$$'. 973 // happens for instance when scanning '$$'.
959 assert(endOffset >= beginOffset); 974 assert(endOffset >= beginOffset);
960 return f(beginOffset, endOffset); 975 return f(beginOffset, endOffset);
961 } 976 }
962 977
963 String toString() => 'SourceSpan($uri, $begin, $end)'; 978 String toString() => 'SourceSpan($uri, $begin, $end)';
964 } 979 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698