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); } }
public void While(ILLazy comparer) { this.Comparer = comparer; ((IILPusher)comparer).Push(); this.Generator.Emit(OpCodes.Brtrue_S, base.BeginLabel); this.Generator.MarkLabel(base.EndLabel); this._isEnd = true; }
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ı."); } }
internal ILForeach(ILCoder coding, ILVariable enumerable) : base(coding) { this._current = coding.Null.ToLocal(); this._enumerator = enumerable.Invoke(ILForeach.getEnumerator, null, null).ToLocal(); this._currentProp = this._enumerator.GetProperty("Current"); this._moveNext = this._enumerator.Invoke(ILForeach.moveNext, null, null); this._innerWhile = coding.While(this._moveNext); this.Item.AssignFrom(this._currentProp.Get()); }
internal ILFor(ILCoder coding, ILLocal i, ILLazy comparer, ILLazy operating) : base(coding, comparer) { if (comparer.ILType == typeof(bool)) { this.I = i; this.Comparer = comparer; this._operator = operating; } else { throw new InvalidOperationException("Comparer type must be Boolean."); } }
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); } }
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); } }
public ILLazy Invoke(MethodInfo method, 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 (this.PinnedState == ILEmitter.PinnedState.Base) { throw new NotSupportedException("Bu metot base işaretçisi tarafından desteklenmiyor. This işaretçisi kullanılmalı."); } if (method == null) { throw new ArgumentNullException("method"); } if (method.GetType() != MethodBase.GetCurrentMethod().GetType()) { throw new ArgumentException("Çağrılan metot tutucusunun türü System.RuntimeMethod tipinde olmalı."); } if (method.IsGenericMethod && (genericArgs == null || genericArgs.Length == 0)) { throw new ArgumentNullException("genericArgs", "Çağrılan yöntem bir generic tanımlama içeriyor."); } ILLazy push = null; if (method.IsStatic) { throw new CodingException("Çağrılan metot statik olmamalı."); } else { push = new ILLazyInvoke(this.Coding, this, method, genericArgs, invokeParams); } if (push.ILType == typeof(void)) { ((IILPusher)push).Push(); return(null); } else { return(push); } }
internal ILWhile(ILCoder coding, ILLazy comparer) { this.Coding = coding; this.Generator = coding.Generator; this.Comparer = comparer; if (comparer.ILType == typeof(bool)) { this.BeginLabel = this.Coding.DefineLabel(); this.EndLabel = this.Coding.DefineLabel(); this.Generator.MarkLabel(this.BeginLabel); ((IILPusher)this.Comparer).Push(); this.Generator.Emit(OpCodes.Brfalse_S, this.EndLabel); } else { throw new InvalidOperationException("Comparer type must be Boolean."); } }