Index: pkg/compiler/lib/src/ssa/graph_builder.dart |
diff --git a/pkg/compiler/lib/src/ssa/graph_builder.dart b/pkg/compiler/lib/src/ssa/graph_builder.dart |
index 7f112300128be9a7242f31585426ada8f9e9858f..abb3169270a4723c606f2f0f37a601c2d6bb45df 100644 |
--- a/pkg/compiler/lib/src/ssa/graph_builder.dart |
+++ b/pkg/compiler/lib/src/ssa/graph_builder.dart |
@@ -215,6 +215,47 @@ abstract class GraphBuilder { |
localsHandler.directLocals[local] != null; |
} |
+ HInstruction callSetRuntimeTypeInfoWithTypeArguments( |
+ DartType type, List<HInstruction> rtiInputs, HInstruction newObject) { |
+ if (!backend.classNeedsRti(type.element)) { |
+ return newObject; |
+ } |
+ |
+ HInstruction typeInfo = new HTypeInfoExpression( |
+ TypeInfoExpressionKind.INSTANCE, |
+ (type.element as ClassElement).thisType, |
+ rtiInputs, |
+ backend.dynamicType); |
+ add(typeInfo); |
+ return callSetRuntimeTypeInfo(typeInfo, newObject); |
+ } |
+ |
+ HInstruction callSetRuntimeTypeInfo( |
+ HInstruction typeInfo, HInstruction newObject) { |
+ // Set the runtime type information on the object. |
+ Element typeInfoSetterElement = backend.helpers.setRuntimeTypeInfo; |
+ pushInvokeStatic(typeInfoSetterElement, <HInstruction>[newObject, typeInfo], |
+ typeMask: backend.dynamicType, |
+ sourceInformation: newObject.sourceInformation); |
+ |
+ // The new object will now be referenced through the |
+ // `setRuntimeTypeInfo` call. We therefore set the type of that |
+ // instruction to be of the object's type. |
+ assert(invariant(CURRENT_ELEMENT_SPANNABLE, |
+ stack.last is HInvokeStatic || stack.last == newObject, |
+ message: "Unexpected `stack.last`: Found ${stack.last}, " |
+ "expected ${newObject} or an HInvokeStatic. " |
+ "State: typeInfo=$typeInfo, stack=$stack.")); |
+ stack.last.instructionType = newObject.instructionType; |
+ return pop(); |
+ } |
+ |
+ void pushInvokeStatic(MethodElement element, List<HInstruction> arguments, |
+ {TypeMask typeMask, |
+ InterfaceType instanceType, |
+ SourceInformation sourceInformation, |
+ ast.Node location}); |
+ |
/// The element for which this SSA builder is being used. |
Element get targetElement; |
TypeBuilder get typeBuilder; |