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

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

Issue 862703002: Implement constructor bodies and initializers in CPS->JS backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix test case Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
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 23dcd7db16b50e09b4c50ad539513660f00414f2..3458da284c62e4c839308207b2ad3e3d766b6ccc 100644
--- a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
@@ -216,6 +216,14 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> {
@override
js.Expression visitInvokeMethodDirectly(tree_ir.InvokeMethodDirectly node) {
registry.registerDirectInvocation(node.target.declaration);
+ if (node.target is ConstructorBodyElement) {
+ // Constructor body cannot be overriden or intercepted, so we can
floitsch 2015/01/21 16:29:35 A constructor ...
asgerf 2015/01/22 10:18:58 Done.
+ // use the short form for this invocation.
floitsch 2015/01/21 16:29:35 or not ;)
asgerf 2015/01/22 10:18:58 Inserted a TODO. Will update after the fix lands.
+ return js.js('#.#(#)',
+ [visitExpression(node.receiver),
+ glue.instanceMethodName(node.target),
+ visitArguments(node.arguments)]);
+ }
return js.js('#.#.call(#, #)',
[glue.prototypeAccess(node.target.enclosingClass),
glue.invocationName(node.selector),
@@ -435,9 +443,9 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> {
}
@override
- js.Expression visitCreateClosureClass(tree_ir.CreateClosureClass node) {
+ js.Expression visitCreateInstance(tree_ir.CreateInstance node) {
registry.registerInstantiatedClass(node.classElement);
- return new js.New(glue.closureClassConstructorAccess(node.classElement),
+ return new js.New(glue.constructorAccess(node.classElement),
node.arguments.map(visitExpression).toList());
}

Powered by Google App Engine
This is Rietveld 408576698