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 js_backend; | 5 part of js_backend; |
6 | 6 |
7 typedef void Recompile(Element element); | 7 typedef void Recompile(Element element); |
8 | 8 |
9 class ReturnInfo { | 9 class ReturnInfo { |
10 HType returnType; | 10 HType returnType; |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 final List<Element> invalidateAfterCodegen; | 665 final List<Element> invalidateAfterCodegen; |
666 ArgumentTypesRegistry argumentTypes; | 666 ArgumentTypesRegistry argumentTypes; |
667 FieldTypesRegistry fieldTypes; | 667 FieldTypesRegistry fieldTypes; |
668 | 668 |
669 final Interceptors interceptors; | 669 final Interceptors interceptors; |
670 | 670 |
671 List<CompilerTask> get tasks { | 671 List<CompilerTask> get tasks { |
672 return <CompilerTask>[builder, optimizer, generator, emitter]; | 672 return <CompilerTask>[builder, optimizer, generator, emitter]; |
673 } | 673 } |
674 | 674 |
675 JavaScriptBackend(Compiler compiler, | 675 JavaScriptBackend(Compiler compiler, bool generateSourceMap, bool disableEval) |
676 bool generateSourceMap, | 676 : namer = determineNamer(compiler), |
677 bool disableEval) | |
678 : namer = new Namer(compiler), | |
679 returnInfo = new Map<Element, ReturnInfo>(), | 677 returnInfo = new Map<Element, ReturnInfo>(), |
680 invalidateAfterCodegen = new List<Element>(), | 678 invalidateAfterCodegen = new List<Element>(), |
681 interceptors = new Interceptors(compiler), | 679 interceptors = new Interceptors(compiler), |
682 super(compiler, JAVA_SCRIPT_CONSTANT_SYSTEM) { | 680 super(compiler, JAVA_SCRIPT_CONSTANT_SYSTEM) { |
683 emitter = disableEval | 681 emitter = disableEval |
684 ? new CodeEmitterNoEvalTask(compiler, namer, generateSourceMap) | 682 ? new CodeEmitterNoEvalTask(compiler, namer, generateSourceMap) |
685 : new CodeEmitterTask(compiler, namer, generateSourceMap); | 683 : new CodeEmitterTask(compiler, namer, generateSourceMap); |
686 builder = new SsaBuilderTask(this); | 684 builder = new SsaBuilderTask(this); |
687 optimizer = new SsaOptimizerTask(this); | 685 optimizer = new SsaOptimizerTask(this); |
688 generator = new SsaCodeGeneratorTask(this); | 686 generator = new SsaCodeGeneratorTask(this); |
689 argumentTypes = new ArgumentTypesRegistry(this); | 687 argumentTypes = new ArgumentTypesRegistry(this); |
690 fieldTypes = new FieldTypesRegistry(this); | 688 fieldTypes = new FieldTypesRegistry(this); |
691 } | 689 } |
692 | 690 |
| 691 static Namer determineNamer(Compiler compiler) { |
| 692 return compiler.enableMinification ? |
| 693 new MinifyNamer(compiler) : |
| 694 new Namer(compiler); |
| 695 } |
| 696 |
693 Element get cyclicThrowHelper { | 697 Element get cyclicThrowHelper { |
694 return compiler.findHelper(const SourceString("throwCyclicInit")); | 698 return compiler.findHelper(const SourceString("throwCyclicInit")); |
695 } | 699 } |
696 | 700 |
697 JavaScriptItemCompilationContext createItemCompilationContext() { | 701 JavaScriptItemCompilationContext createItemCompilationContext() { |
698 return new JavaScriptItemCompilationContext(); | 702 return new JavaScriptItemCompilationContext(); |
699 } | 703 } |
700 | 704 |
701 Element getInterceptor(Selector selector) { | 705 Element getInterceptor(Selector selector) { |
702 return interceptors.getStaticInterceptor(selector); | 706 return interceptors.getStaticInterceptor(selector); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 print("Inferred return types:"); | 956 print("Inferred return types:"); |
953 print("----------------------"); | 957 print("----------------------"); |
954 dumpReturnTypes(); | 958 dumpReturnTypes(); |
955 print(""); | 959 print(""); |
956 print("Inferred field types:"); | 960 print("Inferred field types:"); |
957 print("------------------------"); | 961 print("------------------------"); |
958 fieldTypes.dump(); | 962 fieldTypes.dump(); |
959 print(""); | 963 print(""); |
960 } | 964 } |
961 } | 965 } |
OLD | NEW |