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

Side by Side Diff: pkg/analyzer2dart/lib/src/cps_generator.dart

Issue 658103003: Support map and list literals in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 months 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 analyzer2dart.cps_generator; 5 library analyzer2dart.cps_generator;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 8
9 import 'package:compiler/implementation/dart_types.dart' as dart2js;
9 import 'package:compiler/implementation/elements/elements.dart' as dart2js; 10 import 'package:compiler/implementation/elements/elements.dart' as dart2js;
10 import 'package:analyzer/src/generated/source.dart'; 11 import 'package:analyzer/src/generated/source.dart';
11 import 'package:analyzer/src/generated/element.dart' as analyzer; 12 import 'package:analyzer/src/generated/element.dart' as analyzer;
12 13
13 import 'package:compiler/implementation/dart2jslib.dart' 14 import 'package:compiler/implementation/dart2jslib.dart'
14 show DART_CONSTANT_SYSTEM; 15 show DART_CONSTANT_SYSTEM;
15 import 'package:compiler/implementation/cps_ir/cps_ir_nodes.dart' as ir; 16 import 'package:compiler/implementation/cps_ir/cps_ir_nodes.dart' as ir;
16 import 'package:compiler/implementation/cps_ir/cps_ir_builder.dart'; 17 import 'package:compiler/implementation/cps_ir/cps_ir_builder.dart';
17 import 'package:compiler/implementation/universe/universe.dart'; 18 import 'package:compiler/implementation/universe/universe.dart';
18 19
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 subbuild(node.elseExpression)); 224 subbuild(node.elseExpression));
224 } 225 }
225 226
226 @override 227 @override
227 visitIfStatement(IfStatement node) { 228 visitIfStatement(IfStatement node) {
228 irBuilder.buildIf( 229 irBuilder.buildIf(
229 build(node.condition), 230 build(node.condition),
230 subbuild(node.thenStatement), 231 subbuild(node.thenStatement),
231 subbuild(node.elseStatement)); 232 subbuild(node.elseStatement));
232 } 233 }
234
235 @override
236 ir.Node visitListLiteral(ListLiteral node) {
237 dart2js.InterfaceType type = converter.convertType(node.staticType);
238 // TODO(johnniwinther): Use `build` instead of `(e) => build(e)` when issue
239 // 18630 has been resolved.
240 Iterable<ir.Primitive> values = node.elements.map((e) => build(e));
241 return irBuilder.buildListLiteral(type, values);
242 }
243
244 @override
245 ir.Node visitMapLiteral(MapLiteral node) {
246 dart2js.InterfaceType type = converter.convertType(node.staticType);
247 Iterable<ir.Primitive> keys =
248 node.entries.map((MapLiteralEntry entry) => build(entry.key));
249 Iterable<ir.Primitive> values =
250 node.entries.map((MapLiteralEntry entry) => build(entry.value));
251 return irBuilder.buildMapLiteral(type, keys, values);
252 }
233 } 253 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer2dart/test/end2end_test.dart » ('j') | pkg/analyzer2dart/test/end2end_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698