internal override void BuildCallNoFlow(MetaObjectBuilder /*!*/ metaBuilder, CallArguments /*!*/ args, string /*!*/ name)
{
Assert.NotNull(metaBuilder, args, name);
// 2 implicit args: self, block
var argsBuilder = new ArgsBuilder(2, Parameters.Mandatory.Length, Parameters.LeadingMandatoryCount, Parameters.Optional.Length, Parameters.Unsplat != null);
argsBuilder.SetImplicit(0, AstUtils.Box(args.TargetExpression));
argsBuilder.SetImplicit(1, args.Signature.HasBlock ? AstUtils.Convert(args.GetBlockExpression(), typeof(Proc)) : AstFactory.NullOfProc);
argsBuilder.AddCallArguments(metaBuilder, args);
if (metaBuilder.Error)
{
return;
}
// box explicit arguments:
var boxedArguments = argsBuilder.GetArguments();
for (int i = 2; i < boxedArguments.Length; i++)
{
boxedArguments[i] = AstUtils.Box(boxedArguments[i]);
}
var method = GetDelegate();
if (method.GetType() == ParamsArrayDelegateType)
{
// Func<object, Proc, object[], object>
metaBuilder.Result = AstFactory.CallDelegate(method, new[] {
boxedArguments[0],
boxedArguments[1],
Ast.NewArrayInit(typeof(object), ArrayUtils.ShiftLeft(boxedArguments, 2))
});
}
else
{
metaBuilder.Result = AstFactory.CallDelegate(method, boxedArguments);
}
}