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

Unified Diff: pkg/compiler/lib/src/js_backend/codegen/codegen.dart

Issue 761983002: Support for map literals in cps js emitter (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/codegen/glue.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/codegen/codegen.dart
diff --git a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
index ec9ff8d303853f0cc3b7d224b10b80ae76237691..4a2a76e763f559a6466ff1df829cf5563a469eb5 100644
--- a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
@@ -168,21 +168,23 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> {
js.Expression buildStaticInvoke(Selector selector,
Element target,
- List<tree_ir.Expression> arguments) {
+ List<js.Expression> arguments) {
registry.registerStaticInvocation(target.declaration);
js.Expression elementAccess = glue.elementAccess(target);
List<js.Expression> compiledArguments =
- selector.makeArgumentsList(arguments, target.implementation,
- visitExpression,
- compileConstant);
+ selector.makeArgumentsList(target.implementation,
+ arguments,
+ compileConstant);
return new js.Call(elementAccess, compiledArguments);
}
@override
js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) {
if (node.constant != null) return giveup(node);
- return buildStaticInvoke(node.selector, node.target, node.arguments);
+ return buildStaticInvoke(node.selector,
+ node.target,
+ visitArguments(node.arguments));
}
void registerMethodInvoke(tree_ir.InvokeMethod node) {
@@ -209,7 +211,9 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> {
@override
js.Expression visitInvokeStatic(tree_ir.InvokeStatic node) {
- return buildStaticInvoke(node.selector, node.target, node.arguments);
+ return buildStaticInvoke(node.selector,
+ node.target,
+ visitArguments(node.arguments));
}
@override
@@ -229,8 +233,27 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> {
@override
js.Expression visitLiteralMap(tree_ir.LiteralMap node) {
- return giveup(node);
- // TODO: implement visitLiteralMap
+ ConstructorElement constructor;
+ if (node.entries.isEmpty) {
+ constructor = glue.mapLiteralConstructorEmpty;
+ } else {
+ constructor = glue.mapLiteralConstructor;
+ }
+ List<js.ArrayElement> entries =
+ new List<js.ArrayElement>(2 * node.entries.length);
+ for (int i = 0; i < node.entries.length; i++) {
+ js.Expression key = visitExpression(node.entries[i].key);
+ js.Expression value = visitExpression(node.entries[i].value);
+ entries[2 * i] = new js.ArrayElement(2 * i, key);
+ entries[2 * i + 1] = new js.ArrayElement(2 * i + 1, value);
+ }
+ List<js.Expression> args =
+ <js.Expression>[new js.ArrayInitializer(node.entries.length * 2,
+ entries)];
+ return buildStaticInvoke(
+ new Selector.call(constructor.name, constructor.library, 2),
+ constructor,
+ args);
}
@override
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/codegen/glue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698