Пример #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);
 }