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