| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 List<js.Expression> compiledArguments = | 174 List<js.Expression> compiledArguments = |
| 175 selector.makeArgumentsList(target.implementation, | 175 selector.makeArgumentsList(target.implementation, |
| 176 arguments, | 176 arguments, |
| 177 compileConstant); | 177 compileConstant); |
| 178 return new js.Call(elementAccess, compiledArguments); | 178 return new js.Call(elementAccess, compiledArguments); |
| 179 } | 179 } |
| 180 | 180 |
| 181 @override | 181 @override |
| 182 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) { | 182 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) { |
| 183 if (node.constant != null) return giveup(node); | 183 if (node.constant != null) return giveup(node); |
| 184 registry.registerInstantiatedClass(node.target.enclosingClass); |
| 184 return buildStaticInvoke(node.selector, | 185 return buildStaticInvoke(node.selector, |
| 185 node.target, | 186 node.target, |
| 186 visitArguments(node.arguments)); | 187 visitArguments(node.arguments)); |
| 187 } | 188 } |
| 188 | 189 |
| 189 void registerMethodInvoke(tree_ir.InvokeMethod node) { | 190 void registerMethodInvoke(tree_ir.InvokeMethod node) { |
| 190 Selector selector = node.selector; | 191 Selector selector = node.selector; |
| 191 // TODO(sigurdm): We should find a better place to register the call. | 192 // TODO(sigurdm): We should find a better place to register the call. |
| 192 Selector call = new Selector.callClosureFrom(selector); | 193 Selector call = new Selector.callClosureFrom(selector); |
| 193 registry.registerDynamicInvocation(call); | 194 registry.registerDynamicInvocation(call); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 206 js.Expression visitInvokeStatic(tree_ir.InvokeStatic node) { | 207 js.Expression visitInvokeStatic(tree_ir.InvokeStatic node) { |
| 207 if (node.target is! FunctionElement) { | 208 if (node.target is! FunctionElement) { |
| 208 giveup(node, 'static getters and setters are not supported.'); | 209 giveup(node, 'static getters and setters are not supported.'); |
| 209 } | 210 } |
| 210 return buildStaticInvoke(node.selector, | 211 return buildStaticInvoke(node.selector, |
| 211 node.target, | 212 node.target, |
| 212 visitArguments(node.arguments)); | 213 visitArguments(node.arguments)); |
| 213 } | 214 } |
| 214 | 215 |
| 215 @override | 216 @override |
| 216 js.Expression visitInvokeSuperMethod(tree_ir.InvokeSuperMethod node) { | 217 js.Expression visitInvokeMethodDirectly(tree_ir.InvokeMethodDirectly node) { |
| 217 return giveup(node); | 218 registry.registerDirectInvocation(node.target.declaration); |
| 218 // TODO: implement visitInvokeSuperMethod | 219 return js.js('#.#.call(#, #)', |
| 220 [glue.prototypeAccess(node.target.enclosingClass), |
| 221 glue.invocationName(node.selector), |
| 222 visitExpression(node.receiver), |
| 223 visitArguments(node.arguments)]); |
| 219 } | 224 } |
| 220 | 225 |
| 221 @override | 226 @override |
| 222 js.Expression visitLiteralList(tree_ir.LiteralList node) { | 227 js.Expression visitLiteralList(tree_ir.LiteralList node) { |
| 223 registry.registerInstantiatedClass(glue.listClass); | 228 registry.registerInstantiatedClass(glue.listClass); |
| 224 int length = node.values.length; | 229 int length = node.values.length; |
| 225 List<js.Expression> entries = node.values.map(visitExpression).toList(); | 230 List<js.Expression> entries = node.values.map(visitExpression).toList(); |
| 226 return new js.ArrayInitializer(entries); | 231 return new js.ArrayInitializer(entries); |
| 227 } | 232 } |
| 228 | 233 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 void visitSetField(tree_ir.SetField node) { | 452 void visitSetField(tree_ir.SetField node) { |
| 448 js.PropertyAccess field = | 453 js.PropertyAccess field = |
| 449 new js.PropertyAccess.field( | 454 new js.PropertyAccess.field( |
| 450 visitExpression(node.object), | 455 visitExpression(node.object), |
| 451 glue.instanceFieldPropertyName(node.field)); | 456 glue.instanceFieldPropertyName(node.field)); |
| 452 js.Assignment asn = new js.Assignment(field, visitExpression(node.value)); | 457 js.Assignment asn = new js.Assignment(field, visitExpression(node.value)); |
| 453 accumulator.add(new js.ExpressionStatement(asn)); | 458 accumulator.add(new js.ExpressionStatement(asn)); |
| 454 visitStatement(node.next); | 459 visitStatement(node.next); |
| 455 } | 460 } |
| 456 } | 461 } |
| OLD | NEW |