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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 inliner.cache.putUnoptimized(element, cpsFunction); | 209 inliner.cache.putUnoptimized(element, cpsFunction); |
210 return cpsFunction; | 210 return cpsFunction; |
211 } | 211 } |
212 | 212 |
213 static const Pattern PRINT_TYPED_IR_FILTER = null; | 213 static const Pattern PRINT_TYPED_IR_FILTER = null; |
214 | 214 |
215 String formatTypeMask(TypeMask type) { | 215 String formatTypeMask(TypeMask type) { |
216 if (type is UnionTypeMask) { | 216 if (type is UnionTypeMask) { |
217 return '[${type.disjointMasks.map(formatTypeMask).join(', ')}]'; | 217 return '[${type.disjointMasks.map(formatTypeMask).join(', ')}]'; |
218 } else if (type is FlatTypeMask) { | 218 } else if (type is FlatTypeMask) { |
219 if (type.isEmpty) { | 219 if (type.isEmpty) return "empty"; |
220 return "null"; | 220 if (type.isNull) return "null"; |
221 } | |
222 String suffix = (type.isExact ? "" : "+") + (type.isNullable ? "?" : "!"); | 221 String suffix = (type.isExact ? "" : "+") + (type.isNullable ? "?" : "!"); |
223 return '${type.base.name}$suffix'; | 222 return '${type.base.name}$suffix'; |
224 } else if (type is ForwardingTypeMask) { | 223 } else if (type is ForwardingTypeMask) { |
225 return formatTypeMask(type.forwardTo); | 224 return formatTypeMask(type.forwardTo); |
226 } | 225 } |
227 throw 'unsupported: $type'; | 226 throw 'unsupported: $type'; |
228 } | 227 } |
229 | 228 |
230 void dumpTypedIr(String passName, cps.FunctionDefinition cpsFunction) { | 229 void dumpTypedIr(String passName, cps.FunctionDefinition cpsFunction) { |
231 if (PRINT_TYPED_IR_FILTER != null && | 230 if (PRINT_TYPED_IR_FILTER != null && |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 treeOptimizationTask] | 351 treeOptimizationTask] |
353 ..addAll(fallbackCompiler.tasks); | 352 ..addAll(fallbackCompiler.tasks); |
354 } | 353 } |
355 | 354 |
356 js.Node attachPosition(js.Node node, AstElement element) { | 355 js.Node attachPosition(js.Node node, AstElement element) { |
357 return node.withSourceInformation( | 356 return node.withSourceInformation( |
358 sourceInformationFactory.createBuilderForContext(element) | 357 sourceInformationFactory.createBuilderForContext(element) |
359 .buildDeclaration(element)); | 358 .buildDeclaration(element)); |
360 } | 359 } |
361 } | 360 } |
OLD | NEW |