Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 const bool REPORT_EXCESS_RESOLUTION = false; | 10 const bool REPORT_EXCESS_RESOLUTION = false; |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 711 if (progress.elapsedInMs() > 500) { | 711 if (progress.elapsedInMs() > 500) { |
| 712 // TODO(ahe): Add structured diagnostics to the compiler API and | 712 // TODO(ahe): Add structured diagnostics to the compiler API and |
| 713 // use it to separate this from the --verbose option. | 713 // use it to separate this from the --verbose option. |
| 714 if (phase == PHASE_COMPILING) { | 714 if (phase == PHASE_COMPILING) { |
| 715 log('Compiled ${codegenWorld.generatedCode.length} methods.'); | 715 log('Compiled ${codegenWorld.generatedCode.length} methods.'); |
| 716 } else { | 716 } else { |
| 717 log('Recompiled ${world.recompilationCandidates.processed} methods.'); | 717 log('Recompiled ${world.recompilationCandidates.processed} methods.'); |
| 718 } | 718 } |
| 719 progress.reset(); | 719 progress.reset(); |
| 720 } | 720 } |
| 721 if (work.element.kind.category == ElementCategory.VARIABLE) { | 721 backend.codegen(work); |
| 722 constantHandler.compileWorkItem(work); | |
| 723 } else { | |
| 724 backend.codegen(work); | |
| 725 } | |
| 726 } | 722 } |
| 727 | 723 |
| 728 void registerInstantiatedClass(ClassElement cls) { | 724 void registerInstantiatedClass(ClassElement cls) { |
| 729 enqueuer.resolution.registerInstantiatedClass(cls); | 725 enqueuer.resolution.registerInstantiatedClass(cls); |
| 730 enqueuer.codegen.registerInstantiatedClass(cls); | 726 enqueuer.codegen.registerInstantiatedClass(cls); |
| 731 } | 727 } |
| 732 | 728 |
| 733 DartType resolveTypeAnnotation(Element element, TypeAnnotation annotation) { | 729 DartType resolveTypeAnnotation(Element element, TypeAnnotation annotation) { |
| 734 return resolver.resolveTypeAnnotation(element, annotation); | 730 return resolver.resolveTypeAnnotation(element, annotation); |
| 735 } | 731 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 749 withCurrentElement(element, | 745 withCurrentElement(element, |
| 750 () => resolver.resolveTypedef(element)); | 746 () => resolver.resolveTypedef(element)); |
| 751 } | 747 } |
| 752 | 748 |
| 753 FunctionType computeFunctionType(Element element, | 749 FunctionType computeFunctionType(Element element, |
| 754 FunctionSignature signature) { | 750 FunctionSignature signature) { |
| 755 return withCurrentElement(element, | 751 return withCurrentElement(element, |
| 756 () => resolver.computeFunctionType(element, signature)); | 752 () => resolver.computeFunctionType(element, signature)); |
| 757 } | 753 } |
| 758 | 754 |
| 755 bool isLazilyInitialized(VariableElement element) { | |
| 756 Constant initialValue = compileVariable(element); | |
| 757 return initialValue === null; | |
| 758 } | |
| 759 | |
| 760 /** 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.
| |
| 761 Constant compileConstant(VariableElement element) { | |
| 762 return withCurrentElement(element, () { | |
| 763 return constantHandler.compileConstant(element); | |
| 764 }); | |
| 765 } | |
| 766 | |
| 759 Constant compileVariable(VariableElement element) { | 767 Constant compileVariable(VariableElement element) { |
| 760 return withCurrentElement(element, () { | 768 return withCurrentElement(element, () { |
| 761 return constantHandler.compileVariable(element); | 769 return constantHandler.compileVariable(element); |
| 762 }); | 770 }); |
| 763 } | 771 } |
| 764 | 772 |
| 765 reportWarning(Node node, var message) { | 773 reportWarning(Node node, var message) { |
| 766 if (message is TypeWarning) { | 774 if (message is TypeWarning) { |
| 767 // TODO(ahe): Don't supress these warning when the type checker | 775 // TODO(ahe): Don't supress these warning when the type checker |
| 768 // is more complete. | 776 // is more complete. |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 917 final endOffset = end.charOffset + end.slowCharCount; | 925 final endOffset = end.charOffset + end.slowCharCount; |
| 918 | 926 |
| 919 // [begin] and [end] might be the same for the same empty token. This | 927 // [begin] and [end] might be the same for the same empty token. This |
| 920 // happens for instance when scanning '$$'. | 928 // happens for instance when scanning '$$'. |
| 921 assert(endOffset >= beginOffset); | 929 assert(endOffset >= beginOffset); |
| 922 return f(beginOffset, endOffset); | 930 return f(beginOffset, endOffset); |
| 923 } | 931 } |
| 924 | 932 |
| 925 String toString() => 'SourceSpan($uri, $begin, $end)'; | 933 String toString() => 'SourceSpan($uri, $begin, $end)'; |
| 926 } | 934 } |
| OLD | NEW |