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; |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 List<js.Expression> arguments = visitArguments(node.arguments); | 263 List<js.Expression> arguments = visitArguments(node.arguments); |
264 return buildStaticInvoke(selector, target, arguments); | 264 return buildStaticInvoke(selector, target, arguments); |
265 } | 265 } |
266 | 266 |
267 @override | 267 @override |
268 js.Expression visitInvokeMethodDirectly(tree_ir.InvokeMethodDirectly node) { | 268 js.Expression visitInvokeMethodDirectly(tree_ir.InvokeMethodDirectly node) { |
269 registry.registerDirectInvocation(node.target.declaration); | 269 registry.registerDirectInvocation(node.target.declaration); |
270 if (node.target is ConstructorBodyElement) { | 270 if (node.target is ConstructorBodyElement) { |
271 // A constructor body cannot be overriden or intercepted, so we can | 271 // A constructor body cannot be overriden or intercepted, so we can |
272 // use the short form for this invocation. | 272 // use the short form for this invocation. |
273 // TODO(asgerf): prevent name clash between constructor bodies. | |
274 return js.js('#.#(#)', | 273 return js.js('#.#(#)', |
275 [visitExpression(node.receiver), | 274 [visitExpression(node.receiver), |
276 glue.instanceMethodName(node.target), | 275 glue.instanceMethodName(node.target), |
277 visitArguments(node.arguments)]); | 276 visitArguments(node.arguments)]); |
278 } | 277 } |
279 return js.js('#.#.call(#, #)', | 278 return js.js('#.#.call(#, #)', |
280 [glue.prototypeAccess(node.target.enclosingClass), | 279 [glue.prototypeAccess(node.target.enclosingClass), |
281 glue.invocationName(node.selector), | 280 glue.invocationName(node.selector), |
282 visitExpression(node.receiver), | 281 visitExpression(node.receiver), |
283 visitArguments(node.arguments)]); | 282 visitArguments(node.arguments)]); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 | 528 |
530 @override | 529 @override |
531 visitSuperInitializer(tree_ir.SuperInitializer node) { | 530 visitSuperInitializer(tree_ir.SuperInitializer node) { |
532 return errorUnsupportedNode(node); | 531 return errorUnsupportedNode(node); |
533 } | 532 } |
534 | 533 |
535 dynamic errorUnsupportedNode(tree_ir.DartSpecificNode node) { | 534 dynamic errorUnsupportedNode(tree_ir.DartSpecificNode node) { |
536 throw "Unsupported node in JS backend: $node"; | 535 throw "Unsupported node in JS backend: $node"; |
537 } | 536 } |
538 } | 537 } |
OLD | NEW |