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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 return giveup(node); | 125 return giveup(node); |
| 126 // TODO: implement visitConcatenateStrings | 126 // TODO: implement visitConcatenateStrings |
| 127 } | 127 } |
| 128 | 128 |
| 129 @override | 129 @override |
| 130 js.Expression visitConditional(tree_ir.Conditional node) { | 130 js.Expression visitConditional(tree_ir.Conditional node) { |
| 131 return giveup(node); | 131 return giveup(node); |
| 132 // TODO: implement visitConditional | 132 // TODO: implement visitConditional |
| 133 } | 133 } |
| 134 | 134 |
| 135 js.Expression buildConstant(ConstantValue constant) { | |
| 136 registry.registerCompileTimeConstant(constant); | |
| 137 return glue.constantReference(constant); | |
| 138 } | |
| 139 | |
| 135 @override | 140 @override |
| 136 js.Expression visitConstant(tree_ir.Constant node) { | 141 js.Expression visitConstant(tree_ir.Constant node) { |
| 137 ConstantValue constant = node.expression.value; | 142 return buildConstant(node.expression.value); |
| 138 registry.registerCompileTimeConstant(constant); | |
| 139 return glue.constantReference(constant); | |
| 140 } | 143 } |
| 141 | 144 |
| 142 @override | 145 @override |
| 143 js.Expression visitFunctionExpression(tree_ir.FunctionExpression node) { | 146 js.Expression visitFunctionExpression(tree_ir.FunctionExpression node) { |
| 144 return giveup(node); | 147 return giveup(node); |
| 145 // TODO: implement visitFunctionExpression | 148 // TODO: implement visitFunctionExpression |
| 146 } | 149 } |
| 147 | 150 |
| 148 @override | 151 @override |
| 149 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) { | 152 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) { |
| 150 return giveup(node); | 153 return giveup(node); |
| 151 // TODO: implement visitInvokeConstructor | 154 // TODO: implement visitInvokeConstructor |
| 152 } | 155 } |
| 153 | 156 |
| 154 @override | 157 @override |
| 155 js.Expression visitInvokeMethod(tree_ir.InvokeMethod node) { | 158 js.Expression visitInvokeMethod(tree_ir.InvokeMethod node) { |
| 156 return giveup(node); | 159 return giveup(node); |
| 157 // TODO: implement visitInvokeMethod | 160 // TODO: implement visitInvokeMethod |
| 158 } | 161 } |
| 159 | 162 |
| 160 @override | 163 @override |
| 161 js.Expression visitInvokeStatic(tree_ir.InvokeStatic node) { | 164 js.Expression visitInvokeStatic(tree_ir.InvokeStatic node) { |
| 162 Element element = node.target; | 165 Element element = node.target; |
| 163 | 166 |
| 164 registry.registerStaticInvocation(element); | 167 registry.registerStaticInvocation(element); |
| 165 | 168 |
| 169 compileConstant(ParameterElement parameter) { | |
|
floitsch
2014/11/20 13:14:43
Add return type.
sigurdm
2014/11/21 09:52:53
Done.
| |
| 170 return buildConstant(glue.getConstantForVariable(parameter).value); | |
| 171 } | |
| 172 | |
| 166 js.Expression elementAccess = glue.elementAccess(node.target); | 173 js.Expression elementAccess = glue.elementAccess(node.target); |
| 167 return new js.Call(elementAccess, visitArguments(node.arguments)); | 174 List<js.Expression> arguments = |
| 175 node.selector.makeArgumentsList2(node.arguments, element, | |
| 176 visitExpression, | |
| 177 compileConstant); | |
| 178 return new js.Call(elementAccess, arguments); | |
| 168 } | 179 } |
| 169 | 180 |
| 170 @override | 181 @override |
| 171 js.Expression visitInvokeSuperMethod(tree_ir.InvokeSuperMethod node) { | 182 js.Expression visitInvokeSuperMethod(tree_ir.InvokeSuperMethod node) { |
| 172 return giveup(node); | 183 return giveup(node); |
| 173 // TODO: implement visitInvokeSuperMethod | 184 // TODO: implement visitInvokeSuperMethod |
| 174 } | 185 } |
| 175 | 186 |
| 176 @override | 187 @override |
| 177 js.Expression visitLiteralList(tree_ir.LiteralList node) { | 188 js.Expression visitLiteralList(tree_ir.LiteralList node) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 } | 297 } |
| 287 | 298 |
| 288 @override | 299 @override |
| 289 void visitReturn(tree_ir.Return node) { | 300 void visitReturn(tree_ir.Return node) { |
| 290 accumulator.add(new js.Return(visitExpression(node.value))); | 301 accumulator.add(new js.Return(visitExpression(node.value))); |
| 291 } | 302 } |
| 292 | 303 |
| 293 bool isNullLiteral(js.Expression exp) => exp is js.LiteralNull; | 304 bool isNullLiteral(js.Expression exp) => exp is js.LiteralNull; |
| 294 | 305 |
| 295 } | 306 } |
| OLD | NEW |