| 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 library code_generator; | 5 library code_generator; |
| 6 | 6 |
| 7 import 'glue.dart'; | 7 import 'glue.dart'; |
| 8 | 8 |
| 9 import '../../tree_ir/tree_ir_nodes.dart' as tree_ir; | 9 import '../../tree_ir/tree_ir_nodes.dart' as tree_ir; |
| 10 import '../../js/js.dart' as js; | 10 import '../../js/js.dart' as js; |
| 11 import '../../elements/elements.dart'; | 11 import '../../elements/elements.dart'; |
| 12 import '../../io/source_information.dart' show SourceInformation; | 12 import '../../io/source_information.dart' show SourceInformation; |
| 13 import '../../util/maplet.dart'; | 13 import '../../util/maplet.dart'; |
| 14 import '../../constants/values.dart'; | 14 import '../../constants/values.dart'; |
| 15 import '../../dart2jslib.dart'; | 15 import '../../dart2jslib.dart'; |
| 16 import '../../dart_types.dart'; | 16 import '../../dart_types.dart'; |
| 17 import '../../types/types.dart' show TypeMask; |
| 18 import '../../universe/universe.dart' show UniverseSelector; |
| 17 | 19 |
| 18 class CodegenBailout { | 20 class CodegenBailout { |
| 19 final tree_ir.Node node; | 21 final tree_ir.Node node; |
| 20 final String reason; | 22 final String reason; |
| 21 CodegenBailout(this.node, this.reason); | 23 CodegenBailout(this.node, this.reason); |
| 22 String get message { | 24 String get message { |
| 23 return 'bailout${node != null ? " on $node" : ""}: $reason'; | 25 return 'bailout${node != null ? " on $node" : ""}: $reason'; |
| 24 } | 26 } |
| 25 } | 27 } |
| 26 | 28 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 246 |
| 245 registry.registerInstantiatedType(node.type); | 247 registry.registerInstantiatedType(node.type); |
| 246 Selector selector = node.selector; | 248 Selector selector = node.selector; |
| 247 FunctionElement target = node.target; | 249 FunctionElement target = node.target; |
| 248 List<js.Expression> arguments = visitExpressionList(node.arguments); | 250 List<js.Expression> arguments = visitExpressionList(node.arguments); |
| 249 return buildStaticInvoke(selector, target, arguments); | 251 return buildStaticInvoke(selector, target, arguments); |
| 250 } | 252 } |
| 251 | 253 |
| 252 void registerMethodInvoke(tree_ir.InvokeMethod node) { | 254 void registerMethodInvoke(tree_ir.InvokeMethod node) { |
| 253 Selector selector = node.selector; | 255 Selector selector = node.selector; |
| 256 TypeMask mask = node.mask; |
| 254 if (selector.isGetter) { | 257 if (selector.isGetter) { |
| 255 registry.registerDynamicGetter(selector); | 258 registry.registerDynamicGetter(new UniverseSelector(selector, mask)); |
| 256 } else if (selector.isSetter) { | 259 } else if (selector.isSetter) { |
| 257 registry.registerDynamicSetter(selector); | 260 registry.registerDynamicSetter(new UniverseSelector(selector, mask)); |
| 258 } else { | 261 } else { |
| 259 assert(invariant(CURRENT_ELEMENT_SPANNABLE, | 262 assert(invariant(CURRENT_ELEMENT_SPANNABLE, |
| 260 selector.isCall || selector.isOperator || | 263 selector.isCall || selector.isOperator || |
| 261 selector.isIndex || selector.isIndexSet, | 264 selector.isIndex || selector.isIndexSet, |
| 262 message: 'unexpected kind ${selector.kind}')); | 265 message: 'unexpected kind ${selector.kind}')); |
| 263 // TODO(sigurdm): We should find a better place to register the call. | 266 // TODO(sigurdm): We should find a better place to register the call. |
| 264 Selector call = new Selector.callClosureFrom(selector); | 267 Selector call = new Selector.callClosureFrom(selector); |
| 265 registry.registerDynamicInvocation(call); | 268 registry.registerDynamicInvocation(new UniverseSelector(call, null)); |
| 266 registry.registerDynamicInvocation(selector); | 269 registry.registerDynamicInvocation(new UniverseSelector(selector, mask)); |
| 267 } | 270 } |
| 268 } | 271 } |
| 269 | 272 |
| 270 @override | 273 @override |
| 271 js.Expression visitInvokeMethod(tree_ir.InvokeMethod node) { | 274 js.Expression visitInvokeMethod(tree_ir.InvokeMethod node) { |
| 272 registerMethodInvoke(node); | 275 registerMethodInvoke(node); |
| 273 return js.propertyCall(visitExpression(node.receiver), | 276 return js.propertyCall(visitExpression(node.receiver), |
| 274 glue.invocationName(node.selector), | 277 glue.invocationName(node.selector), |
| 275 visitExpressionList(node.arguments)); | 278 visitExpressionList(node.arguments)); |
| 276 } | 279 } |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 List<js.Expression> arguments = visitExpressionList(node.arguments); | 697 List<js.Expression> arguments = visitExpressionList(node.arguments); |
| 695 return glue.generateTypeRepresentation(node.dartType, arguments); | 698 return glue.generateTypeRepresentation(node.dartType, arguments); |
| 696 } | 699 } |
| 697 | 700 |
| 698 visitFunctionExpression(tree_ir.FunctionExpression node) { | 701 visitFunctionExpression(tree_ir.FunctionExpression node) { |
| 699 // FunctionExpressions are currently unused. | 702 // FunctionExpressions are currently unused. |
| 700 // We might need them if we want to emit raw JS nested functions. | 703 // We might need them if we want to emit raw JS nested functions. |
| 701 throw 'FunctionExpressions should not be used'; | 704 throw 'FunctionExpressions should not be used'; |
| 702 } | 705 } |
| 703 } | 706 } |
| OLD | NEW |