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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 329 |
330 js.Fun compileToJavaScript( | 330 js.Fun compileToJavaScript( |
331 CodegenWorkItem work, tree_ir.FunctionDefinition definition) { | 331 CodegenWorkItem work, tree_ir.FunctionDefinition definition) { |
332 CodeGenerator codeGen = new CodeGenerator(glue, work.registry); | 332 CodeGenerator codeGen = new CodeGenerator(glue, work.registry); |
333 Element element = work.element; | 333 Element element = work.element; |
334 js.Fun code = codeGen.buildFunction(definition); | 334 js.Fun code = codeGen.buildFunction(definition); |
335 if (element is FunctionElement && element.asyncMarker != AsyncMarker.SYNC) { | 335 if (element is FunctionElement && element.asyncMarker != AsyncMarker.SYNC) { |
336 code = backend.rewriteAsync(element, code); | 336 code = backend.rewriteAsync(element, code); |
337 work.registry.registerAsyncMarker(element); | 337 work.registry.registerAsyncMarker(element); |
338 } | 338 } |
339 return attachPosition(code, element); | 339 return attachPosition(code, work.resolvedAst); |
340 } | 340 } |
341 | 341 |
342 Iterable<CompilerTask> get tasks { | 342 Iterable<CompilerTask> get tasks { |
343 return <CompilerTask>[ | 343 return <CompilerTask>[ |
344 cpsBuilderTask, | 344 cpsBuilderTask, |
345 cpsOptimizationTask, | 345 cpsOptimizationTask, |
346 treeBuilderTask, | 346 treeBuilderTask, |
347 treeOptimizationTask | 347 treeOptimizationTask |
348 ]..addAll(fallbackCompiler.tasks); | 348 ]..addAll(fallbackCompiler.tasks); |
349 } | 349 } |
350 | 350 |
351 js.Node attachPosition(js.Node node, AstElement element) { | 351 js.Node attachPosition(js.Node node, ResolvedAst resolvedAst) { |
352 return node.withSourceInformation(sourceInformationFactory | 352 return node.withSourceInformation(sourceInformationFactory |
353 .createBuilderForContext(element) | 353 .createBuilderForContext(resolvedAst) |
354 .buildDeclaration(backend.frontend.getResolvedAst(element))); | 354 .buildDeclaration(resolvedAst)); |
355 } | 355 } |
356 } | 356 } |
OLD | NEW |