Ejemplo n.º 1
0
        internal static void InvokeMemberAction(ref CallSite callsite,
                                                Type binderType,
                                                int knownType,
                                                LazyBinder binder,
                                                String_OR_InvokeMemberName name,
                                                bool staticContext,
                                                Type context,
                                                string[] argNames,
                                                object target,
                                                params object[] args)
        {
            var tSwitch = args.Length;

            switch (tSwitch)
            {
                #region Optimizations
            case 0:
            {
                var tCallSite = (CallSite <Action <CallSite, object> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Action <CallSite, object> >(binderType, knownType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                tCallSite.Target(tCallSite, target);
                break;
            }

            case 1:
            {
                var tCallSite = (CallSite <Action <CallSite, object, object> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Action <CallSite, object, object> >(binderType, knownType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                tCallSite.Target(tCallSite, target, args[0]);
                break;
            }

            case 2:
            {
                var tCallSite = (CallSite <Action <CallSite, object, object, object> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Action <CallSite, object, object, object> >(binderType, knownType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                tCallSite.Target(tCallSite, target, args[0], args[1]);
                break;
            }

            case 3:
            {
                var tCallSite = (CallSite <Action <CallSite, object, object, object, object> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Action <CallSite, object, object, object, object> >(binderType, knownType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                tCallSite.Target(tCallSite, target, args[0], args[1], args[2]);
                break;
            }

            case 4:
            {
                var tCallSite = (CallSite <Action <CallSite, object, object, object, object, object> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Action <CallSite, object, object, object, object, object> >(binderType, knownType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3]);
                break;
            }

            case 5:
            {
                var tCallSite = (CallSite <Action <CallSite, object, object, object, object, object, object> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Action <CallSite, object, object, object, object, object, object> >(binderType, knownType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4]);
                break;
            }

            case 6:
            {
                var tCallSite = (CallSite <Action <CallSite, object, object, object, object, object, object, object> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Action <CallSite, object, object, object, object, object, object, object> >(binderType, knownType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4], args[5]);
                break;
            }

            case 7:
            {
                var tCallSite = (CallSite <Action <CallSite, object, object, object, object, object, object, object, object> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Action <CallSite, object, object, object, object, object, object, object, object> >(binderType, knownType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
                break;
            }

            case 8:
            {
                var tCallSite = (CallSite <Action <CallSite, object, object, object, object, object, object, object, object, object> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Action <CallSite, object, object, object, object, object, object, object, object, object> >(binderType, knownType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
                break;
            }

            case 9:
            {
                var tCallSite = (CallSite <Action <CallSite, object, object, object, object, object, object, object, object, object, object> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Action <CallSite, object, object, object, object, object, object, object, object, object, object> >(binderType, knownType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
                break;
            }

            case 10:
            {
                var tCallSite = (CallSite <Action <CallSite, object, object, object, object, object, object, object, object, object, object, object> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Action <CallSite, object, object, object, object, object, object, object, object, object, object, object> >(binderType, knownType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]);
                break;
            }

            case 11:
            {
                var tCallSite = (CallSite <Action <CallSite, object, object, object, object, object, object, object, object, object, object, object, object> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Action <CallSite, object, object, object, object, object, object, object, object, object, object, object, object> >(binderType, knownType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10]);
                break;
            }

            case 12:
            {
                var tCallSite = (CallSite <Action <CallSite, object, object, object, object, object, object, object, object, object, object, object, object, object> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Action <CallSite, object, object, object, object, object, object, object, object, object, object, object, object, object> >(binderType, knownType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11]);
                break;
            }

            case 13:
            {
                var tCallSite = (CallSite <Action <CallSite, object, object, object, object, object, object, object, object, object, object, object, object, object, object> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Action <CallSite, object, object, object, object, object, object, object, object, object, object, object, object, object, object> >(binderType, knownType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11], args[12]);
                break;
            }

            case 14:
            {
                var tCallSite = (CallSite <Action <CallSite, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Action <CallSite, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object> >(binderType, knownType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11], args[12], args[13]);
                break;
            }

                #endregion
            default:
                var tArgTypes     = Enumerable.Repeat(typeof(object), tSwitch);
                var tDelagateType = BuildProxy.GenerateCallSiteFuncType(tArgTypes, typeof(void));
                Impromptu.InvokeCallSite(CreateCallSite(tDelagateType, binderType, knownType, binder, name, context, argNames), target, args);
                break;
            }
        }
Ejemplo n.º 2
0
        internal static TReturn InvokeMemberTargetType <TTarget, TReturn>(
            ref CallSite callsite,
            Type binderType,
            LazyBinder binder,
            String_OR_InvokeMemberName name,
            bool staticContext,
            Type context,
            string[] argNames,
            TTarget target, params object[] args)
        {
            var tSwitch = args.Length;

            switch (tSwitch)
            {
            case 0: {
                var tCallSite = (CallSite <Func <CallSite, TTarget, TReturn> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Func <CallSite, TTarget, TReturn> >(binderType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                return(tCallSite.Target(tCallSite, target));
            }

            case 1: {
                var tCallSite = (CallSite <Func <CallSite, TTarget, object, TReturn> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Func <CallSite, TTarget, object, TReturn> >(binderType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                return(tCallSite.Target(tCallSite, target, args[0]));
            }

            case 2: {
                var tCallSite = (CallSite <Func <CallSite, TTarget, object, object, TReturn> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Func <CallSite, TTarget, object, object, TReturn> >(binderType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                return(tCallSite.Target(tCallSite, target, args[0], args[1]));
            }

            case 3: {
                var tCallSite = (CallSite <Func <CallSite, TTarget, object, object, object, TReturn> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Func <CallSite, TTarget, object, object, object, TReturn> >(binderType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                return(tCallSite.Target(tCallSite, target, args[0], args[1], args[2]));
            }

            case 4: {
                var tCallSite = (CallSite <Func <CallSite, TTarget, object, object, object, object, TReturn> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Func <CallSite, TTarget, object, object, object, object, TReturn> >(binderType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                return(tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3]));
            }

            case 5: {
                var tCallSite = (CallSite <Func <CallSite, TTarget, object, object, object, object, object, TReturn> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Func <CallSite, TTarget, object, object, object, object, object, TReturn> >(binderType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                return(tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4]));
            }

            case 6: {
                var tCallSite = (CallSite <Func <CallSite, TTarget, object, object, object, object, object, object, TReturn> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Func <CallSite, TTarget, object, object, object, object, object, object, TReturn> >(binderType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                return(tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4], args[5]));
            }

            case 7: {
                var tCallSite = (CallSite <Func <CallSite, TTarget, object, object, object, object, object, object, object, TReturn> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Func <CallSite, TTarget, object, object, object, object, object, object, object, TReturn> >(binderType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                return(tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4], args[5], args[6]));
            }

            case 8: {
                var tCallSite = (CallSite <Func <CallSite, TTarget, object, object, object, object, object, object, object, object, TReturn> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Func <CallSite, TTarget, object, object, object, object, object, object, object, object, TReturn> >(binderType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                return(tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]));
            }

            case 9: {
                var tCallSite = (CallSite <Func <CallSite, TTarget, object, object, object, object, object, object, object, object, object, TReturn> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Func <CallSite, TTarget, object, object, object, object, object, object, object, object, object, TReturn> >(binderType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                return(tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]));
            }

            case 10: {
                var tCallSite = (CallSite <Func <CallSite, TTarget, object, object, object, object, object, object, object, object, object, object, TReturn> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Func <CallSite, TTarget, object, object, object, object, object, object, object, object, object, object, TReturn> >(binderType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                return(tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]));
            }

            case 11: {
                var tCallSite = (CallSite <Func <CallSite, TTarget, object, object, object, object, object, object, object, object, object, object, object, TReturn> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Func <CallSite, TTarget, object, object, object, object, object, object, object, object, object, object, object, TReturn> >(binderType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                return(tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10]));
            }

            case 12: {
                var tCallSite = (CallSite <Func <CallSite, TTarget, object, object, object, object, object, object, object, object, object, object, object, object, TReturn> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Func <CallSite, TTarget, object, object, object, object, object, object, object, object, object, object, object, object, TReturn> >(binderType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                return(tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11]));
            }

            case 13: {
                var tCallSite = (CallSite <Func <CallSite, TTarget, object, object, object, object, object, object, object, object, object, object, object, object, object, TReturn> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Func <CallSite, TTarget, object, object, object, object, object, object, object, object, object, object, object, object, object, TReturn> >(binderType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                return(tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11], args[12]));
            }

            case 14: {
                var tCallSite = (CallSite <Func <CallSite, TTarget, object, object, object, object, object, object, object, object, object, object, object, object, object, object, TReturn> >)callsite;
                if (tCallSite == null)
                {
                    tCallSite = CreateCallSite <Func <CallSite, TTarget, object, object, object, object, object, object, object, object, object, object, object, object, object, object, TReturn> >(binderType, binder, name, context, argNames, staticContext);
                    callsite  = tCallSite;
                }
                return(tCallSite.Target(tCallSite, target, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11], args[12], args[13]));
            }

            default:
                var tArgTypes     = Enumerable.Repeat(typeof(object), tSwitch);
                var tDelagateType = BuildProxy.GenerateCallSiteFuncType(tArgTypes, typeof(TTarget));
                return(Impromptu.InvokeCallSite(CreateCallSite(tDelagateType, binderType, binder, name, context, argNames), target, args));
            }
        }