Index: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart |
diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart |
index c4ce556be84ffa6eaae42a0073f37fe993a4cdc9..bf3d984f442002ceb10747d7f0abbaaf38432a2a 100644 |
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart |
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart |
@@ -1334,12 +1334,51 @@ class IrBuilderVisitor extends ast.Visitor<ir.Primitive> |
if (node.isConst) { |
return translateConstant(node); |
} |
+ |
InterfaceType type = elements.getType(node); |
- List<ir.LiteralMapEntry> entries = |
- node.entries.nodes.mapToList((ast.LiteralMapEntry e) { |
- return new ir.LiteralMapEntry(visit(e.key), visit(e.value)); |
- }); |
- return irBuilder.addPrimitive(new ir.LiteralMap(type, entries)); |
+ |
+ if (node.entries.nodes.isEmpty) { |
+ 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.
|
+ return irBuilder.buildStaticFunctionInvocation( |
+ helpers.mapLiteralUntypedEmptyMaker, |
+ <ir.Primitive>[], |
+ sourceInformation: sourceInformationBuilder.buildNew(node)); |
+ } else { |
+ ConstructorElement constructor = helpers.mapLiteralConstructorEmpty; |
+ return irBuilder.buildConstructorInvocation( |
+ constructor.effectiveTarget, |
+ CallStructure.NO_ARGS, |
+ constructor.computeEffectiveTargetType(type), |
+ <ir.Primitive>[], |
+ sourceInformationBuilder.buildNew(node)); |
+ } |
+ } |
+ |
+ List<ir.Primitive> keysAndValues = <ir.Primitive>[]; |
+ for (ast.LiteralMapEntry entry in node.entries.nodes.toList()) { |
+ keysAndValues.add(visit(entry.key)); |
+ keysAndValues.add(visit(entry.value)); |
+ } |
+ ir.Primitive keysAndValuesList = |
+ irBuilder.buildListLiteral(null, keysAndValues); |
+ |
+ if (type.isRaw) { |
+ return irBuilder.buildStaticFunctionInvocation( |
+ helpers.mapLiteralUntypedMaker, |
+ <ir.Primitive>[keysAndValuesList], |
+ sourceInformation: sourceInformationBuilder.buildNew(node)); |
+ } else { |
+ ConstructorElement constructor = helpers.mapLiteralConstructor; |
+ print('constructor = $constructor type = $type' |
+ '\n constructor.effectiveTarget = ${constructor.effectiveTarget}' |
+ '\n constructor.computeEffectiveTargetType(type) = ${constructor.computeEffectiveTargetType(type)}'); |
asgerf
2016/01/22 03:14:20
renegade print
|
+ return irBuilder.buildConstructorInvocation( |
+ constructor.effectiveTarget, |
+ CallStructure.ONE_ARG, |
+ constructor.computeEffectiveTargetType(type), |
+ <ir.Primitive>[keysAndValuesList], |
+ sourceInformationBuilder.buildNew(node)); |
+ } |
} |
ir.Primitive visitLiteralSymbol(ast.LiteralSymbol node) { |