Пример #1
0
        unsafe StackObject *ILInvokeSub(ILIntepreter intp, StackObject *esp, IList <object> mStack)
        {
            var  ebp = esp;
            bool unhandled;

            if (method.HasThis)
            {
                esp = ILIntepreter.PushObject(esp, mStack, instance);
            }
            int paramCnt = method.ParameterCount;

            for (int i = paramCnt; i > 0; i--)
            {
                intp.CopyToStack(esp, Minus(ebp, i), mStack);
                esp++;
            }
            var ret = intp.Execute(method, esp, out unhandled);

            if (next != null)
            {
                if (method.ReturnType != appdomain.VoidType)
                {
                    intp.Free(ret - 1);//Return value for multicast delegate doesn't make sense, only return the last one's value
                }
                DelegateAdapter n = (DelegateAdapter)next;
                ret = n.ILInvokeSub(intp, ebp, mStack);
            }
            return(ret);
        }
Пример #2
0
        unsafe StackObject *ILInvokeSub(ILIntepreter intp, StackObject *esp, IList <object> mStack)
        {
            var  ebp = esp;
            bool unhandled;

            if (method.HasThis)
            {
                esp = ILIntepreter.PushObject(esp, mStack, instance);
            }
            int paramCnt = method.ParameterCount;

            if (method.IsExtend && instance != null)
            {
                esp = ILIntepreter.PushObject(esp, mStack, instance);
                paramCnt--;
            }
            bool useRegister = method.ShouldUseRegisterVM;

            for (int i = paramCnt; i > 0; i--)
            {
                intp.CopyToStack(esp, Minus(ebp, i), mStack);
                if (esp->ObjectType < ObjectTypes.Object && useRegister)
                {
                    mStack.Add(null);
                }
                esp++;
            }
            StackObject *ret;

            if (useRegister)
            {
                ret = intp.ExecuteR(method, esp, out unhandled);
            }
            else
            {
                ret = intp.Execute(method, esp, out unhandled);
            }
            if (next != null)
            {
                if (method.ReturnType != appdomain.VoidType)
                {
                    intp.Free(ret - 1);//Return value for multicast delegate doesn't make sense, only return the last one's value
                }
                DelegateAdapter n = (DelegateAdapter)next;
                ret = n.ILInvokeSub(intp, ebp, mStack);
            }
            return(ret);
        }