| 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 '../js_backend.dart';import '../../dart2jslib.dart'; | 8 import '../js_backend.dart';import '../../dart2jslib.dart'; |
| 9 import '../../source_file.dart'; | 9 import '../../source_file.dart'; |
| 10 import '../../cps_ir/cps_ir_nodes.dart' as cps; | 10 import '../../cps_ir/cps_ir_nodes.dart' as cps; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 final ConstantSystem constantSystem; | 39 final ConstantSystem constantSystem; |
| 40 | 40 |
| 41 final Compiler compiler; | 41 final Compiler compiler; |
| 42 | 42 |
| 43 // Remember to update dart-doc of [compile] when this field is removed. | 43 // Remember to update dart-doc of [compile] when this field is removed. |
| 44 FunctionCompiler fallbackCompiler; | 44 FunctionCompiler fallbackCompiler; |
| 45 | 45 |
| 46 CspFunctionCompiler(Compiler compiler, JavaScriptBackend backend) | 46 CspFunctionCompiler(Compiler compiler, JavaScriptBackend backend) |
| 47 : irBuilderTask = new IrBuilderTask(compiler), | 47 : irBuilderTask = new IrBuilderTask(compiler), |
| 48 fallbackCompiler = new ssa.SsaFunctionCompiler(backend), | 48 fallbackCompiler = new ssa.SsaFunctionCompiler(backend, true), |
| 49 constantSystem = backend.constantSystem, | 49 constantSystem = backend.constantSystem, |
| 50 compiler = compiler; | 50 compiler = compiler; |
| 51 | 51 |
| 52 /// Generates JavaScript code for `work.element`. First tries to use the | 52 /// Generates JavaScript code for `work.element`. First tries to use the |
| 53 /// Cps Ir -> tree ir -> js pipeline, and if that fails due to language | 53 /// Cps Ir -> tree ir -> js pipeline, and if that fails due to language |
| 54 /// features not implemented it will fall back to the ssa pipeline. | 54 /// features not implemented it will fall back to the ssa pipeline. |
| 55 js.Fun compile(CodegenWorkItem work) { | 55 js.Fun compile(CodegenWorkItem work) { |
| 56 AstElement element = work.element; | 56 AstElement element = work.element; |
| 57 return compiler.withCurrentElement(element, () { | 57 return compiler.withCurrentElement(element, () { |
| 58 try { | 58 try { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 SourceFile sourceFileOfElement(Element element) { | 161 SourceFile sourceFileOfElement(Element element) { |
| 162 return element.implementation.compilationUnit.script.file; | 162 return element.implementation.compilationUnit.script.file; |
| 163 } | 163 } |
| 164 | 164 |
| 165 js.Fun buildJavaScriptFunction(FunctionElement element, | 165 js.Fun buildJavaScriptFunction(FunctionElement element, |
| 166 List<js.Parameter> parameters, | 166 List<js.Parameter> parameters, |
| 167 js.Block body) { | 167 js.Block body) { |
| 168 return attachPosition(new js.Fun(parameters, body), element); | 168 return attachPosition(new js.Fun(parameters, body), element); |
| 169 } | 169 } |
| 170 } | 170 } |
| OLD | NEW |