Example #1
0
        protected override void DoEmit(EmitContext ec)
        {
            ec.BeginBlock(InitBlock);
            foreach (var s in InitBlock.InitStatements)
            {
                s.Emit(ec);
            }
            foreach (var s in InitBlock.Statements)
            {
                s.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);

            if (NextExpression != null)
            {
                NextExpression.Emit(ec);
                ec.Emit(OpCode.Pop);
            }
            ec.Emit(OpCode.Jump, contLabel);

            ec.EmitLabel(endLabel);

            ec.EndBlock();
        }
Example #2
0
        protected override void DoEmit(EmitContext ec)
        {
            Left.Emit(ec);
            ec.EmitCastToBoolean(Left.GetEvaluatedCType(ec));

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

            switch (Op)
            {
            case LogicOp.And:
                ec.Emit(OpCode.LogicalAnd);
                break;

            case LogicOp.Or:
                ec.Emit(OpCode.LogicalOr);
                break;

            default:
                throw new NotSupportedException("Unsupported logical operator '" + Op + "'");
            }
        }
        protected override void DoEmit(EmitContext ec)
        {
            var falseLabel = ec.DefineLabel();
            var endLabel   = ec.DefineLabel();

            Condition.Emit(ec);
            ec.EmitCastToBoolean(Condition.GetEvaluatedCType(ec));
            ec.Emit(OpCode.BranchIfFalse, falseLabel);

            TrueValue.Emit(ec);
            ec.Emit(OpCode.Jump, endLabel);

            ec.EmitLabel(falseLabel);
            FalseValue.Emit(ec);

            ec.EmitLabel(endLabel);
        }
Example #4
0
        protected override void DoEmit(EmitContext ec)
        {
            if (IsDo)
            {
                throw new NotImplementedException(GetType().Name + ": Do Emit");
            }
            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 #5
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);
        }