예제 #1
0
 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();
 }
예제 #2
0
 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);
 }
예제 #3
0
        /// <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);
        }
예제 #4
0
 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);
 }
예제 #5
0
 internal void InvokeBaseConstructor(ConstructorInfo constructor, params ArgumentReference[] arguments)
 {
     base.AddStatement(new ExpressionStatement(new ConstructorInvocationExpression(constructor, ArgumentsUtil.ConvertArgumentReferenceToExpression(arguments))));
 }
예제 #6
0
 public override void Emit(IEasyMember member, ILGenerator gen)
 {
     ArgumentsUtil.EmitLoadOwnerAndReference(this._arrayReference, gen);
     ArgumentsUtil.EmitLoadOwnerAndReference(this._index, gen);
     gen.Emit(OpCodes.Ldelem_Ref);
 }
예제 #7
0
 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);
 }
예제 #8
0
 public override void Emit(IEasyMember member, ILGenerator gen)
 {
     ArgumentsUtil.EmitLoadOwnerAndReference(this._reference, gen);
 }
예제 #9
0
 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);
 }
예제 #10
0
 public override void Emit(IEasyMember member, ILGenerator gen)
 {
     ArgumentsUtil.EmitLoadOwnerAndReference(this._target.OwnerReference, gen);
     this._expression.Emit(member, gen);
     this._target.StoreReference(gen);
 }
예제 #11
0
        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);
        }
예제 #12
0
 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);
 }