Beispiel #1
0
        public void Return(IILValue value, params IILValue[] Parameters)
        {
            Type returnType = this.ddmethod.ReturnType;
            Type valueType  = value.ValueType;

            value.LdValue();

            convert(returnType, valueType);

            this.IL.Emit(OpCodes.Ret);
        }
Beispiel #2
0
        //将当前属性的值,推送到堆栈
        /// <summary>
        /// 将当前属性的值,推送到堆栈
        /// </summary>
        public override void LdValue()
        {
            if (this.obj.IsStatic)
            {
            }
            else
            {
                target.LdValue();
            }

            Ld();
        }
Beispiel #3
0
        public override LocalBuilder Call(IILValue array)
        {
            MethodInfo methodInfo = ((MethodInfo)obj);

            ParameterInfo[] paraInfos = methodInfo.GetParameters();
            LocalBuilder[]  paras     = new LocalBuilder[paraInfos.Length];

            Type elementType = array.ValueType.GetElementType();

            for (int i = 0; i < paraInfos.Length; i++)
            {
                paras[i] = this.il.DeclareLocal(paraInfos[i].ParameterType);
                array.LdValue();
                this.il.Emit(OpCodes.Ldc_I4, i);
                this.il.Emit(OpCodes.Ldelem_Ref);
                base.convert(paraInfos[i].ParameterType, elementType);
                this.il.Emit(OpCodes.Stloc, paras[i]);
            }

            if (methodInfo.IsStatic)
            {
                this.il.Emit(OpCodes.Ldnull);
            }
            else
            {
                this.target.LdValue();
            }

            for (int i = 0; i < paraInfos.Length; i++)
            {
                this.il.Emit(OpCodes.Ldloc, paras[i]);
            }

            LocalBuilder returnLocal = null;

            this.il.Emit(OpCodes.Call, methodInfo);

            if (methodInfo.ReturnType == typeof(void))
            {
            }
            else
            {
                returnLocal = il.DeclareLocal(methodInfo.ReturnType);
                this.il.Emit(OpCodes.Stloc, returnLocal);
            }
            return(returnLocal);
        }