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

Unified Diff: lib/compiler/implementation/ssa/builder.dart

Issue 10905234: Fix for issue 4921: ad the generic type info to a List when we create it. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/ssa/builder.dart
===================================================================
--- lib/compiler/implementation/ssa/builder.dart (revision 12240)
+++ lib/compiler/implementation/ssa/builder.dart (working copy)
@@ -1233,22 +1233,11 @@
// If the class has type variables, create the runtime type
// information with the type parameters provided.
if (!classElement.typeVariables.isEmpty()) {
- List<String> typeVariables = <String>[];
List<HInstruction> rtiInputs = <HInstruction>[];
classElement.typeVariables.forEach((TypeVariableType typeVariable) {
- typeVariables.add("'$typeVariable': #");
rtiInputs.add(localsHandler.directLocals[typeVariable.element]);
});
- String jsCode = '{ ${Strings.join(typeVariables, ', ')} }';
- HInstruction typeInfo = new HForeign(new LiteralDartString(jsCode),
- new LiteralDartString('Object'),
- rtiInputs);
- add(typeInfo);
- Element typeInfoSetterElement = interceptors.getSetRuntimeTypeInfo();
- HInstruction typeInfoSetter = new HStatic(typeInfoSetterElement);
- add(typeInfoSetter);
- add(new HInvokeStatic(
- <HInstruction>[typeInfoSetter, newObject, typeInfo]));
+ callSetRuntimeTypeInfo(classElement, rtiInputs, newObject);
}
// Generate calls to the constructor bodies.
@@ -2627,10 +2616,42 @@
}
}
+ void handleListConstructor(InterfaceType type,
+ Node currentNode,
+ HInstruction newObject) {
+ if (type.arguments.isEmpty()) return;
+ List<HInstruction> inputs = <HInstruction>[];
+ type.arguments.forEach((DartType argument) {
+ inputs.add(analyzeTypeArgument(argument, currentNode));
+ });
+ callSetRuntimeTypeInfo(type.element, inputs, newObject);
+ }
+
+ void callSetRuntimeTypeInfo(ClassElement element,
+ List<HInstruction> inputs,
+ HInstruction newObject) {
+ List<String> typeVariables = <String>[];
+ element.typeVariables.forEach((TypeVariableType typeVariable) {
+ typeVariables.add("'$typeVariable': #");
+ });
+
+ String jsCode = '{ ${Strings.join(typeVariables, ', ')} }';
+ HInstruction typeInfo = new HForeign(new LiteralDartString(jsCode),
+ new LiteralDartString('Object'),
+ inputs);
+ add(typeInfo);
+ Element typeInfoSetterElement = interceptors.getSetRuntimeTypeInfo();
+ HInstruction typeInfoSetter = new HStatic(typeInfoSetterElement);
+ add(typeInfoSetter);
+ add(new HInvokeStatic(<HInstruction>[typeInfoSetter, newObject, typeInfo]));
+ }
+
visitNewSend(Send node) {
+ bool isListConstructor = false;
computeType(element) {
Element originalElement = elements[node];
if (originalElement.getEnclosingClass() === compiler.listClass) {
+ isListConstructor = true;
if (node.arguments.isEmpty()) {
return HType.EXTENDABLE_ARRAY;
} else {
@@ -2675,6 +2696,14 @@
HType elementType = computeType(constructor);
HInstruction newInstance = new HInvokeStatic(inputs, elementType);
pushWithPosition(newInstance, node);
+
+ // The List constructor forwards to a Dart static method that does
+ // not know about the type argument. Therefore we special case
+ // this constructor to have the setRuntimeTypeInfo called where
+ // the 'new' is done.
+ if (isListConstructor) {
+ handleListConstructor(type, node, newInstance);
+ }
}
visitStaticSend(Send node) {
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698