| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 js.Expression visitConstant(tree_ir.Constant node) { | 155 js.Expression visitConstant(tree_ir.Constant node) { |
| 156 return buildConstant(node.expression.value); | 156 return buildConstant(node.expression.value); |
| 157 } | 157 } |
| 158 | 158 |
| 159 @override | 159 @override |
| 160 js.Expression visitFunctionExpression(tree_ir.FunctionExpression node) { | 160 js.Expression visitFunctionExpression(tree_ir.FunctionExpression node) { |
| 161 return giveup(node); | 161 return giveup(node); |
| 162 // TODO: implement visitFunctionExpression | 162 // TODO: implement visitFunctionExpression |
| 163 } | 163 } |
| 164 | 164 |
| 165 js.Expression compileConstant(ParameterElement parameter) { |
| 166 return buildConstant(glue.getConstantForVariable(parameter).value); |
| 167 } |
| 168 |
| 169 js.Expression buildStaticInvoke(Selector selector, |
| 170 Element target, |
| 171 List<tree_ir.Expression> arguments) { |
| 172 registry.registerStaticInvocation(target.declaration); |
| 173 |
| 174 js.Expression elementAccess = glue.elementAccess(target); |
| 175 List<js.Expression> compiledArguments = |
| 176 selector.makeArgumentsList(arguments, target.implementation, |
| 177 visitExpression, |
| 178 compileConstant); |
| 179 return new js.Call(elementAccess, compiledArguments); |
| 180 } |
| 181 |
| 165 @override | 182 @override |
| 166 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) { | 183 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) { |
| 167 return giveup(node); | 184 if (node.constant != null) return giveup(node); |
| 168 // TODO: implement visitInvokeConstructor | 185 return buildStaticInvoke(node.selector, node.target, node.arguments); |
| 169 } | 186 } |
| 170 | 187 |
| 171 @override | 188 @override |
| 172 js.Expression visitInvokeMethod(tree_ir.InvokeMethod node) { | 189 js.Expression visitInvokeMethod(tree_ir.InvokeMethod node) { |
| 173 return giveup(node); | 190 return giveup(node); |
| 174 // TODO: implement visitInvokeMethod | 191 // TODO: implement visitInvokeMethod |
| 175 } | 192 } |
| 176 | 193 |
| 177 @override | 194 @override |
| 178 js.Expression visitInvokeStatic(tree_ir.InvokeStatic node) { | 195 js.Expression visitInvokeStatic(tree_ir.InvokeStatic node) { |
| 179 Element element = node.target; | 196 return buildStaticInvoke(node.selector, node.target, node.arguments); |
| 180 | |
| 181 registry.registerStaticInvocation(element.declaration); | |
| 182 | |
| 183 js.Expression compileConstant(ParameterElement parameter) { | |
| 184 return buildConstant(glue.getConstantForVariable(parameter).value); | |
| 185 } | |
| 186 | |
| 187 js.Expression elementAccess = glue.elementAccess(node.target); | |
| 188 List<js.Expression> arguments = | |
| 189 node.selector.makeArgumentsList(node.arguments, element.implementation, | |
| 190 visitExpression, | |
| 191 compileConstant); | |
| 192 return new js.Call(elementAccess, arguments); | |
| 193 } | 197 } |
| 194 | 198 |
| 195 @override | 199 @override |
| 196 js.Expression visitInvokeSuperMethod(tree_ir.InvokeSuperMethod node) { | 200 js.Expression visitInvokeSuperMethod(tree_ir.InvokeSuperMethod node) { |
| 197 return giveup(node); | 201 return giveup(node); |
| 198 // TODO: implement visitInvokeSuperMethod | 202 // TODO: implement visitInvokeSuperMethod |
| 199 } | 203 } |
| 200 | 204 |
| 201 @override | 205 @override |
| 202 js.Expression visitLiteralList(tree_ir.LiteralList node) { | 206 js.Expression visitLiteralList(tree_ir.LiteralList node) { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 accumulator.add( | 375 accumulator.add( |
| 372 buildWhile(new js.LiteralBool(true), node.body, node.label, node)); | 376 buildWhile(new js.LiteralBool(true), node.body, node.label, node)); |
| 373 } | 377 } |
| 374 | 378 |
| 375 @override | 379 @override |
| 376 void visitReturn(tree_ir.Return node) { | 380 void visitReturn(tree_ir.Return node) { |
| 377 accumulator.add(new js.Return(visitExpression(node.value))); | 381 accumulator.add(new js.Return(visitExpression(node.value))); |
| 378 } | 382 } |
| 379 | 383 |
| 380 } | 384 } |
| OLD | NEW |