예제 #1
0
 public override void Emit()
 {
     //ILGenerator il = context.ILout;
     base.EmitArgsExp(OpMethod.GetParameters(), new Exp[] { LeftExp, RightExp });
     EmitHelper.CallDynamic(IL, OpMethod);
     base.EmitConv();
 }
예제 #2
0
 void emitItem()
 {
     EmitHelper.LoadVar(IL, listSymbol.VarBuilder);
     EmitHelper.LoadVar(IL, indexSymbol.VarBuilder);
     EmitHelper.CallDynamic(IL, itemMethod);
     EmitHelper.StormVar(IL, itemSymbol.VarBuilder);
 }
예제 #3
0
 public override void Emit()
 {
     EmitSubject();
     base.EmitArgs(ExpProcDesc, SearchedMethod.ZDesces[0]); //GenerateArgs(context);
     EmitHelper.CallDynamic(IL, SearchedMethod.SharpMethod);
     EmitConv();                                            //base.GenerateConv(context);
 }
예제 #4
0
 public override void Emit()
 {
     EmitLoadMain();
     EmitArgsThis(ZMethod, ArgExps);
     EmitHelper.CallDynamic(IL, ZMethod.SharpMethod);
     EmitConv();
 }
예제 #5
0
        public void Generate(TypeBuilder classBuilder, bool isStatic)
        {
            var             symbols     = MethodContext.Symbols;
            EmitStmtContext stmtContext = new EmitStmtContext(MethodContext.EmitContext);
            var             il          = MethodContext.EmitContext.ILout;

            for (int i = 0; i < MethodContext.LoacalVarList.Count; i++)
            {
                string    ident     = MethodContext.LoacalVarList[i];
                SymbolVar varSymbol = symbols.Get(ident) as SymbolVar;
                varSymbol.VarBuilder = il.DeclareLocal(varSymbol.DimType);
                varSymbol.VarBuilder.SetLocalSymInfo(varSymbol.SymbolName);
            }
            if (MethodContext.RetType != typeof(void))
            {
                if (MethodContext.RetType.IsValueType)
                {
                    EmitHelper.LoadInt(il, 0);
                }
                else
                {
                    il.Emit(OpCodes.Ldnull);
                }
                EmitHelper.StormVar(il, (symbols.Get(MethodContext.LoacalVarList[0]) as SymbolVar).VarBuilder);
            }

            if (FnName.IsConstructor(this.ClassName) != -1)
            {
                if (!isStatic)
                {
                    callBaseDefault();
                    if (ClassContext.InitMemberValueMethod != null)
                    {
                        il.Emit(OpCodes.Ldarg_0);
                        EmitHelper.CallDynamic(il, ClassContext.InitMemberValueMethod, true);//EmitHelper.CallDynamic(il, ClassContext.InitMemberValueMethod);
                    }
                }
                else
                {
                    if (ClassContext.InitMemberValueMethod != null)
                    {
                        EmitHelper.CallDynamic(il, ClassContext.InitMemberValueMethod, true);//EmitHelper.CallDynamic(il, ClassContext.InitMemberValueMethod);
                    }
                }
            }
            //var MethodName = getMethodName(isStatic);
            //if(MethodName=="启动")
            //{
            //    //EmitHelper.CallDynamic(il, typeof(DebugHelper).GetMethod("PrintBaseDirectory"));
            //}
            FnBody.Generate(stmtContext);

            if (MethodContext.RetType != typeof(void))
            {
                il.Emit(OpCodes.Ldloc, retResult.VarBuilder);
                EmitHelper.EmitConv(il, MethodContext.RetType, retResult.DimType);
            }
            il.Emit(OpCodes.Ret);
        }
예제 #6
0
        public override void Generate(EmitExpContext context)
        {
            ILGenerator il = context.ILout;

            base.GenerateArgsExp(context, OpMethod.GetParameters(), new Exp[] { LeftExp, RightExp });
            EmitHelper.CallDynamic(il, OpMethod, true);
            base.GenerateConv(context);
        }
예제 #7
0
        public void EmitGet( )
        {
            MethodInfo getMethod = Property.GetGetMethod();

            EmitHelper.LoadVar(IL, ListSymbol.VarBuilder);//SubjectExp.Emit();
            EmitHelper.LoadVar(IL, IndexSymbol.VarBuilder);
            EmitHelper.CallDynamic(IL, getMethod);
        }
예제 #8
0
        void generateCount(EmitStmtContext context)
        {
            ILGenerator il = context.ILout;

            EmitHelper.LoadVar(il, listSymbol.VarBuilder);
            EmitHelper.CallDynamic(il, getCountMethod);
            EmitHelper.StormVar(il, countSymbol.VarBuilder);
        }
예제 #9
0
 public override void Emit()
 {
     base.EmitArgsExp(new Exp[] { LeftExp, RightExp }, OpMethod);
     EmitHelper.CallDynamic(IL, OpMethod);
     EmitSymbolHelper.EmitStorm(IL, TempStormLocalVarSymbol);
     EmitSymbolHelper.EmitLoad(IL, TempStormLocalVarSymbol);
     base.EmitConv();
 }
예제 #10
0
        public void GenerateGet(EmitExpContext context)
        {
            ILGenerator il        = context.ILout;
            MethodInfo  getMethod = ExProperty.Property.GetGetMethod();

            GenenrateSubject(context);
            EmitHelper.CallDynamic(il, getMethod, ExProperty.IsSelf);
        }
예제 #11
0
 void generateCondition(EmitStmtContext context)
 {
     EmitHelper.LoadVar(IL, indexSymbol.VarBuilder);
     EmitHelper.LoadVar(IL, countSymbol.VarBuilder);
     EmitHelper.CallDynamic(IL, compareMethod, true);
     EmitHelper.LoadInt(IL, 1);
     IL.Emit(OpCodes.Ceq);
 }
예제 #12
0
 protected void EmitCondition( )
 {
     EmitHelper.LoadVar(IL, IndexSymbol.VarBuilder);
     EmitHelper.LoadVar(IL, CountSymbol.VarBuilder);
     EmitHelper.CallDynamic(IL, LEMethod);
     EmitHelper.LoadInt(IL, 1);
     IL.Emit(OpCodes.Ceq);
 }
예제 #13
0
        public void EmitSet(Exp valueExp)
        {
            MethodInfo setMethod = Property.GetSetMethod();

            EmitHelper.LoadVar(IL, ListSymbol.VarBuilder);
            EmitHelper.LoadVar(IL, IndexSymbol.VarBuilder);
            valueExp.Emit();
            EmitHelper.CallDynamic(IL, setMethod);
        }
예제 #14
0
        private void EmitSetProperty(Exp valueExp)
        {
            EmitHelper.EmitThis(IL, true);
            EmitValueExp(valueExp);
            MethodInfo setMethod = ZProperty.SharpProperty.GetSetMethod();

            EmitHelper.CallDynamic(IL, setMethod);
            base.EmitConv();
        }
예제 #15
0
        void generateElement(EmitStmtContext context)
        {
            ILGenerator il = context.ILout;

            EmitHelper.LoadVar(il, listSymbol.VarBuilder);
            EmitHelper.LoadVar(il, indexSymbol.VarBuilder);
            EmitHelper.CallDynamic(il, diMethod);
            EmitHelper.StormVar(il, elementSymbol.VarBuilder);
        }
예제 #16
0
        void genBody(EmitExpContext context)
        {
            ILGenerator il = context.ILout;

            invokeExp.GenerateSubject(context);
            generateElement(context);
            invokeExp.GenerateArgs(context);
            EmitHelper.CallDynamic(il, invokeExp.CallExMethod);
        }
예제 #17
0
 public void AnalyBody()
 {
     Body.ProcContext = this.ProcContext;
     if (this.ProcContext.ClassContext.InitPropertyMethod != null)
     {
         EmitHelper.CallDynamic(Body.IL, this.ProcContext.ClassContext.InitPropertyMethod);
     }
     Body.Analy();
 }
예제 #18
0
파일: ExpDi.cs 프로젝트: pyzh/ZLanguage3
        public void EmitGet( )
        {
            MethodInfo getMethod = Property.GetGetMethod();

            SubjectExp.Emit();
            ArgExp.RequireType = ZTypeManager.GetBySharpType(getMethod.ReturnType) as ZType;
            ArgExp.Emit();
            EmitHelper.CallDynamic(IL, getMethod);
        }
예제 #19
0
        public override void Generate(EmitExpContext context)
        {
            ILGenerator il = context.ILout;

            GenerateSubject(context);
            base.GenerateArgsExp(context, ExpProcDesc, searchedProcDesc); //GenerateArgs(context);
            EmitHelper.CallDynamic(il, CallExMethod);
            base.GenerateConv(context);
        }
예제 #20
0
        public void GenerateSet(EmitExpContext context, Exp valueExpr)
        {
            ILGenerator il        = context.ILout;
            MethodInfo  setMethod = ExProperty.Property.GetSetMethod();

            GenenrateSubject(context);
            valueExpr.Generate(context);

            EmitHelper.CallDynamic(il, setMethod, ExProperty.IsSelf);
        }
예제 #21
0
        void generateCondition(EmitStmtContext context)
        {
            ILGenerator il = context.ILout;

            EmitHelper.LoadVar(il, indexSymbol.VarBuilder);
            EmitHelper.LoadVar(il, countSymbol.VarBuilder);
            EmitHelper.CallDynamic(il, compareMethod, true);
            EmitHelper.LoadInt(il, 1);
            il.Emit(OpCodes.Ceq);
        }
예제 #22
0
        public virtual void EmitGetProperty()
        {
            //bool isstatic = GetIsStatic();
            MethodInfo getMethod = GetGetMethod();

            //EmitHelper.EmitThis(IL, isstatic);
            EmitLoadMain();
            EmitHelper.CallDynamic(IL, getMethod);
            base.EmitConv();
        }
예제 #23
0
        //public virtual void EmitGetNestedProperty()
        //{
        //    bool isstatic = GetIsStatic();
        //    MethodInfo getMethod = GetGetMethod();

        //    EmitHelper.EmitThis(IL, isstatic);
        //    EmitSymbolHelper.EmitLoad(IL, LambdaThis);
        //    EmitHelper.CallDynamic(IL, getMethod);
        //    base.EmitConv();
        //}

        public virtual void EmitSetProperty(Exp valueExp)
        {
            //bool isstatic = GetIsStatic();
            MethodInfo setMethod = GetSetMethod();

            //EmitHelper.EmitThis(IL, isstatic);
            EmitLoadMain();
            EmitValueExp(valueExp);
            EmitHelper.CallDynamic(IL, setMethod);
        }
예제 #24
0
파일: DiExp.cs 프로젝트: qtxtz/ZCompileCore
        public void GenerateGet(EmitExpContext context)
        {
            ILGenerator il        = context.ILout;
            MethodInfo  getMethod = ExProperty.Property.GetGetMethod();

            SubjectExp.Generate(context);
            ArgExp.RequireType = getMethod.ReturnType;
            ArgExp.Generate(context);
            EmitHelper.CallDynamic(il, getMethod, ExProperty.IsSelf);
        }
예제 #25
0
        public virtual void EmitSetNestedProperty(Exp valueExp)
        {
            bool       isstatic  = GetIsStatic();
            MethodInfo setMethod = GetSetMethod();

            EmitHelper.EmitThis(IL, false);
            EmitSymbolHelper.EmitLoad(IL, LambdaThis);
            EmitValueExp(valueExp);
            EmitHelper.CallDynamic(IL, setMethod);
        }
예제 #26
0
파일: ExpDi.cs 프로젝트: pyzh/ZLanguage3
        public void EmitSet(Exp valueExp)
        {
            MethodInfo setMethod = Property.GetSetMethod();

            SubjectExp.Emit();
            ArgExp.RequireType = ZTypeManager.GetBySharpType(setMethod.GetParameters()[0].ParameterType) as ZType;
            ArgExp.Emit();
            //EmitHelper.Box(il, ArgExp.RetType, setMethod.GetParameters()[0].ParameterType);
            valueExp.RequireType = ZTypeManager.GetBySharpType(setMethod.GetParameters()[1].ParameterType) as ZType;
            valueExp.Emit();
            EmitHelper.CallDynamic(IL, setMethod);
        }
예제 #27
0
파일: DiExp.cs 프로젝트: qtxtz/ZCompileCore
        public void GenerateSet(EmitExpContext context, Exp valueExpr)
        {
            ILGenerator il        = context.ILout;
            MethodInfo  setMethod = ExProperty.Property.GetSetMethod();

            SubjectExp.Generate(context);
            ArgExp.RequireType = setMethod.GetParameters()[0].ParameterType;
            ArgExp.Generate(context);
            //EmitHelper.Box(il, ArgExp.RetType, setMethod.GetParameters()[0].ParameterType);
            valueExpr.RequireType = setMethod.GetParameters()[1].ParameterType;
            valueExpr.Generate(context);
            EmitHelper.CallDynamic(il, setMethod, ExProperty.IsSelf);
        }
예제 #28
0
 public void EmitGet( )
 {
     if (ZMember is ZPropertyInfo)
     {
         MethodInfo getMethod = (ZMember as ZPropertyInfo).SharpProperty.GetGetMethod();
         EmitSubject();
         EmitHelper.CallDynamic(IL, getMethod);
     }
     else
     {
         EmitSubject();
         EmitHelper.LoadField(IL, (ZMember as ZFieldInfo).SharpField);
     }
 }
예제 #29
0
        public override void Generate(EmitExpContext context)
        {
            ILGenerator il = context.ILout;

            if (newCode == 1)
            {
                var          Constructor = ConstructorDesc.Constructor;
                LocalBuilder varLocal    = il.DeclareLocal(SubjectGCL.ForType);
                EmitHelper.NewObj(il, Constructor);
                il.Emit(OpCodes.Stloc, varLocal);

                MethodInfo   addMethod       = SubjectGCL.ForType.GetMethod("Add");
                ExMethodInfo exAddMethodInfo = GclUtil.CreatExMethodInfo(addMethod, SubjectGCL.ForType);
                if (BrackestArgs != null)
                {
                    foreach (var exp in BrackestArgs.InneExps)
                    {
                        EmitHelper.LoadVar(il, varLocal);//il.Emit(OpCodes.Ldloc, varLocal);
                        (exp).Generate(context);
                        EmitHelper.CallDynamic(il, exAddMethodInfo);
                    }
                }
                EmitHelper.LoadVar(il, varLocal);//il.Emit(OpCodes.Ldloc, varLocal);
            }
            else if (newCode == 2)
            {
                var Constructor = ConstructorDesc.Constructor;
                if (!IsAssignedValue)
                {
                    LocalBuilder varLocal = il.DeclareLocal(SubjectGCL.ForType);
                    emitConstructor(context);//emitArgs(context);
                    EmitHelper.NewObj(il, Constructor);
                    il.Emit(OpCodes.Stloc, varLocal);
                    EmitHelper.LoadVar(il, varLocal);//il.Emit(OpCodes.Ldloc, varLocal);
                }
                else
                {
                    emitConstructor(context);//emitArgs(context);
                    EmitHelper.NewObj(il, Constructor);
                }
            }
            else
            {
                var Method = ProcDesc.ExMethod;
                emitProc(context);
                EmitHelper.CallDynamic(il, Method);
            }
            base.GenerateConv(context);
        }
예제 #30
0
 public void EmitSet(Exp valueExp)
 {
     if (ZMember is ZPropertyInfo)
     {
         MethodInfo setMethod = (ZMember as ZPropertyInfo).SharpProperty.GetSetMethod();
         EmitSubject();
         valueExp.Emit();
         EmitHelper.CallDynamic(IL, setMethod);
     }
     else
     {
         EmitSubject();
         valueExp.Emit();
         EmitHelper.StormField(IL, (ZMember as ZFieldInfo).SharpField);
     }
 }