private Expression CreateCallSite(int argumentCount, string selector, string nativeName, bool isSuperSend, bool isConstantReceiver, string superLookupScope)
        {
            MessageSendBinderDefinition binder = new MessageSendBinderDefinition(selector, nativeName, argumentCount, isSuperSend, isConstantReceiver, superLookupScope);

            Type delegateType = NativeDynamicCallStrategy.GetCallSiteType(argumentCount);
            Type siteType     = typeof(CallSite <>).MakeGenericType(delegateType);

            return(this.CallSiteGenerator.CreateCallSite(binder, delegateType, siteType, selector));
        }
        private Expression CompileDynamicCall(Expression callSite, Expression receiver, Expression executionContext, IEnumerable <Expression> arguments)
        {
            Type delegateType = NativeDynamicCallStrategy.GetCallSiteType(arguments.Count());
            Type siteType     = typeof(CallSite <>).MakeGenericType(delegateType);

            List <Expression> args = new List <Expression>();

            args.Add(callSite);
            args.Add(receiver);
            args.Add(executionContext);
            args.AddRange(arguments);

            FieldInfo  target = TypeUtilities.Field(siteType, "Target", BindingFlags.Instance | BindingFlags.Public);
            MethodInfo invoke = TypeUtilities.Method(delegateType, "Invoke");

            ParameterInfo[] pis = invoke.GetParameters();

            // siteExpr.Target.Invoke(siteExpr, *args)
            return(Expression.Call(
                       Expression.Field(callSite, target),
                       invoke,
                       args));

            /* C# Style
             * ParameterExpression site = Expression.Variable(siteType, "$site");
             * List<Expression> args = new List<Expression>();
             * args.Add(site);
             * args.Add(receiver);
             * args.Add(executionContext);
             * args.AddRange(arguments);
             *
             * FieldInfo target = TypeUtilities.Field(siteType, "Target", BindingFlags.Instance | BindingFlags.Public);
             * MethodInfo invoke = TypeUtilities.Method(delegateType, "Invoke");
             * ParameterInfo[] pis = invoke.GetParameters();
             * // ($site = siteExpr).Target.Invoke($site, *args)
             * return Expression.Block(
             *  new[] { site },
             *  Expression.Call(
             *      Expression.Field(Expression.Assign(site, callSite), target),
             *      invoke,
             *      args));
             */
        }