| 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 | 11 |
| 11 import '../js_backend.dart'; | 12 import '../js_backend.dart'; |
| 12 import '../../dart2jslib.dart'; | 13 import '../../dart2jslib.dart'; |
| 13 import '../../source_file.dart'; | 14 import '../../source_file.dart'; |
| 14 import '../../cps_ir/cps_ir_nodes.dart' as cps; | 15 import '../../cps_ir/cps_ir_nodes.dart' as cps; |
| 15 import '../../cps_ir/cps_ir_builder.dart'; | 16 import '../../cps_ir/cps_ir_builder.dart'; |
| 16 import '../../tree_ir/tree_ir_nodes.dart' as tree_ir; | 17 import '../../tree_ir/tree_ir_nodes.dart' as tree_ir; |
| 17 import '../../tree/tree.dart' as ast; | 18 import '../../tree/tree.dart' as ast; |
| 18 import '../../scanner/scannerlib.dart' as scanner; | 19 import '../../scanner/scannerlib.dart' as scanner; |
| 19 import '../../elements/elements.dart'; | 20 import '../../elements/elements.dart'; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 if (element.isGenerativeConstructorBody || | 93 if (element.isGenerativeConstructorBody || |
| 93 element.enclosingClass is ClosureClassElement || | 94 element.enclosingClass is ClosureClassElement || |
| 94 element.isNative) { | 95 element.isNative) { |
| 95 giveUp('unsupported element kind: ${element.name}:${element.kind}'); | 96 giveUp('unsupported element kind: ${element.name}:${element.kind}'); |
| 96 } | 97 } |
| 97 | 98 |
| 98 cps.FunctionDefinition cpsNode = irBuilderTask.buildNode(element); | 99 cps.FunctionDefinition cpsNode = irBuilderTask.buildNode(element); |
| 99 if (cpsNode == null) { | 100 if (cpsNode == null) { |
| 100 giveUp('unable to build cps definition of $element'); | 101 giveUp('unable to build cps definition of $element'); |
| 101 } | 102 } |
| 103 const UnsugarVisitor().rewrite(cpsNode); |
| 102 return cpsNode; | 104 return cpsNode; |
| 103 } | 105 } |
| 104 | 106 |
| 105 cps.FunctionDefinition optimizeCpsIR(cps.FunctionDefinition cpsNode) { | 107 cps.FunctionDefinition optimizeCpsIR(cps.FunctionDefinition cpsNode) { |
| 106 // Transformations on the CPS IR. | 108 // Transformations on the CPS IR. |
| 107 traceGraph("IR Builder", cpsNode); | 109 traceGraph("IR Builder", cpsNode); |
| 108 new ConstantPropagator(compiler, constantSystem) | 110 new ConstantPropagator(compiler, constantSystem) |
| 109 .rewrite(cpsNode); | 111 .rewrite(cpsNode); |
| 110 traceGraph("Sparse constant propagation", cpsNode); | 112 traceGraph("Sparse constant propagation", cpsNode); |
| 111 new RedundantPhiEliminator().rewrite(cpsNode); | 113 new RedundantPhiEliminator().rewrite(cpsNode); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 SourceFile sourceFileOfElement(Element element) { | 195 SourceFile sourceFileOfElement(Element element) { |
| 194 return element.implementation.compilationUnit.script.file; | 196 return element.implementation.compilationUnit.script.file; |
| 195 } | 197 } |
| 196 | 198 |
| 197 js.Fun buildJavaScriptFunction(FunctionElement element, | 199 js.Fun buildJavaScriptFunction(FunctionElement element, |
| 198 List<js.Parameter> parameters, | 200 List<js.Parameter> parameters, |
| 199 js.Block body) { | 201 js.Block body) { |
| 200 return attachPosition(new js.Fun(parameters, body), element); | 202 return attachPosition(new js.Fun(parameters, body), element); |
| 201 } | 203 } |
| 202 } | 204 } |
| OLD | NEW |