Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart2js.ir_builder_task; | 5 library dart2js.ir_builder_task; |
| 6 | 6 |
| 7 import '../closure.dart' as closure; | 7 import '../closure.dart' as closure; |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../common/names.dart' show | 9 import '../common/names.dart' show |
| 10 Names, | 10 Names, |
| (...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1327 InterfaceType type = elements.getType(node); | 1327 InterfaceType type = elements.getType(node); |
| 1328 return irBuilder.buildListLiteral(type, values, | 1328 return irBuilder.buildListLiteral(type, values, |
| 1329 allocationSiteType: getAllocationSiteType(node)); | 1329 allocationSiteType: getAllocationSiteType(node)); |
| 1330 } | 1330 } |
| 1331 | 1331 |
| 1332 ir.Primitive visitLiteralMap(ast.LiteralMap node) { | 1332 ir.Primitive visitLiteralMap(ast.LiteralMap node) { |
| 1333 assert(irBuilder.isOpen); | 1333 assert(irBuilder.isOpen); |
| 1334 if (node.isConst) { | 1334 if (node.isConst) { |
| 1335 return translateConstant(node); | 1335 return translateConstant(node); |
| 1336 } | 1336 } |
| 1337 | |
| 1337 InterfaceType type = elements.getType(node); | 1338 InterfaceType type = elements.getType(node); |
| 1338 List<ir.LiteralMapEntry> entries = | 1339 |
| 1339 node.entries.nodes.mapToList((ast.LiteralMapEntry e) { | 1340 if (node.entries.nodes.isEmpty) { |
| 1340 return new ir.LiteralMapEntry(visit(e.key), visit(e.value)); | 1341 if (type.isRaw) { |
|
asgerf
2016/01/22 03:14:20
I believe we should use treatAtRaw instead of isRa
sra1
2016/01/22 03:32:04
Done.
| |
| 1341 }); | 1342 return irBuilder.buildStaticFunctionInvocation( |
| 1342 return irBuilder.addPrimitive(new ir.LiteralMap(type, entries)); | 1343 helpers.mapLiteralUntypedEmptyMaker, |
| 1344 <ir.Primitive>[], | |
| 1345 sourceInformation: sourceInformationBuilder.buildNew(node)); | |
| 1346 } else { | |
| 1347 ConstructorElement constructor = helpers.mapLiteralConstructorEmpty; | |
| 1348 return irBuilder.buildConstructorInvocation( | |
| 1349 constructor.effectiveTarget, | |
| 1350 CallStructure.NO_ARGS, | |
| 1351 constructor.computeEffectiveTargetType(type), | |
| 1352 <ir.Primitive>[], | |
| 1353 sourceInformationBuilder.buildNew(node)); | |
| 1354 } | |
| 1355 } | |
| 1356 | |
| 1357 List<ir.Primitive> keysAndValues = <ir.Primitive>[]; | |
| 1358 for (ast.LiteralMapEntry entry in node.entries.nodes.toList()) { | |
| 1359 keysAndValues.add(visit(entry.key)); | |
| 1360 keysAndValues.add(visit(entry.value)); | |
| 1361 } | |
| 1362 ir.Primitive keysAndValuesList = | |
| 1363 irBuilder.buildListLiteral(null, keysAndValues); | |
| 1364 | |
| 1365 if (type.isRaw) { | |
| 1366 return irBuilder.buildStaticFunctionInvocation( | |
| 1367 helpers.mapLiteralUntypedMaker, | |
| 1368 <ir.Primitive>[keysAndValuesList], | |
| 1369 sourceInformation: sourceInformationBuilder.buildNew(node)); | |
| 1370 } else { | |
| 1371 ConstructorElement constructor = helpers.mapLiteralConstructor; | |
| 1372 print('constructor = $constructor type = $type' | |
| 1373 '\n constructor.effectiveTarget = ${constructor.effectiveTarget}' | |
| 1374 '\n constructor.computeEffectiveTargetType(type) = ${constructor.co mputeEffectiveTargetType(type)}'); | |
|
asgerf
2016/01/22 03:14:20
renegade print
| |
| 1375 return irBuilder.buildConstructorInvocation( | |
| 1376 constructor.effectiveTarget, | |
| 1377 CallStructure.ONE_ARG, | |
| 1378 constructor.computeEffectiveTargetType(type), | |
| 1379 <ir.Primitive>[keysAndValuesList], | |
| 1380 sourceInformationBuilder.buildNew(node)); | |
| 1381 } | |
| 1343 } | 1382 } |
| 1344 | 1383 |
| 1345 ir.Primitive visitLiteralSymbol(ast.LiteralSymbol node) { | 1384 ir.Primitive visitLiteralSymbol(ast.LiteralSymbol node) { |
| 1346 assert(irBuilder.isOpen); | 1385 assert(irBuilder.isOpen); |
| 1347 return translateConstant(node); | 1386 return translateConstant(node); |
| 1348 } | 1387 } |
| 1349 | 1388 |
| 1350 ir.Primitive visitParenthesizedExpression( | 1389 ir.Primitive visitParenthesizedExpression( |
| 1351 ast.ParenthesizedExpression node) { | 1390 ast.ParenthesizedExpression node) { |
| 1352 assert(irBuilder.isOpen); | 1391 assert(irBuilder.isOpen); |
| (...skipping 2200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3553 } | 3592 } |
| 3554 | 3593 |
| 3555 Element get closureConverter { | 3594 Element get closureConverter { |
| 3556 return _backend.helpers.closureConverter; | 3595 return _backend.helpers.closureConverter; |
| 3557 } | 3596 } |
| 3558 | 3597 |
| 3559 void addNativeMethod(FunctionElement function) { | 3598 void addNativeMethod(FunctionElement function) { |
| 3560 _backend.emitter.nativeEmitter.nativeMethods.add(function); | 3599 _backend.emitter.nativeEmitter.nativeMethods.add(function); |
| 3561 } | 3600 } |
| 3562 } | 3601 } |
| OLD | NEW |