Пример #1
0
        public void Invoke()
        {
            if (invocated)
            {
                throw new NotSupportedException("A invocation context can only be used once");
            }
            invocated = true;
            var cnt = method.HasThis ? method.ParameterCount + 1 : method.ParameterCount;

            if (cnt != paramCnt)
            {
                throw new ArgumentException("Argument count mismatch");
            }
            bool unhandledException;

            if (useRegister)
            {
                esp = intp.ExecuteR(method, esp, out unhandledException);
            }
            else
            {
                esp = intp.Execute(method, esp, out unhandledException);
            }
            esp--;
        }
Пример #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);
        }