Exemplo n.º 1
0
        public override void Emit()
        {
            SubjectExp.Emit();
            EmitHelper.StormVar(IL, ListSymbol.VarBuilder);
            EmitHelper.LoadInt(IL, START_INDEX);
            EmitHelper.StormVar(IL, IndexSymbol.VarBuilder);

            EmitHelper.LoadVar(IL, ListSymbol.VarBuilder);
            EmitHelper.CallDynamic(IL, getCountMethod);
            EmitHelper.StormVar(IL, CountSymbol.VarBuilder);

            var True_Label  = IL.DefineLabel();
            var False_Label = IL.DefineLabel();

            EmitCondition();
            IL.Emit(OpCodes.Brfalse, False_Label);

            //定义一个标签,表示从下面开始进入循环体
            IL.MarkLabel(True_Label);
            BodyExp.Emit();
            if (ZTypeUtil.IsBool(BodyExp.RetType))//(BodyExp.RetType.SharpType != typeof(void))
            {
                IL.Emit(OpCodes.Pop);
            }
            EmitHelper.Inc(IL, IndexSymbol.VarBuilder);
            EmitCondition();
            IL.Emit(OpCodes.Brtrue, True_Label);
            IL.MarkLabel(False_Label);
        }
Exemplo n.º 2
0
        public void EmitGet( )
        {
            MethodInfo getMethod = Property.GetGetMethod();

            SubjectExp.Emit();
            ArgExp.RequireType = ZTypeManager.GetBySharpType(getMethod.ReturnType) as ZType;
            ArgExp.Emit();
            EmitHelper.CallDynamic(IL, getMethod);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 private void EmitLeft()
 {
     if (SubjectExp.RetType.IsStruct)
     {
         if (IsNeedTempLocal())
         {
             SubjectExp.Emit();
             EmitSymbolHelper.EmitStorm(IL, this.tempLocal);
             EmitSymbolHelper.EmitLoada(IL, this.tempLocal);
         }
         else
         {
             if (SubjectExp is ExpLocalVar)
             {
                 ((ExpLocalVar)SubjectExp).EmitLoadLocala();
             }
             else if (SubjectExp is ExpArg)
             {
                 ((ExpArg)SubjectExp).EmitLoadArga();
             }
             else if (SubjectExp is ExpFieldDef)
             {
                 ((ExpFieldDef)SubjectExp).EmitLoadFielda();
             }
             else if (SubjectExp is ExpFieldSuper)
             {
                 ((ExpFieldSuper)SubjectExp).EmitLoadFielda();
             }
             else if (SubjectExp is ExpUseField)
             {
                 ((ExpUseField)SubjectExp).EmitLoadFielda();
             }
             else
             {
                 SubjectExp.Emit();
             }
         }
     }
     else
     {
         SubjectExp.Emit();
     }
 }