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

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: 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 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 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 // TODO(ahe): Add structured diagnostics to the compiler API and 742 // TODO(ahe): Add structured diagnostics to the compiler API and
743 // use it to separate this from the --verbose option. 743 // use it to separate this from the --verbose option.
744 if (phase == PHASE_COMPILING) { 744 if (phase == PHASE_COMPILING) {
745 log('Compiled ${codegenWorld.generatedCode.length} methods.'); 745 log('Compiled ${codegenWorld.generatedCode.length} methods.');
746 } else { 746 } else {
747 log('Recompiled ${world.recompilationCandidates.processed} methods.'); 747 log('Recompiled ${world.recompilationCandidates.processed} methods.');
748 } 748 }
749 progress.reset(); 749 progress.reset();
750 } 750 }
751 if (work.element.kind.category == ElementCategory.VARIABLE) { 751 if (work.element.kind.category == ElementCategory.VARIABLE) {
752 constantHandler.compileWorkItem(work); 752 Constant initialValue = constantHandler.compileWorkItem(work);
753 return null; 753 if (initialValue != null) return null;
754 } else { 754 // 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.
755 CodeBuffer codeBuffer = backend.codegen(work);
756 codegenWorld.addGeneratedCode(work, codeBuffer);
757 return codeBuffer.toString();
758 } 755 }
756 CodeBuffer codeBuffer = backend.codegen(work);
757 codegenWorld.addGeneratedCode(work, codeBuffer);
758 return codeBuffer.toString();
759 } 759 }
760 760
761 void registerInstantiatedClass(ClassElement cls) { 761 void registerInstantiatedClass(ClassElement cls) {
762 enqueuer.resolution.registerInstantiatedClass(cls); 762 enqueuer.resolution.registerInstantiatedClass(cls);
763 enqueuer.codegen.registerInstantiatedClass(cls); 763 enqueuer.codegen.registerInstantiatedClass(cls);
764 } 764 }
765 765
766 void resolveClass(ClassElement element) { 766 void resolveClass(ClassElement element) {
767 withCurrentElement(element, () => resolver.resolveClass(element)); 767 withCurrentElement(element, () => resolver.resolveClass(element));
768 } 768 }
(...skipping 17 matching lines...) Expand all
786 return withCurrentElement(element, 786 return withCurrentElement(element,
787 () => resolver.resolveTypedef(element)); 787 () => resolver.resolveTypedef(element));
788 } 788 }
789 789
790 FunctionType computeFunctionType(Element element, 790 FunctionType computeFunctionType(Element element,
791 FunctionSignature signature) { 791 FunctionSignature signature) {
792 return withCurrentElement(element, 792 return withCurrentElement(element,
793 () => resolver.computeFunctionType(element, signature)); 793 () => resolver.computeFunctionType(element, signature));
794 } 794 }
795 795
796 bool isLazilyInitialized(VariableElement element) {
797 Constant initialValue = compileVariable(element);
798 return initialValue == null;
kasperl 2012/08/16 14:41:37 ===?
floitsch 2012/08/16 22:52:33 Done.
799 }
800
801 /** Compiles compile-time constants. Must not return `null`. */
802 Constant compileConstant(VariableElement element) {
803 return withCurrentElement(element, () {
804 return constantHandler.compileConstant(element);
805 });
806 }
807
796 Constant compileVariable(VariableElement element) { 808 Constant compileVariable(VariableElement element) {
797 return withCurrentElement(element, () { 809 return withCurrentElement(element, () {
798 return constantHandler.compileVariable(element); 810 return constantHandler.compileVariable(element);
799 }); 811 });
800 } 812 }
801 813
802 reportWarning(Node node, var message) { 814 reportWarning(Node node, var message) {
803 if (message is TypeWarning) { 815 if (message is TypeWarning) {
804 // TODO(ahe): Don't supress these warning when the type checker 816 // TODO(ahe): Don't supress these warning when the type checker
805 // is more complete. 817 // is more complete.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 final endOffset = end.charOffset + end.slowCharCount; 958 final endOffset = end.charOffset + end.slowCharCount;
947 959
948 // [begin] and [end] might be the same for the same empty token. This 960 // [begin] and [end] might be the same for the same empty token. This
949 // happens for instance when scanning '$$'. 961 // happens for instance when scanning '$$'.
950 assert(endOffset >= beginOffset); 962 assert(endOffset >= beginOffset);
951 return f(beginOffset, endOffset); 963 return f(beginOffset, endOffset);
952 } 964 }
953 965
954 String toString() => 'SourceSpan($uri, $begin, $end)'; 966 String toString() => 'SourceSpan($uri, $begin, $end)';
955 } 967 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698