Esempio n. 1
0
        public override void Compile(Execution.VM.ByteCode bc)
        {
            m_Exp1.Compile(bc);

            if (m_Operator == Operator.Or)
            {
                Instruction i = bc.Emit_Jump(OpCode.JtOrPop, -1);
                m_Exp2.Compile(bc);
                i.NumVal = bc.GetJumpPointForNextInstruction();
                return;
            }

            if (m_Operator == Operator.And)
            {
                Instruction i = bc.Emit_Jump(OpCode.JfOrPop, -1);
                m_Exp2.Compile(bc);
                i.NumVal = bc.GetJumpPointForNextInstruction();
                return;
            }


            if (m_Exp2 != null)
            {
                m_Exp2.Compile(bc);
            }

            bc.Emit_Operator(OperatorToOpCode(m_Operator));

            if (ShouldInvertBoolean(m_Operator))
            {
                bc.Emit_Operator(OpCode.Not);
            }
        }
        private void CompileOp(Execution.VM.ByteCode bc, Operator op, Expression exp)
        {
            if (op == Operator.Or)
            {
                Instruction i = bc.Emit_Jump(OpCode.JtOrPop, -1);
                exp.Compile(bc);
                i.NumVal = bc.GetJumpPointForNextInstruction();
                return;
            }

            if (op == Operator.And)
            {
                Instruction i = bc.Emit_Jump(OpCode.JfOrPop, -1);
                exp.Compile(bc);
                i.NumVal = bc.GetJumpPointForNextInstruction();
                return;
            }


            if (exp != null)
            {
                exp.Compile(bc);
            }

            bc.Emit_Operator(OperatorToOpCode(op));

            if (ShouldInvertBoolean(op))
            {
                bc.Emit_Operator(OpCode.Not);
            }
        }