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

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

Issue 1011403003: cps-ir: Set runtime type information for new objects that require it. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add parameter for each type variable to the JS-factory. Created 5 years, 9 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 f6c7e21608b46c268c89575c9d7531f6141c63e8..6d1d199593a7447fbf31fcb35e0f56239cd480df 100644
--- a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
@@ -206,9 +206,10 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> {
@override
js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) {
checkStaticTargetIsValid(node, node.target);
-
if (node.constant != null) return giveup(node);
- registry.registerInstantiatedClass(node.target.enclosingClass);
+
+ ClassElement instantiatedClass = node.target.enclosingClass;
+ registry.registerInstantiatedClass(instantiatedClass);
Selector selector = node.selector;
FunctionElement target = node.target;
List<js.Expression> arguments = visitArguments(node.arguments);
@@ -501,8 +502,18 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> {
@override
js.Expression visitCreateInstance(tree_ir.CreateInstance node) {
registry.registerInstantiatedClass(node.classElement);
- return new js.New(glue.constructorAccess(node.classElement),
- node.arguments.map(visitExpression).toList());
+ js.Expression instance = new js.New(
+ glue.constructorAccess(node.classElement),
+ node.arguments.map(visitExpression).toList());
+ if (node.typeInformation != null) {
+ FunctionElement helper = glue.getAddRuntimeTypeInformation();
+ js.Expression typeInformation = new js.ArrayInitializer(
+ node.typeInformation.map(visitExpression).toList());
+ return buildStaticHelperInvocation(helper,
+ <js.Expression>[instance, typeInformation]);
+ } else {
+ return instance;
+ }
}
@override
@@ -555,6 +566,12 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> {
}
}
+ @override
+ js.Expression visitTypeExpression(tree_ir.TypeExpression node) {
+ List<js.Expression> arguments =
+ node.arguments.map(visitExpression).toList(growable: false);
+ return glue.generateTypeRepresentation(node.dartType, arguments);
+ }
// Dart-specific IR nodes

Powered by Google App Engine
This is Rietveld 408576698