private static void BuildOverriddenInitializerCall(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, RubyMemberInfo/*!*/ initializer) {
var instanceExpr = metaBuilder.Result;
metaBuilder.Result = null;
var instanceVariable = metaBuilder.GetTemporary(instanceExpr.Type, "#instance");
// We know an exact type of the new instance and that there is no singleton for that instance.
// We also have the exact method we need to call ("initialize" is a RubyMethodInfo/RubyLambdaMethodInfo).
// => no tests are necessary:
args.SetTarget(instanceVariable, null);
if (initializer is RubyMethodInfo || initializer is RubyLambdaMethodInfo) {
initializer.BuildCallNoFlow(metaBuilder, args, Symbols.Initialize);
} else {
// TODO: we need more refactoring of RubyMethodGroupInfo.BuildCall to be able to inline this:
metaBuilder.Result = AstUtils.LightDynamic(
RubyCallAction.Make(args.RubyContext, "initialize",
new RubyCallSignature(
args.Signature.ArgumentCount,
(args.Signature.Flags & ~RubyCallFlags.IsInteropCall) | RubyCallFlags.HasImplicitSelf
)
),
args.GetCallSiteArguments(instanceVariable)
);
}
if (!metaBuilder.Error) {
// PropagateRetrySingleton(instance = new <type>(), instance.initialize(<args>))
metaBuilder.Result = Methods.PropagateRetrySingleton.OpCall(
Ast.Assign(instanceVariable, instanceExpr),
metaBuilder.Result
);
// we need to handle break, which unwinds to a proc-converter that could be this method's frame:
if (args.Signature.HasBlock) {
metaBuilder.ControlFlowBuilder = RubyMethodInfo.RuleControlFlowBuilder;
}
}
}