Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: pkg/compiler/lib/src/js_backend/codegen/codegen.dart

Issue 743973002: Add list literals in js cps codegen. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/codegen/glue.dart » ('j') | tests/compiler/dart2js/js_backend_cps_ir_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698