| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /// Generate code using the cps-based IR pipeline. | 5 /// Generate code using the cps-based IR pipeline. |
| 6 library code_generator_task; | 6 library code_generator_task; |
| 7 | 7 |
| 8 import 'glue.dart'; | 8 import 'glue.dart'; |
| 9 import 'codegen.dart'; | 9 import 'codegen.dart'; |
| 10 import 'unsugar.dart'; | 10 import 'unsugar.dart'; |
| 11 | 11 |
| 12 import '../js_backend.dart'; | 12 import '../js_backend.dart'; |
| 13 import '../../constants/constant_system.dart'; | 13 import '../../constants/constant_system.dart'; |
| 14 import '../../dart2jslib.dart'; | 14 import '../../dart2jslib.dart'; |
| 15 import '../../cps_ir/cps_ir_nodes.dart' as cps; | 15 import '../../cps_ir/cps_ir_nodes.dart' as cps; |
| 16 import '../../cps_ir/cps_ir_integrity.dart'; | 16 import '../../cps_ir/cps_ir_integrity.dart'; |
| 17 import '../../cps_ir/cps_ir_builder_task.dart'; | 17 import '../../cps_ir/cps_ir_builder_task.dart'; |
| 18 import '../../tree_ir/tree_ir_nodes.dart' as tree_ir; | 18 import '../../tree_ir/tree_ir_nodes.dart' as tree_ir; |
| 19 import '../../types/types.dart' show TypeMask, UnionTypeMask, FlatTypeMask, | 19 import '../../types/types.dart' show TypeMask, UnionTypeMask, FlatTypeMask, |
| 20 ForwardingTypeMask; | 20 ForwardingTypeMask; |
| 21 import '../../elements/elements.dart'; | 21 import '../../elements/elements.dart'; |
| 22 import '../../js/js.dart' as js; | 22 import '../../js/js.dart' as js; |
| 23 import '../../io/source_information.dart' show SourceInformationFactory; | 23 import '../../io/source_information.dart' show SourceInformationStrategy; |
| 24 import '../../tree_ir/tree_ir_builder.dart' as tree_builder; | 24 import '../../tree_ir/tree_ir_builder.dart' as tree_builder; |
| 25 import '../../cps_ir/optimizers.dart'; | 25 import '../../cps_ir/optimizers.dart'; |
| 26 import '../../cps_ir/optimizers.dart' as cps_opt; | 26 import '../../cps_ir/optimizers.dart' as cps_opt; |
| 27 import '../../tracer.dart'; | 27 import '../../tracer.dart'; |
| 28 import '../../js_backend/codegen/codegen.dart'; | 28 import '../../js_backend/codegen/codegen.dart'; |
| 29 import '../../ssa/ssa.dart' as ssa; | 29 import '../../ssa/ssa.dart' as ssa; |
| 30 import '../../tree_ir/optimization/optimization.dart'; | 30 import '../../tree_ir/optimization/optimization.dart'; |
| 31 import '../../tree_ir/optimization/optimization.dart' as tree_opt; | 31 import '../../tree_ir/optimization/optimization.dart' as tree_opt; |
| 32 import '../../tree_ir/tree_ir_integrity.dart'; | 32 import '../../tree_ir/tree_ir_integrity.dart'; |
| 33 import '../../cps_ir/cps_ir_nodes_sexpr.dart'; | 33 import '../../cps_ir/cps_ir_nodes_sexpr.dart'; |
| 34 import 'js_tree_builder.dart'; | 34 import 'js_tree_builder.dart'; |
| 35 | 35 |
| 36 class CpsFunctionCompiler implements FunctionCompiler { | 36 class CpsFunctionCompiler implements FunctionCompiler { |
| 37 final ConstantSystem constantSystem; | 37 final ConstantSystem constantSystem; |
| 38 final Compiler compiler; | 38 final Compiler compiler; |
| 39 final Glue glue; | 39 final Glue glue; |
| 40 final SourceInformationFactory sourceInformationFactory; | 40 final SourceInformationStrategy sourceInformationFactory; |
| 41 | 41 |
| 42 // TODO(karlklose,sigurm): remove and update dart-doc of [compile]. | 42 // TODO(karlklose,sigurm): remove and update dart-doc of [compile]. |
| 43 final FunctionCompiler fallbackCompiler; | 43 final FunctionCompiler fallbackCompiler; |
| 44 | 44 |
| 45 Tracer get tracer => compiler.tracer; | 45 Tracer get tracer => compiler.tracer; |
| 46 | 46 |
| 47 IrBuilderTask get irBuilderTask => compiler.irBuilder; | 47 IrBuilderTask get irBuilderTask => compiler.irBuilder; |
| 48 | 48 |
| 49 CpsFunctionCompiler(Compiler compiler, JavaScriptBackend backend, | 49 CpsFunctionCompiler(Compiler compiler, JavaScriptBackend backend, |
| 50 SourceInformationFactory sourceInformationFactory) | 50 SourceInformationStrategy sourceInformationFactory) |
| 51 : fallbackCompiler = | 51 : fallbackCompiler = |
| 52 new ssa.SsaFunctionCompiler(backend, sourceInformationFactory), | 52 new ssa.SsaFunctionCompiler(backend, sourceInformationFactory), |
| 53 this.sourceInformationFactory = sourceInformationFactory, | 53 this.sourceInformationFactory = sourceInformationFactory, |
| 54 constantSystem = backend.constantSystem, | 54 constantSystem = backend.constantSystem, |
| 55 compiler = compiler, | 55 compiler = compiler, |
| 56 glue = new Glue(compiler); | 56 glue = new Glue(compiler); |
| 57 | 57 |
| 58 String get name => 'CPS Ir pipeline'; | 58 String get name => 'CPS Ir pipeline'; |
| 59 | 59 |
| 60 /// Generates JavaScript code for `work.element`. First tries to use the | 60 /// Generates JavaScript code for `work.element`. First tries to use the |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 return attachPosition(codeGen.buildFunction(definition), work.element); | 209 return attachPosition(codeGen.buildFunction(definition), work.element); |
| 210 } | 210 } |
| 211 | 211 |
| 212 Iterable<CompilerTask> get tasks { | 212 Iterable<CompilerTask> get tasks { |
| 213 // TODO(sigurdm): Make a better list of tasks. | 213 // TODO(sigurdm): Make a better list of tasks. |
| 214 return <CompilerTask>[irBuilderTask]..addAll(fallbackCompiler.tasks); | 214 return <CompilerTask>[irBuilderTask]..addAll(fallbackCompiler.tasks); |
| 215 } | 215 } |
| 216 | 216 |
| 217 js.Node attachPosition(js.Node node, AstElement element) { | 217 js.Node attachPosition(js.Node node, AstElement element) { |
| 218 return node.withSourceInformation( | 218 return node.withSourceInformation( |
| 219 sourceInformationFactory.forContext(element) | 219 sourceInformationFactory.createBuilderForContext(element) |
| 220 .buildDeclaration(element)); | 220 .buildDeclaration(element)); |
| 221 } | 221 } |
| 222 } | 222 } |
| OLD | NEW |