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'; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 return true; // So this can be used from assert(). | 187 return true; // So this can be used from assert(). |
188 } | 188 } |
189 | 189 |
190 tree_ir.FunctionDefinition optimizeTreeIR(tree_ir.FunctionDefinition node) { | 190 tree_ir.FunctionDefinition optimizeTreeIR(tree_ir.FunctionDefinition node) { |
191 void applyTreePass(tree_opt.Pass pass) { | 191 void applyTreePass(tree_opt.Pass pass) { |
192 pass.rewrite(node); | 192 pass.rewrite(node); |
193 traceGraph(pass.passName, node); | 193 traceGraph(pass.passName, node); |
194 assert(checkTreeIntegrity(node)); | 194 assert(checkTreeIntegrity(node)); |
195 } | 195 } |
196 | 196 |
197 applyTreePass(new StatementRewriter(isDartMode: false)); | 197 applyTreePass(new StatementRewriter()); |
198 applyTreePass(new VariableMerger()); | 198 applyTreePass(new VariableMerger()); |
199 applyTreePass(new LoopRewriter()); | 199 applyTreePass(new LoopRewriter()); |
200 applyTreePass(new LogicalRewriter()); | 200 applyTreePass(new LogicalRewriter()); |
201 applyTreePass(new PullIntoInitializers()); | 201 applyTreePass(new PullIntoInitializers()); |
202 | 202 |
203 return node; | 203 return node; |
204 } | 204 } |
205 | 205 |
206 js.Fun compileToJavaScript(CodegenWorkItem work, | 206 js.Fun compileToJavaScript(CodegenWorkItem work, |
207 tree_ir.FunctionDefinition definition) { | 207 tree_ir.FunctionDefinition definition) { |
208 CodeGenerator codeGen = new CodeGenerator(glue, work.registry); | 208 CodeGenerator codeGen = new CodeGenerator(glue, work.registry); |
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.forContext(element) |
220 .buildDeclaration(element)); | 220 .buildDeclaration(element)); |
221 } | 221 } |
222 } | 222 } |
OLD | NEW |