Ejemplo n.º 1
0
        public virtual ILLazy Call(string methodName, Type[] genericArgs, ILData[] invokeParams)
        {
            if (((IBuilder)this.Coding).IsBuild)
            {
                throw new CodingException("Metodun tanımlandığı tip derlenmiş. Derlenmiş metotların gövdesi yeniden yazılamaz.");
            }
            if (methodName == null)
            {
                throw new ArgumentNullException("methodName");
            }

            ILLazy push = null;

            Type[]     parameterTypes = ILExtentionUtils.ParametersToTypeList(invokeParams);
            MethodInfo method         = ILExtentionUtils.FindMethod(this.ILType, methodName, parameterTypes, false);

            if (method == null || method.IsStatic)
            {
                throw new MethodNotFoundException("Hedef obje, çağrılan metodu içermiyor veya metot statik.");
            }
            else
            {
                push = new ILLazyInvoke(this.Coding, this, method, genericArgs, invokeParams);
            }

            if (push.ILType == typeof(void))
            {
                ((IILPusher)push).Push();
                return(null);
            }
            else
            {
                return(push);
            }
        }
Ejemplo n.º 2
0
 public ILData Convert(Type to)
 {
     if (((IBuilder)this.Coding).IsBuild)
     {
         throw new CodingException("Metodun tanımlandığı tip derlenmiş. Derlenmiş metotların gövdesi yeniden yazılamaz.");
     }
     else if (this.PinnedState == PinnedState.Null)
     {
         throw new NotSupportedException("Yöntem, ILNull nesnesi için kullanılamaz.");
     }
     else if (to == null)
     {
         throw new ArgumentNullException("to");
     }
     else if (to == this.ILType)
     {
         return(this);
     }
     else if (to == typeof(object))
     {
         return(this.Coding.Box(this));
     }
     else if (ILExtentionUtils.IsPrimitive(this.ILType) && ILExtentionUtils.IsPrimitive(to))
     {
         return(new ILLazyPrimitiveConverter(this.Coding, this, to));
     }
     else if (this.ILType == typeof(object) && to != typeof(object))
     {
         return(this.Coding.Cast(CastOperations.UnboxAny, this, to));
     }
     else if (this.ILType.IsGenericParameter && to.IsGenericParameter && to != this.ILType)
     {
         return(this.Coding.Cast(CastOperations.UnboxAny, this.Coding.Box(this), to));
     }
     else if (this.ILType.IsClass && to.IsClass)
     {
         return(this.Coding.Cast(CastOperations.CastClass, this, to));
     }
     else if (to.IsAssignableFrom(this.ILType))
     {
         if (this.ILType.IsValueType)
         {
             ILLazy boxing   = this.Coding.Box(this);
             ILLazy unboxing = this.Coding.Cast(CastOperations.UnboxAny, boxing, to);
             return(unboxing);
         }
         else
         {
             return(this); //op_Explicit;
         }
     }
     else
     {
         throw new TypeConvertException("İki tip arasında dönüştürücü bulunamadı.");
     }
 }
Ejemplo n.º 3
0
 internal static string Signature(MethodInfo info) //İmzalama hatalı olursa diye yazıldı.
 {
     ParameterInfo[] parameters    = info.GetParameters();
     Type[]          parameterType = new Type[parameters.Length];
     for (int i = 0; i < parameters.Length; i++)
     {
         parameterType[i] = parameters[i].ParameterType;
     }
     return(ILExtentionUtils.Signature(info.Name, parameterType));
 }
Ejemplo n.º 4
0
        public override ILLazy Call(string methodName, Type[] genericArgs, ILData[] invokeParams)
        {
            if (((IBuilder)this.Coding).IsBuild)
            {
                throw new CodingException("Metodun tanımlandığı tip derlenmiş. Derlenmiş metotların gövdesi yeniden yazılamaz.");
            }
            if (methodName == null)
            {
                throw new ArgumentNullException("methodName");
            }

            ILLazy push = null;

            Type[]     parameterTypes = ILExtentionUtils.ParametersToTypeList(invokeParams);
            Type       baseType       = this.Coding.CurrentMethod.ILTypeBuilder.BaseType;
            MethodInfo baseMethod     = ILExtentionUtils.FindMethod(baseType, methodName, parameterTypes, false);

            if (baseMethod == null || baseMethod.IsStatic)
            {
                throw new MethodNotFoundException("Hedef obje, çağrılan metodu içermiyor veya metot statik.");
            }
            else
            {
                if ((baseMethod.Attributes & MethodAttributes.Private) == MethodAttributes.Private)
                {
                    throw new MethodAccessException("Metot, private olarak tanımlanmış. Metoda erişilemiyor.");
                }
                else
                if (baseMethod.IsGenericMethod && (genericArgs == null || genericArgs.Length == 0))
                {
                    throw new ArgumentNullException("genericArgs", "Çağrılan yöntem bir generic tanımlama içeriyor.");
                }
                else
                {
                    push = new ILLazyInvoke(this.Coding, this, baseMethod, genericArgs, invokeParams);
                }
            }
            if (push.ILType == typeof(void))
            {
                ((IILPusher)push).Push();
                return(null);
            }
            else
            {
                return(push);
            }
        }
Ejemplo n.º 5
0
        public override ILLazy Call(string methodName, Type[] genericArgs, ILData[] invokeParams)
        {
            if (((IBuilder)this.Coding).IsBuild)
            {
                throw new CodingException("Metodun tanımlandığı tip derlenmiş. Derlenmiş metotların gövdesi yeniden yazılamaz.");
            }
            if (methodName == null)
            {
                throw new ArgumentNullException("methodName");
            }

            ILLazy push = null;

            Type[]          parameterTypes = ILExtentionUtils.ParametersToTypeList(invokeParams);
            ILMethodBuilder builder        = this.Coding.CurrentMethod.ILTypeBuilder.FindMethod(methodName, parameterTypes);

            if (builder == null)
            {
                return(this.Coding.Base.Call(methodName, genericArgs, invokeParams));
            }
            if (builder.IsStatic)
            {
                throw new MethodNotFoundException("Hedef obje, çağrılan metodu içermiyor veya metot statik.");
            }
            else
            if (builder.IsGeneric && (genericArgs == null || genericArgs.Length == 0))
            {
                throw new ArgumentNullException("genericArgs", "Çağrılan yöntem bir generic tanımlama içeriyor.");
            }
            else
            {
                push = new ILLazyInvoke(this.Coding, this, builder, genericArgs, invokeParams);
            }

            if (push.ILType == typeof(void))
            {
                ((IILPusher)push).Push();
                return(null);
            }
            else
            {
                return(push);
            }
        }