| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 return new js.Call(elementAccess, arguments, | 232 return new js.Call(elementAccess, arguments, |
| 233 sourceInformation: sourceInformation); | 233 sourceInformation: sourceInformation); |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 | 236 |
| 237 @override | 237 @override |
| 238 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) { | 238 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) { |
| 239 checkStaticTargetIsValid(node, node.target); | 239 checkStaticTargetIsValid(node, node.target); |
| 240 if (node.constant != null) return giveup(node); | 240 if (node.constant != null) return giveup(node); |
| 241 | 241 |
| 242 ClassElement instantiatedClass = node.target.enclosingClass; | 242 registry.registerInstantiatedType(node.type); |
| 243 registry.registerInstantiatedClass(instantiatedClass); | |
| 244 Selector selector = node.selector; | 243 Selector selector = node.selector; |
| 245 FunctionElement target = node.target; | 244 FunctionElement target = node.target; |
| 246 List<js.Expression> arguments = visitArguments(node.arguments); | 245 List<js.Expression> arguments = visitArguments(node.arguments); |
| 247 return buildStaticInvoke(selector, target, arguments); | 246 return buildStaticInvoke(selector, target, arguments); |
| 248 } | 247 } |
| 249 | 248 |
| 250 void registerMethodInvoke(tree_ir.InvokeMethod node) { | 249 void registerMethodInvoke(tree_ir.InvokeMethod node) { |
| 251 Selector selector = node.selector; | 250 Selector selector = node.selector; |
| 252 if (selector.isGetter) { | 251 if (selector.isGetter) { |
| 253 registry.registerDynamicGetter(selector); | 252 registry.registerDynamicGetter(selector); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 } | 522 } |
| 524 | 523 |
| 525 @override | 524 @override |
| 526 js.Expression visitCreateBox(tree_ir.CreateBox node) { | 525 js.Expression visitCreateBox(tree_ir.CreateBox node) { |
| 527 return new js.ObjectInitializer([]); | 526 return new js.ObjectInitializer([]); |
| 528 } | 527 } |
| 529 | 528 |
| 530 @override | 529 @override |
| 531 js.Expression visitCreateInstance(tree_ir.CreateInstance node) { | 530 js.Expression visitCreateInstance(tree_ir.CreateInstance node) { |
| 532 ClassElement cls = node.classElement; | 531 ClassElement cls = node.classElement; |
| 532 // TODO(asgerf): To allow inlining of InvokeConstructor, CreateInstance must |
| 533 // carry a DartType so we can register the instantiated type |
| 534 // with its type arguments. Otherwise dataflow analysis is |
| 535 // needed to reconstruct the instantiated type. |
| 533 registry.registerInstantiatedClass(cls); | 536 registry.registerInstantiatedClass(cls); |
| 534 js.Expression instance = new js.New( | 537 js.Expression instance = new js.New( |
| 535 glue.constructorAccess(cls), | 538 glue.constructorAccess(cls), |
| 536 node.arguments.map(visitExpression).toList()); | 539 node.arguments.map(visitExpression).toList()); |
| 537 | 540 |
| 538 List<tree_ir.Expression> typeInformation = node.typeInformation; | 541 List<tree_ir.Expression> typeInformation = node.typeInformation; |
| 539 assert(typeInformation.isEmpty || | 542 assert(typeInformation.isEmpty || |
| 540 typeInformation.length == cls.typeVariables.length); | 543 typeInformation.length == cls.typeVariables.length); |
| 541 if (typeInformation.isNotEmpty) { | 544 if (typeInformation.isNotEmpty) { |
| 542 FunctionElement helper = glue.getAddRuntimeTypeInformation(); | 545 FunctionElement helper = glue.getAddRuntimeTypeInformation(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 | 626 |
| 624 @override | 627 @override |
| 625 visitVariableDeclaration(tree_ir.VariableDeclaration node) { | 628 visitVariableDeclaration(tree_ir.VariableDeclaration node) { |
| 626 return errorUnsupportedNode(node); | 629 return errorUnsupportedNode(node); |
| 627 } | 630 } |
| 628 | 631 |
| 629 errorUnsupportedNode(tree_ir.DartSpecificNode node) { | 632 errorUnsupportedNode(tree_ir.DartSpecificNode node) { |
| 630 throw "Unsupported node in JS backend: $node"; | 633 throw "Unsupported node in JS backend: $node"; |
| 631 } | 634 } |
| 632 } | 635 } |
| OLD | NEW |