public ILField CreateField(string fieldName, string targetName) { IILValue target = Builders[targetName]; FieldInfo field = target.ValueType.GetField(fieldName, ALLATTR); return(new ILField(this.IL, field, target)); }
public ILProperty CreateProperty(string propertyName, string targetName) { IILValue target = Builders[targetName]; PropertyInfo property = target.ValueType.GetProperty(propertyName, ALLATTR); return(new ILProperty(this.IL, property, target)); }
public ILMethod CreateMethod(string methodName, string targetName) { IILValue target = Builders[targetName]; MethodInfo method = target.ValueType.GetMethod(methodName, ALLATTR); return(new ILMethod(this.IL, method, target)); }
public ILMethod(ILGenerator il, MethodInfo obj, IILValue target) : base(il, ILType.Property) { base.obj = obj; this.obj = obj; this.target = target; this.valueType = obj.ReturnType; Ld = delegate() { this.il.Emit(OpCodes.Call, (MethodInfo)obj); }; }
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); }
public ILObjectBase[] CreateArray(string arrayName, IILValue array) { throw new Exception("无法活动数组长度是个问题..."); //LocalBuilder args = this.il.DeclareLocal(typeof(object[])); //this.il.Emit(OpCodes.Ldc_I4_1); //this.il.Emit(OpCodes.Newarr, typeof(object)); //this.il.Emit(OpCodes.Stloc, args); //this.il.Emit(OpCodes.Ldloc, args); //this.il.Emit(OpCodes.Ldc_I4_0); //this.il.Emit(OpCodes.Ldloc, arg); //this.il.Emit(OpCodes.Stelem_Ref); }
public ILProperty(ILGenerator il, PropertyInfo obj, IILValue target) : base(il, ILType.Property) { base.obj = obj; this.obj = obj; this.target = target; this.valueType = obj.PropertyType; Ld = delegate() { this.il.Emit(OpCodes.Call, ((PropertyInfo)obj).GetGetMethod()); }; }
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); }
public ILField(ILGenerator il, FieldInfo obj, IILValue target) : base(il, ILType.Property) { base.obj = obj; this.obj = obj; this.target = target; this.valueType = obj.FieldType; if (((FieldInfo)obj).IsStatic) { Ld = delegate() { this.il.Emit(OpCodes.Ldsfld, (FieldInfo)obj); } } ; else { Ld = delegate() { this.il.Emit(OpCodes.Ldfld, (FieldInfo)obj); } }; }
//新建对象实例 /// <summary> /// 新建对象实例 /// </summary> /// <param name="objType">对象类型</param> /// <param name="Parameters">构造函数参数</param> public void New(Type objType, params IILValue[] Parameters) { Type[] argTypes = new Type[Parameters.Length]; LocalBuilder[] argBuilder = new LocalBuilder[Parameters.Length]; for (int i = 0; i < Parameters.Length; i++) { IILValue v = Parameters[i]; argTypes[i] = v.ValueType; argBuilder[i] = v.StValue(); } foreach (LocalBuilder var in argBuilder) { this.il.Emit(OpCodes.Ldloc, var); } this.il.Emit(OpCodes.Newobj, objType.GetConstructor(argTypes)); //this.il.Emit(OpCodes.Stloc, ((LocalBuilder)(p0._arg))); }
public ILProperty CreateProperty(string propertyName, IILValue target) { PropertyInfo property = target.ValueType.GetProperty(propertyName, ALLATTR); return(new ILProperty(this.IL, property, target)); }
public ILMethod CreateMethod(string methodName, IILValue target) { MethodInfo method = target.ValueType.GetMethod(methodName, ALLATTR); return(new ILMethod(this.IL, method, target)); }
public ILMethod CreateMethod(MethodInfo method, IILValue target) { return(new ILMethod(this.IL, method, target)); }
public ILField CreateField(string fieldName, IILValue target) { FieldInfo field = target.ValueType.GetField(fieldName, ALLATTR); return(new ILField(this.IL, field, target)); }
public ILField CreateField(FieldInfo field, IILValue target) { return(new ILField(this.IL, field, target)); }
public virtual LocalBuilder Call(IILValue Parameters) { throw new Exception("当前类不能使用此方法"); }
public ILProperty CreateProperty(PropertyInfo property, IILValue target) { return(new ILProperty(this.IL, property, target)); }