| 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 part of dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * If true, print a warning for each method that was resolved, but not | 8 * If true, print a warning for each method that was resolved, but not |
| 9 * compiled. | 9 * compiled. |
| 10 */ | 10 */ |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 class DeferredTask { | 68 class DeferredTask { |
| 69 final Element element; | 69 final Element element; |
| 70 final DeferredAction action; | 70 final DeferredAction action; |
| 71 | 71 |
| 72 DeferredTask(this.element, this.action); | 72 DeferredTask(this.element, this.action); |
| 73 } | 73 } |
| 74 | 74 |
| 75 abstract class Backend { | 75 abstract class Backend { |
| 76 final Compiler compiler; | 76 final Compiler compiler; |
| 77 final ConstantSystem constantSystem; | |
| 78 | 77 |
| 79 Backend(this.compiler, | 78 Backend(this.compiler); |
| 80 [ConstantSystem constantSystem = DART_CONSTANT_SYSTEM]) | 79 |
| 81 : this.constantSystem = constantSystem; | 80 /// The [ConstantSystem] used to interpret compile-time constants for this |
| 81 /// backend. |
| 82 ConstantSystem get constantSystem; |
| 83 |
| 84 /// The constant environment for the backend interpretation of compile-time |
| 85 /// constants. |
| 86 BackendConstantEnvironment get constants; |
| 87 |
| 88 /// The compiler task responsible for the compilation of constants for both |
| 89 /// the frontend and the backend. |
| 90 ConstantCompilerTask get constantCompilerTask; |
| 82 | 91 |
| 83 // Given a [FunctionElement], return a buffer with the code generated for it | 92 // Given a [FunctionElement], return a buffer with the code generated for it |
| 84 // or null if no code was generated. | 93 // or null if no code was generated. |
| 85 CodeBuffer codeOf(Element element) => null; | 94 CodeBuffer codeOf(Element element) => null; |
| 86 | 95 |
| 87 void initializeHelperClasses() {} | 96 void initializeHelperClasses() {} |
| 88 | 97 |
| 89 void enqueueHelpers(ResolutionEnqueuer world, TreeElements elements); | 98 void enqueueHelpers(ResolutionEnqueuer world, TreeElements elements); |
| 90 void codegen(CodegenWorkItem work); | 99 void codegen(CodegenWorkItem work); |
| 91 | 100 |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 ParserTask parser; | 568 ParserTask parser; |
| 560 PatchParserTask patchParser; | 569 PatchParserTask patchParser; |
| 561 LibraryLoader libraryLoader; | 570 LibraryLoader libraryLoader; |
| 562 TreeValidatorTask validator; | 571 TreeValidatorTask validator; |
| 563 ResolverTask resolver; | 572 ResolverTask resolver; |
| 564 closureMapping.ClosureTask closureToClassMapper; | 573 closureMapping.ClosureTask closureToClassMapper; |
| 565 TypeCheckerTask checker; | 574 TypeCheckerTask checker; |
| 566 IrBuilderTask irBuilder; | 575 IrBuilderTask irBuilder; |
| 567 ti.TypesTask typesTask; | 576 ti.TypesTask typesTask; |
| 568 Backend backend; | 577 Backend backend; |
| 569 ConstantHandler constantHandler; | 578 |
| 579 /// The constant environment for the frontend interpretation of compile-time |
| 580 /// constants. |
| 581 ConstantEnvironment constants; |
| 582 |
| 570 EnqueueTask enqueuer; | 583 EnqueueTask enqueuer; |
| 571 DeferredLoadTask deferredLoadTask; | 584 DeferredLoadTask deferredLoadTask; |
| 572 MirrorUsageAnalyzerTask mirrorUsageAnalyzerTask; | 585 MirrorUsageAnalyzerTask mirrorUsageAnalyzerTask; |
| 573 DumpInfoTask dumpInfoTask; | 586 DumpInfoTask dumpInfoTask; |
| 574 String buildId; | 587 String buildId; |
| 575 | 588 |
| 576 static const String MAIN = 'main'; | 589 static const String MAIN = 'main'; |
| 577 static const String CALL_OPERATOR_NAME = 'call'; | 590 static const String CALL_OPERATOR_NAME = 'call'; |
| 578 static const String NO_SUCH_METHOD = 'noSuchMethod'; | 591 static const String NO_SUCH_METHOD = 'noSuchMethod'; |
| 579 static const int NO_SUCH_METHOD_ARG_COUNT = 1; | 592 static const int NO_SUCH_METHOD_ARG_COUNT = 1; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 | 685 |
| 673 // No-op in production mode. | 686 // No-op in production mode. |
| 674 validator = new TreeValidatorTask(this); | 687 validator = new TreeValidatorTask(this); |
| 675 | 688 |
| 676 tasks = [ | 689 tasks = [ |
| 677 libraryLoader = new LibraryLoaderTask(this), | 690 libraryLoader = new LibraryLoaderTask(this), |
| 678 scanner = new ScannerTask(this), | 691 scanner = new ScannerTask(this), |
| 679 dietParser = new DietParserTask(this), | 692 dietParser = new DietParserTask(this), |
| 680 parser = new ParserTask(this), | 693 parser = new ParserTask(this), |
| 681 patchParser = new PatchParserTask(this), | 694 patchParser = new PatchParserTask(this), |
| 682 resolver = new ResolverTask(this), | 695 resolver = new ResolverTask(this, backend.constantCompilerTask), |
| 683 closureToClassMapper = new closureMapping.ClosureTask(this, closureNamer), | 696 closureToClassMapper = new closureMapping.ClosureTask(this, closureNamer), |
| 684 checker = new TypeCheckerTask(this), | 697 checker = new TypeCheckerTask(this), |
| 685 irBuilder = new IrBuilderTask(this), | 698 irBuilder = new IrBuilderTask(this), |
| 686 typesTask = new ti.TypesTask(this), | 699 typesTask = new ti.TypesTask(this), |
| 687 constantHandler = new ConstantHandler(this, backend.constantSystem), | 700 constants = backend.constantCompilerTask, |
| 688 deferredLoadTask = new DeferredLoadTask(this), | 701 deferredLoadTask = new DeferredLoadTask(this), |
| 689 mirrorUsageAnalyzerTask = new MirrorUsageAnalyzerTask(this), | 702 mirrorUsageAnalyzerTask = new MirrorUsageAnalyzerTask(this), |
| 690 enqueuer = new EnqueueTask(this), | 703 enqueuer = new EnqueueTask(this), |
| 691 dumpInfoTask = new DumpInfoTask(this)]; | 704 dumpInfoTask = new DumpInfoTask(this)]; |
| 692 | 705 |
| 693 tasks.addAll(backend.tasks); | 706 tasks.addAll(backend.tasks); |
| 694 } | 707 } |
| 695 | 708 |
| 696 Universe get resolverWorld => enqueuer.resolution.universe; | 709 Universe get resolverWorld => enqueuer.resolution.universe; |
| 697 Universe get codegenWorld => enqueuer.codegen.universe; | 710 Universe get codegenWorld => enqueuer.codegen.universe; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 '$missingHelperClasses'); | 949 '$missingHelperClasses'); |
| 937 } | 950 } |
| 938 | 951 |
| 939 if (types == null) { | 952 if (types == null) { |
| 940 types = new Types(this, dynamicClass); | 953 types = new Types(this, dynamicClass); |
| 941 } | 954 } |
| 942 backend.initializeHelperClasses(); | 955 backend.initializeHelperClasses(); |
| 943 | 956 |
| 944 dynamicClass.ensureResolved(this); | 957 dynamicClass.ensureResolved(this); |
| 945 | 958 |
| 946 proxyConstant = constantHandler.compileVariable( | 959 proxyConstant = |
| 947 coreLibrary.find('proxy'), isConst: true); | 960 resolver.constantCompiler.compileConstant(coreLibrary.find('proxy')); |
| 948 } | 961 } |
| 949 | 962 |
| 950 Element _unnamedListConstructor; | 963 Element _unnamedListConstructor; |
| 951 Element get unnamedListConstructor { | 964 Element get unnamedListConstructor { |
| 952 if (_unnamedListConstructor != null) return _unnamedListConstructor; | 965 if (_unnamedListConstructor != null) return _unnamedListConstructor; |
| 953 Selector callConstructor = new Selector.callConstructor( | 966 Selector callConstructor = new Selector.callConstructor( |
| 954 "", listClass.getLibrary()); | 967 "", listClass.getLibrary()); |
| 955 return _unnamedListConstructor = | 968 return _unnamedListConstructor = |
| 956 listClass.lookupConstructor(callConstructor); | 969 listClass.lookupConstructor(callConstructor); |
| 957 } | 970 } |
| (...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1801 static NullSink outputProvider(String name, String extension) { | 1814 static NullSink outputProvider(String name, String extension) { |
| 1802 return new NullSink('$name.$extension'); | 1815 return new NullSink('$name.$extension'); |
| 1803 } | 1816 } |
| 1804 } | 1817 } |
| 1805 | 1818 |
| 1806 /// Information about suppressed warnings and hints for a given library. | 1819 /// Information about suppressed warnings and hints for a given library. |
| 1807 class SuppressionInfo { | 1820 class SuppressionInfo { |
| 1808 int warnings = 0; | 1821 int warnings = 0; |
| 1809 int hints = 0; | 1822 int hints = 0; |
| 1810 } | 1823 } |
| OLD | NEW |