Example #1
0
        protected override void DoEmit(EmitContext ec)
        {
            InitBlock.Emit(ec);

            var endLabel = ec.DefineLabel();

            var contLabel = ec.DefineLabel();

            ec.EmitLabel(contLabel);
            ContinueExpression.Emit(ec);
            ec.EmitCastToBoolean(ContinueExpression.GetEvaluatedCType(ec));
            ec.Emit(OpCode.BranchIfFalse, endLabel);

            LoopBody.Emit(ec);
            NextExpression.Emit(ec);
            ec.Emit(OpCode.Pop);
            ec.Emit(OpCode.Jump, contLabel);

            ec.EmitLabel(endLabel);
        }
Example #2
0
        protected override void DoEmit(EmitContext ec)
        {
            if (IsDo)
            {
                throw new NotImplementedException();
            }
            else
            {
                var condLabel = ec.DefineLabel();
                var loopLabel = ec.DefineLabel();
                var endLabel  = ec.DefineLabel();

                ec.EmitLabel(condLabel);
                Condition.Emit(ec);
                ec.EmitCastToBoolean(Condition.GetEvaluatedCType(ec));
                ec.Emit(OpCode.BranchIfFalse, endLabel);
                ec.EmitLabel(loopLabel);
                Loop.Emit(ec);
                ec.Emit(OpCode.Jump, condLabel);
                ec.EmitLabel(endLabel);
            }
        }
Example #3
0
        protected override void DoEmit(EmitContext ec)
        {
            var endLabel = ec.DefineLabel();

            Condition.Emit(ec);
            ec.EmitCastToBoolean(Condition.GetEvaluatedCType(ec));

            if (FalseStatement == null)
            {
                ec.Emit(OpCode.BranchIfFalse, endLabel);
                TrueStatement.Emit(ec);
            }
            else
            {
                var falseLabel = ec.DefineLabel();
                ec.Emit(OpCode.BranchIfFalse, falseLabel);
                TrueStatement.Emit(ec);
                ec.Emit(OpCode.Jump, endLabel);
                ec.EmitLabel(falseLabel);
                FalseStatement.Emit(ec);
            }

            ec.EmitLabel(endLabel);
        }