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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 List<js.Expression> arguments = visitArguments(node.arguments); | 270 List<js.Expression> arguments = visitArguments(node.arguments); |
271 return buildStaticInvoke(selector, target, arguments); | 271 return buildStaticInvoke(selector, target, arguments); |
272 } | 272 } |
273 | 273 |
274 @override | 274 @override |
275 js.Expression visitInvokeMethodDirectly(tree_ir.InvokeMethodDirectly node) { | 275 js.Expression visitInvokeMethodDirectly(tree_ir.InvokeMethodDirectly node) { |
276 registry.registerDirectInvocation(node.target.declaration); | 276 registry.registerDirectInvocation(node.target.declaration); |
277 if (node.target is ConstructorBodyElement) { | 277 if (node.target is ConstructorBodyElement) { |
278 // A constructor body cannot be overriden or intercepted, so we can | 278 // A constructor body cannot be overriden or intercepted, so we can |
279 // use the short form for this invocation. | 279 // use the short form for this invocation. |
| 280 // TODO(asgerf): prevent name clash between constructor bodies. |
280 return js.js('#.#(#)', | 281 return js.js('#.#(#)', |
281 [visitExpression(node.receiver), | 282 [visitExpression(node.receiver), |
282 glue.instanceMethodName(node.target), | 283 glue.instanceMethodName(node.target), |
283 visitArguments(node.arguments)]); | 284 visitArguments(node.arguments)]); |
284 } | 285 } |
285 return js.js('#.#.call(#, #)', | 286 return js.js('#.#.call(#, #)', |
286 [glue.prototypeAccess(node.target.enclosingClass), | 287 [glue.prototypeAccess(node.target.enclosingClass), |
287 glue.invocationName(node.selector), | 288 glue.invocationName(node.selector), |
288 visitExpression(node.receiver), | 289 visitExpression(node.receiver), |
289 visitArguments(node.arguments)]); | 290 visitArguments(node.arguments)]); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 void visitSetField(tree_ir.SetField node) { | 523 void visitSetField(tree_ir.SetField node) { |
523 js.PropertyAccess field = | 524 js.PropertyAccess field = |
524 new js.PropertyAccess.field( | 525 new js.PropertyAccess.field( |
525 visitExpression(node.object), | 526 visitExpression(node.object), |
526 glue.instanceFieldPropertyName(node.field)); | 527 glue.instanceFieldPropertyName(node.field)); |
527 js.Assignment asn = new js.Assignment(field, visitExpression(node.value)); | 528 js.Assignment asn = new js.Assignment(field, visitExpression(node.value)); |
528 accumulator.add(new js.ExpressionStatement(asn)); | 529 accumulator.add(new js.ExpressionStatement(asn)); |
529 visitStatement(node.next); | 530 visitStatement(node.next); |
530 } | 531 } |
531 } | 532 } |
OLD | NEW |