| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 ? nodeOrRef.definition | 149 ? nodeOrRef.definition |
| 150 : nodeOrRef; | 150 : nodeOrRef; |
| 151 var type = typePropagator.getType(node); | 151 var type = typePropagator.getType(node); |
| 152 return type == null ? s : "$s:${formatTypeMask(type.type)}"; | 152 return type == null ? s : "$s:${formatTypeMask(type.type)}"; |
| 153 } | 153 } |
| 154 DEBUG_MODE = true; | 154 DEBUG_MODE = true; |
| 155 print(new SExpressionStringifier(printType).visit(cpsNode)); | 155 print(new SExpressionStringifier(printType).visit(cpsNode)); |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 | 158 |
| 159 static bool checkCpsIntegrity(cps.ExecutableDefinition node) { | 159 static bool checkCpsIntegrity(cps.RootNode node) { |
| 160 new CheckCpsIntegrity().check(node); | 160 new CheckCpsIntegrity().check(node); |
| 161 return true; // So this can be used from assert(). | 161 return true; // So this can be used from assert(). |
| 162 } | 162 } |
| 163 | 163 |
| 164 cps.FunctionDefinition optimizeCpsIR(cps.FunctionDefinition cpsNode) { | 164 cps.FunctionDefinition optimizeCpsIR(cps.FunctionDefinition cpsNode) { |
| 165 // Transformations on the CPS IR. | 165 // Transformations on the CPS IR. |
| 166 void applyCpsPass(cps_opt.Pass pass) { | 166 void applyCpsPass(cps_opt.Pass pass) { |
| 167 pass.rewrite(cpsNode); | 167 pass.rewrite(cpsNode); |
| 168 traceGraph(pass.passName, cpsNode); | 168 traceGraph(pass.passName, cpsNode); |
| 169 assert(checkCpsIntegrity(cpsNode)); | 169 assert(checkCpsIntegrity(cpsNode)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 185 tree_ir.FunctionDefinition compileToTreeIR(cps.FunctionDefinition cpsNode) { | 185 tree_ir.FunctionDefinition compileToTreeIR(cps.FunctionDefinition cpsNode) { |
| 186 tree_builder.Builder builder = new JsTreeBuilder( | 186 tree_builder.Builder builder = new JsTreeBuilder( |
| 187 compiler.internalError, compiler.identicalFunction, glue); | 187 compiler.internalError, compiler.identicalFunction, glue); |
| 188 tree_ir.FunctionDefinition treeNode = builder.buildFunction(cpsNode); | 188 tree_ir.FunctionDefinition treeNode = builder.buildFunction(cpsNode); |
| 189 assert(treeNode != null); | 189 assert(treeNode != null); |
| 190 traceGraph('Tree builder', treeNode); | 190 traceGraph('Tree builder', treeNode); |
| 191 assert(checkTreeIntegrity(treeNode)); | 191 assert(checkTreeIntegrity(treeNode)); |
| 192 return treeNode; | 192 return treeNode; |
| 193 } | 193 } |
| 194 | 194 |
| 195 static bool checkTreeIntegrity(tree_ir.ExecutableDefinition node) { | 195 static bool checkTreeIntegrity(tree_ir.RootNode node) { |
| 196 new CheckTreeIntegrity().check(node); | 196 new CheckTreeIntegrity().check(node); |
| 197 return true; // So this can be used from assert(). | 197 return true; // So this can be used from assert(). |
| 198 } | 198 } |
| 199 | 199 |
| 200 tree_ir.FunctionDefinition optimizeTreeIR(tree_ir.FunctionDefinition node) { | 200 tree_ir.FunctionDefinition optimizeTreeIR(tree_ir.FunctionDefinition node) { |
| 201 void applyTreePass(tree_opt.Pass pass) { | 201 void applyTreePass(tree_opt.Pass pass) { |
| 202 pass.rewrite(node); | 202 pass.rewrite(node); |
| 203 traceGraph(pass.passName, node); | 203 traceGraph(pass.passName, node); |
| 204 assert(checkTreeIntegrity(node)); | 204 assert(checkTreeIntegrity(node)); |
| 205 } | 205 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 222 Iterable<CompilerTask> get tasks { | 222 Iterable<CompilerTask> get tasks { |
| 223 // TODO(sigurdm): Make a better list of tasks. | 223 // TODO(sigurdm): Make a better list of tasks. |
| 224 return <CompilerTask>[irBuilderTask]..addAll(fallbackCompiler.tasks); | 224 return <CompilerTask>[irBuilderTask]..addAll(fallbackCompiler.tasks); |
| 225 } | 225 } |
| 226 | 226 |
| 227 js.Node attachPosition(js.Node node, AstElement element) { | 227 js.Node attachPosition(js.Node node, AstElement element) { |
| 228 return node.withSourceInformation( | 228 return node.withSourceInformation( |
| 229 StartEndSourceInformation.computeSourceInformation(element)); | 229 StartEndSourceInformation.computeSourceInformation(element)); |
| 230 } | 230 } |
| 231 } | 231 } |
| OLD | NEW |