| 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 /** |
| 761 * Compiles compile-time constants. Never returns [:null:]. |
| 762 * If the initial value is not a compile-time constants reports an error. |
| 763 */ |
| 764 Constant compileConstant(VariableElement element) { |
| 765 return withCurrentElement(element, () { |
| 766 return constantHandler.compileConstant(element); |
| 767 }); |
| 768 } |
| 769 |
| 759 Constant compileVariable(VariableElement element) { | 770 Constant compileVariable(VariableElement element) { |
| 760 return withCurrentElement(element, () { | 771 return withCurrentElement(element, () { |
| 761 return constantHandler.compileVariable(element); | 772 return constantHandler.compileVariable(element); |
| 762 }); | 773 }); |
| 763 } | 774 } |
| 764 | 775 |
| 765 reportWarning(Node node, var message) { | 776 reportWarning(Node node, var message) { |
| 766 if (message is TypeWarning) { | 777 if (message is TypeWarning) { |
| 767 // TODO(ahe): Don't supress these warning when the type checker | 778 // TODO(ahe): Don't supress these warning when the type checker |
| 768 // is more complete. | 779 // is more complete. |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 final endOffset = end.charOffset + end.slowCharCount; | 928 final endOffset = end.charOffset + end.slowCharCount; |
| 918 | 929 |
| 919 // [begin] and [end] might be the same for the same empty token. This | 930 // [begin] and [end] might be the same for the same empty token. This |
| 920 // happens for instance when scanning '$$'. | 931 // happens for instance when scanning '$$'. |
| 921 assert(endOffset >= beginOffset); | 932 assert(endOffset >= beginOffset); |
| 922 return f(beginOffset, endOffset); | 933 return f(beginOffset, endOffset); |
| 923 } | 934 } |
| 924 | 935 |
| 925 String toString() => 'SourceSpan($uri, $begin, $end)'; | 936 String toString() => 'SourceSpan($uri, $begin, $end)'; |
| 926 } | 937 } |
| OLD | NEW |