Chromium Code Reviews| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 } else { | 199 } else { |
| 200 js.Expression elementAccess = glue.staticFunctionAccess(target); | 200 js.Expression elementAccess = glue.staticFunctionAccess(target); |
| 201 return new js.Call(elementAccess, arguments, | 201 return new js.Call(elementAccess, arguments, |
| 202 sourceInformation: sourceInformation); | 202 sourceInformation: sourceInformation); |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 @override | 206 @override |
| 207 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) { | 207 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) { |
| 208 checkStaticTargetIsValid(node, node.target); | 208 checkStaticTargetIsValid(node, node.target); |
| 209 assert(node.type == null); | |
| 210 if (node.constant != null) return giveup(node); | |
| 209 | 211 |
| 210 if (node.constant != null) return giveup(node); | 212 ClassElement instantiatedClass = node.target.enclosingClass; |
| 211 registry.registerInstantiatedClass(node.target.enclosingClass); | 213 registry.registerInstantiatedClass(instantiatedClass); |
| 212 Selector selector = node.selector; | 214 Selector selector = node.selector; |
| 213 FunctionElement target = node.target; | 215 FunctionElement target = node.target; |
| 214 List<js.Expression> arguments = visitArguments(node.arguments); | 216 List<js.Expression> arguments = visitArguments(node.arguments); |
| 215 return buildStaticInvoke(selector, target, arguments); | 217 js.Expression object = buildStaticInvoke(selector, target, arguments); |
|
asgerf
2015/03/18 10:18:07
It seems we are using InvokeConstuctor to call the
| |
| 218 if (!node.typeArguments.isEmpty) { | |
| 219 FunctionElement helper = glue.getAddRuntimeTypeInformation(); | |
| 220 List<js.Expression> typeArguments = visitArguments(node.typeArguments); | |
| 221 js.Expression typeInformation = new js.ArrayInitializer(typeArguments); | |
| 222 return buildStaticHelperInvocation(helper, | |
| 223 <js.Expression>[object, typeInformation]); | |
| 224 } else { | |
| 225 return object; | |
| 226 } | |
| 216 } | 227 } |
| 217 | 228 |
| 218 void registerMethodInvoke(tree_ir.InvokeMethod node) { | 229 void registerMethodInvoke(tree_ir.InvokeMethod node) { |
| 219 Selector selector = node.selector; | 230 Selector selector = node.selector; |
| 220 if (selector.isGetter) { | 231 if (selector.isGetter) { |
| 221 registry.registerDynamicGetter(selector); | 232 registry.registerDynamicGetter(selector); |
| 222 } else if (selector.isSetter) { | 233 } else if (selector.isSetter) { |
| 223 registry.registerDynamicSetter(selector); | 234 registry.registerDynamicSetter(selector); |
| 224 } else { | 235 } else { |
| 225 assert(invariant(CURRENT_ELEMENT_SPANNABLE, | 236 assert(invariant(CURRENT_ELEMENT_SPANNABLE, |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 return buildStaticHelperInvocation( | 559 return buildStaticHelperInvocation( |
| 549 glue.getTypeArgumentWithSubstitution(), | 560 glue.getTypeArgumentWithSubstitution(), |
| 550 [visitExpression(node.target), substitution, index]); | 561 [visitExpression(node.target), substitution, index]); |
| 551 } else { | 562 } else { |
| 552 return buildStaticHelperInvocation( | 563 return buildStaticHelperInvocation( |
| 553 glue.getTypeArgumentByIndex(), | 564 glue.getTypeArgumentByIndex(), |
| 554 [visitExpression(node.target), index]); | 565 [visitExpression(node.target), index]); |
| 555 } | 566 } |
| 556 } | 567 } |
| 557 | 568 |
| 569 @override | |
| 570 js.Expression visitTypeExpression(tree_ir.TypeExpression node) { | |
| 571 List<js.Expression> arguments = | |
| 572 node.arguments.map(visitExpression).toList(growable: false); | |
| 573 return glue.generateTypeRepresentation(node.dartType, arguments); | |
| 574 } | |
| 558 | 575 |
| 559 // Dart-specific IR nodes | 576 // Dart-specific IR nodes |
| 560 | 577 |
| 561 @override | 578 @override |
| 562 visitReifyTypeVar(tree_ir.ReifyTypeVar node) { | 579 visitReifyTypeVar(tree_ir.ReifyTypeVar node) { |
| 563 return errorUnsupportedNode(node); | 580 return errorUnsupportedNode(node); |
| 564 } | 581 } |
| 565 | 582 |
| 566 @override | 583 @override |
| 567 visitFunctionExpression(tree_ir.FunctionExpression node) { | 584 visitFunctionExpression(tree_ir.FunctionExpression node) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 580 | 597 |
| 581 @override | 598 @override |
| 582 visitSuperInitializer(tree_ir.SuperInitializer node) { | 599 visitSuperInitializer(tree_ir.SuperInitializer node) { |
| 583 return errorUnsupportedNode(node); | 600 return errorUnsupportedNode(node); |
| 584 } | 601 } |
| 585 | 602 |
| 586 errorUnsupportedNode(tree_ir.DartSpecificNode node) { | 603 errorUnsupportedNode(tree_ir.DartSpecificNode node) { |
| 587 throw "Unsupported node in JS backend: $node"; | 604 throw "Unsupported node in JS backend: $node"; |
| 588 } | 605 } |
| 589 } | 606 } |
| OLD | NEW |