public override void Emit(IEasyMember member, ILGenerator gen) { ArgumentsUtil.EmitLoadOwnerAndReference(this._syncLockSource, gen); //gen.Emit(OpCodes.Call, typeof(Monitor).GetMethod("Enter")); //在2.0中没问题 vs2010 2.0中修改该处 gen.Emit(OpCodes.Call, typeof(Monitor).GetMethod("Enter", new Type[] { typeof(object) })); gen.BeginExceptionBlock(); foreach (Statement statement in this._stmts) { statement.Emit(member, gen); } gen.BeginFinallyBlock(); ArgumentsUtil.EmitLoadOwnerAndReference(this._syncLockSource, gen); gen.Emit(OpCodes.Call, typeof(Monitor).GetMethod("Exit")); gen.EndExceptionBlock(); }
public override void Emit(IEasyMember member, ILGenerator gen) { if (this._reference != null) { ArgumentsUtil.EmitLoadOwnerAndReference(this._reference, gen); } else if (this._expression != null) { this._expression.Emit(member, gen); } else if (member.ReturnType != typeof(void)) { OpCodeUtil.EmitLoadOpCodeForDefaultValueOfType(gen, member.ReturnType); } gen.Emit(OpCodes.Ret); }
/// <summary> /// /// </summary> /// <param name="baseConstructor"></param> /// <returns></returns> protected virtual EasyConstructor GenerateConstructor(ConstructorInfo baseConstructor) { ArrayList list = new ArrayList(); ArgumentReference reference = new ArgumentReference(base.Context.Interceptor); ArgumentReference reference2 = new ArgumentReference(typeof(object[])); list.Add(reference); ParameterInfo[] parameters = baseConstructor.GetParameters(); if (base.Context.HasMixins) { list.Add(reference2); } ArgumentReference[] c = ArgumentsUtil.ConvertToArgumentReference(parameters); list.AddRange(c); EasyConstructor constructor = base.MainTypeBuilder.CreateConstructor((ArgumentReference[])list.ToArray(typeof(ArgumentReference))); this.GenerateConstructorCode(constructor.CodeBuilder, reference, SelfReference.Self, reference2); constructor.CodeBuilder.InvokeBaseConstructor(baseConstructor, c); constructor.CodeBuilder.AddStatement(new ReturnStatement()); return(constructor); }
internal EasyConstructor(AbstractEasyType maintype, params ArgumentReference[] arguments) { this._maintype = maintype; Type[] parameterTypes = ArgumentsUtil.InitializeAndConvert(arguments); this._builder = maintype.TypeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, parameterTypes); }
internal void InvokeBaseConstructor(ConstructorInfo constructor, params ArgumentReference[] arguments) { base.AddStatement(new ExpressionStatement(new ConstructorInvocationExpression(constructor, ArgumentsUtil.ConvertArgumentReferenceToExpression(arguments)))); }
public override void Emit(IEasyMember member, ILGenerator gen) { ArgumentsUtil.EmitLoadOwnerAndReference(this._arrayReference, gen); ArgumentsUtil.EmitLoadOwnerAndReference(this._index, gen); gen.Emit(OpCodes.Ldelem_Ref); }
public EasyRuntimeConstructor(AbstractEasyType maintype, params ArgumentReference[] arguments) { Type[] parameterTypes = ArgumentsUtil.InitializeAndConvert(arguments); base._builder = maintype.TypeBuilder.DefineConstructor(MethodAttributes.SpecialName | MethodAttributes.HideBySig | MethodAttributes.Public, CallingConventions.Standard, parameterTypes); base._builder.SetImplementationFlags(MethodImplAttributes.CodeTypeMask); }
public override void Emit(IEasyMember member, ILGenerator gen) { ArgumentsUtil.EmitLoadOwnerAndReference(this._reference, gen); }
public EasyMethod CreateSetMethod(MethodAttributes attrs, params Type[] parameters) { if (this._setMethod == null) { this._setMethod = new EasyMethod(this._maintype, "set_" + this._builder.Name, attrs, new ReturnReferenceExpression(typeof(void)), ArgumentsUtil.ConvertToArgumentReference(parameters)); } return(this._setMethod); }
public override void Emit(IEasyMember member, ILGenerator gen) { ArgumentsUtil.EmitLoadOwnerAndReference(this._target.OwnerReference, gen); this._expression.Emit(member, gen); this._target.StoreReference(gen); }
public EasyCallable CreateCallable(Type returnType, params ParameterInfo[] args) { EasyCallable nested = new EasyCallable(this, base.IncrementAndGetCounterValue, new ReturnReferenceExpression(returnType), ArgumentsUtil.ConvertToArgumentReference(args)); base._nested.Add(nested); return(nested); }
public EasyMethod CreateRemoveOnMethod(MethodAttributes atts, params Type[] parameters) { if (this.m_removeOnMethod == null) { this.m_removeOnMethod = new EasyMethod(this.m_maintype, "remove_" + this.Name, atts, new ReturnReferenceExpression(typeof(void)), ArgumentsUtil.ConvertToArgumentReference(parameters)); } return(this.m_removeOnMethod); }