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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 } | 168 } |
| 169 | 169 |
| 170 @override | 170 @override |
| 171 js.Expression visitInvokeSuperMethod(tree_ir.InvokeSuperMethod node) { | 171 js.Expression visitInvokeSuperMethod(tree_ir.InvokeSuperMethod node) { |
| 172 return giveup(node); | 172 return giveup(node); |
| 173 // TODO: implement visitInvokeSuperMethod | 173 // TODO: implement visitInvokeSuperMethod |
| 174 } | 174 } |
| 175 | 175 |
| 176 @override | 176 @override |
| 177 js.Expression visitLiteralList(tree_ir.LiteralList node) { | 177 js.Expression visitLiteralList(tree_ir.LiteralList node) { |
| 178 return giveup(node); | 178 registry.registerInstantiatedClass(glue.listClass); |
| 179 // TODO: implement visitLiteralList | 179 return generateArrayLiteral(node); |
| 180 } | |
| 181 | |
| 182 js.ArrayInitializer generateArrayLiteral(tree_ir.LiteralList node) { | |
|
karlklose
2014/11/20 12:31:18
Do you intend to share this method? Otherwise I wo
sigurdm
2014/11/20 13:32:44
Done.
| |
| 183 int length = node.values.length; | |
| 184 List<js.ArrayElement> entries = new List<js.ArrayElement>(); | |
|
karlklose
2014/11/20 12:31:18
How about:
... entries = new List<js.ArrayElemen
sigurdm
2014/11/20 13:32:45
I almost wrote that, but in the end thought that t
| |
| 185 for (int i = 0; i < length; i++) { | |
| 186 entries.add(new js.ArrayElement(i, visitExpression(node.values[i]))); | |
| 187 } | |
| 188 return new js.ArrayInitializer(length, entries); | |
| 180 } | 189 } |
| 181 | 190 |
| 182 @override | 191 @override |
| 183 js.Expression visitLiteralMap(tree_ir.LiteralMap node) { | 192 js.Expression visitLiteralMap(tree_ir.LiteralMap node) { |
| 184 return giveup(node); | 193 return giveup(node); |
| 185 // TODO: implement visitLiteralMap | 194 // TODO: implement visitLiteralMap |
| 186 } | 195 } |
| 187 | 196 |
| 188 @override | 197 @override |
| 189 js.Expression visitLogicalOperator(tree_ir.LogicalOperator node) { | 198 js.Expression visitLogicalOperator(tree_ir.LogicalOperator node) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 } | 295 } |
| 287 | 296 |
| 288 @override | 297 @override |
| 289 void visitReturn(tree_ir.Return node) { | 298 void visitReturn(tree_ir.Return node) { |
| 290 accumulator.add(new js.Return(visitExpression(node.value))); | 299 accumulator.add(new js.Return(visitExpression(node.value))); |
| 291 } | 300 } |
| 292 | 301 |
| 293 bool isNullLiteral(js.Expression exp) => exp is js.LiteralNull; | 302 bool isNullLiteral(js.Expression exp) => exp is js.LiteralNull; |
| 294 | 303 |
| 295 } | 304 } |
| OLD | NEW |