public static void Infix(FuncState fs, BinOpr op, ExpDesc e) { switch (op) { case BinOpr.AND: { GoIfTrue(fs, e); } break; case BinOpr.OR: { GoIfFalse(fs, e); } break; case BinOpr.CONCAT: { Exp2NextReg(fs, e); // operand must be on the `stack' } break; case BinOpr.ADD: case BinOpr.SUB: case BinOpr.MUL: case BinOpr.DIV: case BinOpr.MOD: case BinOpr.POW: { if (!IsNumeral(e)) { Exp2RK(fs, e); } } break; default: { Exp2RK(fs, e); } break; } }
public static void luaK_infix(FuncState fs, BinOpr op, expdesc v) { switch (op) { case BinOpr.OPR_AND: { luaK_goiftrue(fs, v); break; } case BinOpr.OPR_OR: { luaK_goiffalse(fs, v); break; } case BinOpr.OPR_CONCAT: { luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ break; } default: { if (isnumeral(v) == 0) { luaK_exp2RK(fs, v); } break; } } }
public static void luaK_infix(FuncState fs, BinOpr op, expdesc v) { switch (op) { case BinOpr.OPR_AND: luaK_goiftrue(fs, v); break; case BinOpr.OPR_OR: luaK_goiffalse(fs, v); break; case BinOpr.OPR_CONCAT: luaK_exp2nextreg(fs, v); /* operand must be on the 'stack' */ break; case BinOpr.OPR_ADD: case BinOpr.OPR_SUB: case BinOpr.OPR_MUL: case BinOpr.OPR_DIV: case BinOpr.OPR_MOD: case BinOpr.OPR_POW: if ((isnumeral(v) == 0)) { luaK_exp2RK(fs, v); } break; default: luaK_exp2RK(fs, v); break; } }
/* ** Emit code for comparisons. ** 'e1' was already put in R/K form by 'luaK_infix'. */ private static void codecomp(FuncState fs, BinOpr opr, expdesc e1, expdesc e2) { int rk1 = (e1.k == expkind.VK) ? RKASK(e1.u.info) : (int)check_exp(e1.k == expkind.VNONRELOC, e1.u.info); int rk2 = luaK_exp2RK(fs, e2); freeexps(fs, e1, e2); switch (opr) { case BinOpr.OPR_NE: { /* '(a ~= b)' ==> 'not (a == b)' */ e1.u.info = condjump(fs, OpCode.OP_EQ, 0, rk1, rk2); break; } case BinOpr.OPR_GT: case BinOpr.OPR_GE: { /* '(a > b)' ==> '(b < a)'; '(a >= b)' ==> '(b <= a)' */ OpCode op = (OpCode)((opr - BinOpr.OPR_NE) + OpCode.OP_EQ); e1.u.info = condjump(fs, op, 1, rk2, rk1); /* invert operands */ break; } default: { /* '==', '<', '<=' use their own opcodes */ OpCode op = (OpCode)((opr - BinOpr.OPR_EQ) + OpCode.OP_EQ); e1.u.info = condjump(fs, op, 1, rk1, rk2); break; } } e1.k = expkind.VJMP; }
public static void luaK_infix(FuncState fs, BinOpr op, expdesc v) { switch (op) { case BinOpr.OPR_AND: { luaK_goiftrue(fs, v); break; } case BinOpr.OPR_OR: { luaK_goiffalse(fs, v); break; } case BinOpr.OPR_CONCAT: { luaK_exp2nextreg(fs, v); /* operand must be on the 'stack' */ break; } case BinOpr.OPR_ADD: goto case BinOpr.OPR_SHR; case BinOpr.OPR_SUB: goto case BinOpr.OPR_SHR; case BinOpr.OPR_MUL: goto case BinOpr.OPR_SHR; case BinOpr.OPR_DIV: goto case BinOpr.OPR_SHR; case BinOpr.OPR_IDIV: goto case BinOpr.OPR_SHR; case BinOpr.OPR_MOD: goto case BinOpr.OPR_SHR; case BinOpr.OPR_POW: goto case BinOpr.OPR_SHR; case BinOpr.OPR_BAND: goto case BinOpr.OPR_SHR; case BinOpr.OPR_BOR: goto case BinOpr.OPR_SHR; case BinOpr.OPR_BXOR: goto case BinOpr.OPR_SHR; case BinOpr.OPR_SHL: goto case BinOpr.OPR_SHR; case BinOpr.OPR_SHR: { if (lcode.tonumeral(v, null) == false) { luaK_exp2RK(fs, v); } break; } default: { luaK_exp2RK(fs, v); break; } } }
/* ** Process 1st operand 'v' of binary operation 'op' before reading ** 2nd operand. */ public static void luaK_infix(FuncState fs, BinOpr op, expdesc v) { switch (op) { case BinOpr.OPR_AND: { luaK_goiftrue(fs, v); /* go ahead only if 'v' is true */ break; } case BinOpr.OPR_OR: { luaK_goiffalse(fs, v); /* go ahead only if 'v' is false */ break; } case BinOpr.OPR_CONCAT: { luaK_exp2nextreg(fs, v); /* operand must be on the 'stack' */ break; } case BinOpr.OPR_ADD: case BinOpr.OPR_SUB: case BinOpr.OPR_MUL: case BinOpr.OPR_DIV: case BinOpr.OPR_IDIV: case BinOpr.OPR_MOD: case BinOpr.OPR_POW: case BinOpr.OPR_BAND: case BinOpr.OPR_BOR: case BinOpr.OPR_BXOR: case BinOpr.OPR_SHL: case BinOpr.OPR_SHR: { if (0 == tonumeral(v, null)) { luaK_exp2RK(fs, v); } /* else keep numeral, which may be folded with 2nd operand */ break; } default: { luaK_exp2RK(fs, v); break; } } }
public static void LuaKInfix(FuncState fs, BinOpr op, expdesc v) { switch (op) { case BinOpr.OPR_AND: { LuaKGoIfTrue(fs, v); break; } case BinOpr.OPR_OR: { LuaKGoIFalse(fs, v); break; } case BinOpr.OPR_CONCAT: { LuaKExp2NextReg(fs, v); /* operand must be on the `stack' */ break; } case BinOpr.OPR_ADD: case BinOpr.OPR_SUB: case BinOpr.OPR_MUL: case BinOpr.OPR_DIV: case BinOpr.OPR_MOD: case BinOpr.OPR_POW: { if ((IsNumeral(v) == 0)) { LuaKExp2RK(fs, v); } break; } default: { LuaKExp2RK(fs, v); break; } } }
public static void Posfix( FuncState fs, BinOpr op, ExpDesc e1, ExpDesc e2, int line ) { // Debug.Log(">> POSFIX op:" + op); switch( op ) { case BinOpr.AND: { Utl.Assert( e1.ExitTrue == NO_JUMP ); DischargeVars( fs, e2 ); e2.ExitFalse = Concat( fs, e2.ExitFalse, e1.ExitFalse ); e1.CopyFrom( e2 ); break; } case BinOpr.OR: { Utl.Assert( e1.ExitFalse == NO_JUMP ); DischargeVars( fs, e2 ); e2.ExitTrue = Concat( fs, e2.ExitTrue, e1.ExitTrue ); e1.CopyFrom( e2 ); break; } case BinOpr.CONCAT: { Exp2Val( fs, e2 ); var pe2 = fs.GetCode( e2 ); if( e2.Kind == ExpKind.VRELOCABLE && pe2.Value.GET_OPCODE() == OpCode.OP_CONCAT ) { Utl.Assert( e1.Info == pe2.Value.GETARG_B()-1 ); FreeExp( fs, e1 ); pe2.Value = pe2.Value.SETARG_B( e1.Info ); e1.Kind = ExpKind.VRELOCABLE; e1.Info = e2.Info; } else { // operand must be on the `stack' Exp2NextReg( fs, e2 ); CodeArith( fs, OpCode.OP_CONCAT, e1, e2, line ); } break; } case BinOpr.ADD: { CodeArith( fs, OpCode.OP_ADD, e1, e2, line); break; } case BinOpr.SUB: { CodeArith( fs, OpCode.OP_SUB, e1, e2, line); break; } case BinOpr.MUL: { CodeArith( fs, OpCode.OP_MUL, e1, e2, line); break; } case BinOpr.DIV: { CodeArith( fs, OpCode.OP_DIV, e1, e2, line); break; } case BinOpr.MOD: { CodeArith( fs, OpCode.OP_MOD, e1, e2, line); break; } case BinOpr.POW: { CodeArith( fs, OpCode.OP_POW, e1, e2, line); break; } case BinOpr.EQ: { CodeComp( fs, OpCode.OP_EQ, 1, e1, e2 ); break; } case BinOpr.LT: { CodeComp( fs, OpCode.OP_LT, 1, e1, e2 ); break; } case BinOpr.LE: { CodeComp( fs, OpCode.OP_LE, 1, e1, e2 ); break; } case BinOpr.NE: { CodeComp( fs, OpCode.OP_EQ, 0, e1, e2 ); break; } case BinOpr.GT: { CodeComp( fs, OpCode.OP_LT, 0, e1, e2 ); break; } case BinOpr.GE: { CodeComp( fs, OpCode.OP_LE, 0, e1, e2 ); break; } default: Utl.Assert(false); break; } }
public static void Infix( FuncState fs, BinOpr op, ExpDesc e ) { // Debug.Log(">> INFIX op:" + op); switch( op ) { case BinOpr.AND: { GoIfTrue( fs, e ); } break; case BinOpr.OR: { GoIfFalse( fs, e ); } break; case BinOpr.CONCAT: { Exp2NextReg( fs, e ); // operand must be on the `stack' } break; case BinOpr.ADD: case BinOpr.SUB: case BinOpr.MUL: case BinOpr.DIV: case BinOpr.MOD: case BinOpr.POW: { if( !IsNumeral(e) ) Exp2RK( fs, e ); } break; default: { Exp2RK( fs, e ); } break; } }
/* ** subexpr . (simpleexp | unop subexpr) { binop subexpr } ** where `binop' is any binary operator with a priority higher than `limit' */ private static BinOpr subexpr(LexState ls, expdesc v, uint limit) { BinOpr op = new BinOpr(); UnOpr uop = new UnOpr(); enterlevel(ls); uop = getunopr(ls.t.token); if (uop != UnOpr.OPR_NOUNOPR) { LuaXNext(ls); subexpr(ls, v, UNARY_PRIORITY); LuaKPrefix(ls.fs, uop, v); } else simpleexp(ls, v); /* expand while operators have priorities higher than `limit' */ op = getbinopr(ls.t.token); while (op != BinOpr.OPR_NOBINOPR && priority[(int)op].left > limit) { expdesc v2 = new expdesc(); BinOpr nextop; LuaXNext(ls); LuaKInfix(ls.fs, op, v); /* read sub-expression with higher priority */ nextop = subexpr(ls, v2, priority[(int)op].right); LuaKPosFix(ls.fs, op, v, v2); op = nextop; } leavelevel(ls); return op; /* return first untreated operator */ }
public static void luaK_posfix (FuncState fs, BinOpr op, expdesc e1, expdesc e2) { switch (op) { case BinOpr.OPR_AND: { lua_assert(e1.t == NO_JUMP); /* list must be closed */ luaK_dischargevars(fs, e2); luaK_concat(fs, ref e2.f, e1.f); e1.Copy(e2); break; } case BinOpr.OPR_OR: { lua_assert(e1.f == NO_JUMP); /* list must be closed */ luaK_dischargevars(fs, e2); luaK_concat(fs, ref e2.t, e1.t); e1.Copy(e2); break; } case BinOpr.OPR_CONCAT: { luaK_exp2val(fs, e2); if (e2.k == expkind.VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OpCode.OP_CONCAT) { lua_assert(e1.u.s.info == GETARG_B(getcode(fs, e2))-1); freeexp(fs, e1); SETARG_B(getcode(fs, e2), e1.u.s.info); e1.k = expkind.VRELOCABLE; e1.u.s.info = e2.u.s.info; } else { luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ codearith(fs, OpCode.OP_CONCAT, e1, e2); } break; } case BinOpr.OPR_ADD: codearith(fs, OpCode.OP_ADD, e1, e2); break; case BinOpr.OPR_SUB: codearith(fs, OpCode.OP_SUB, e1, e2); break; case BinOpr.OPR_MUL: codearith(fs, OpCode.OP_MUL, e1, e2); break; case BinOpr.OPR_DIV: codearith(fs, OpCode.OP_DIV, e1, e2); break; case BinOpr.OPR_MOD: codearith(fs, OpCode.OP_MOD, e1, e2); break; case BinOpr.OPR_POW: codearith(fs, OpCode.OP_POW, e1, e2); break; case BinOpr.OPR_EQ: codecomp(fs, OpCode.OP_EQ, 1, e1, e2); break; case BinOpr.OPR_NE: codecomp(fs, OpCode.OP_EQ, 0, e1, e2); break; case BinOpr.OPR_LT: codecomp(fs, OpCode.OP_LT, 1, e1, e2); break; case BinOpr.OPR_LE: codecomp(fs, OpCode.OP_LE, 1, e1, e2); break; case BinOpr.OPR_GT: codecomp(fs, OpCode.OP_LT, 0, e1, e2); break; case BinOpr.OPR_GE: codecomp(fs, OpCode.OP_LE, 0, e1, e2); break; default: lua_assert(0); break; } }
public static void luaK_infix (FuncState fs, BinOpr op, expdesc v) { switch (op) { case BinOpr.OPR_AND: { luaK_goiftrue(fs, v); break; } case BinOpr.OPR_OR: { luaK_goiffalse(fs, v); break; } case BinOpr.OPR_CONCAT: { luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ break; } case BinOpr.OPR_ADD: case BinOpr.OPR_SUB: case BinOpr.OPR_MUL: case BinOpr.OPR_DIV: case BinOpr.OPR_MOD: case BinOpr.OPR_POW: { if ((isnumeral(v)==0)) luaK_exp2RK(fs, v); break; } default: { luaK_exp2RK(fs, v); break; } } }
public static void luaK_posfix(FuncState fs, BinOpr op, expdesc e1, expdesc e2, int line) { switch (op) { case BinOpr.OPR_AND: { lua_assert(e1.t == NO_JUMP); /* list must be closed */ luaK_dischargevars(fs, e2); luaK_concat(fs, ref e2.f, e1.f); e1.Copy(e2); break; } case BinOpr.OPR_OR: { lua_assert(e1.f == NO_JUMP); /* list must be closed */ luaK_dischargevars(fs, e2); luaK_concat(fs, ref e2.t, e1.t); e1.Copy(e2); break; } case BinOpr.OPR_CONCAT: { luaK_exp2val(fs, e2); if (e2.k == expkind.VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OpCode.OP_CONCAT) { lua_assert(e1.u.info == GETARG_B(getcode(fs, e2)) - 1); freeexp(fs, e1); SETARG_B(getcode(fs, e2), e1.u.info); e1.k = expkind.VRELOCABLE; e1.u.info = e2.u.info; } else { luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ codeexpval(fs, OpCode.OP_CONCAT, e1, e2, line); } break; } case BinOpr.OPR_ADD: case BinOpr.OPR_SUB: case BinOpr.OPR_MUL: case BinOpr.OPR_DIV: case BinOpr.OPR_IDIV: case BinOpr.OPR_MOD: case BinOpr.OPR_POW: case BinOpr.OPR_BAND: case BinOpr.OPR_BOR: case BinOpr.OPR_BXOR: case BinOpr.OPR_SHL: case BinOpr.OPR_SHR: { codeexpval(fs, (OpCode)((op - BinOpr.OPR_ADD) + OpCode.OP_ADD), e1, e2, line); break; } case BinOpr.OPR_EQ: case BinOpr.OPR_LT: case BinOpr.OPR_LE: { codecomp(fs, (OpCode)(op - BinOpr.OPR_EQ + OpCode.OP_EQ), 1, e1, e2); break; } case BinOpr.OPR_NE: case BinOpr.OPR_GT: case BinOpr.OPR_GE: { codecomp(fs, (OpCode)(op - BinOpr.OPR_NE + OpCode.OP_EQ), 0, e1, e2); break; } default: lua_assert(0); break; } }
private int GetBinOprRightPrior( BinOpr opr ) { switch( opr ) { case BinOpr.ADD: return 6; case BinOpr.SUB: return 6; case BinOpr.MUL: return 7; case BinOpr.DIV: return 7; case BinOpr.MOD: return 7; case BinOpr.POW: return 9; case BinOpr.CONCAT: return 4; case BinOpr.EQ: return 3; case BinOpr.LT: return 3; case BinOpr.LE: return 3; case BinOpr.NE: return 3; case BinOpr.GT: return 3; case BinOpr.GE: return 3; case BinOpr.AND: return 2; case BinOpr.OR: return 1; case BinOpr.NOBINOPR: throw new Exception("GetBinOprRightPrior(NOBINOPR)"); default: throw new Exception("Unknown BinOpr"); } }
public static void LuaKPosFix(FuncState fs, BinOpr op, expdesc e1, expdesc e2) { switch (op) { case BinOpr.OPR_AND: { LuaAssert(e1.t == NO_JUMP); /* list must be closed */ LuaKDischargeVars(fs, e2); LuaKConcat(fs, ref e2.f, e1.f); e1.Copy(e2); break; } case BinOpr.OPR_OR: { LuaAssert(e1.f == NO_JUMP); /* list must be closed */ LuaKDischargeVars(fs, e2); LuaKConcat(fs, ref e2.t, e1.t); e1.Copy(e2); break; } case BinOpr.OPR_CONCAT: { LuaKExp2Val(fs, e2); if (e2.k == expkind.VRELOCABLE && GET_OPCODE(GetCode(fs, e2)) == OpCode.OP_CONCAT) { LuaAssert(e1.u.s.info == GETARG_B(GetCode(fs, e2)) - 1); FreeExp(fs, e1); SETARG_B(GetCode(fs, e2), e1.u.s.info); e1.k = expkind.VRELOCABLE; e1.u.s.info = e2.u.s.info; } else { LuaKExp2NextReg(fs, e2); /* operand must be on the 'stack' */ CodeArith(fs, OpCode.OP_CONCAT, e1, e2); } break; } case BinOpr.OPR_ADD: CodeArith(fs, OpCode.OP_ADD, e1, e2); break; case BinOpr.OPR_SUB: CodeArith(fs, OpCode.OP_SUB, e1, e2); break; case BinOpr.OPR_MUL: CodeArith(fs, OpCode.OP_MUL, e1, e2); break; case BinOpr.OPR_DIV: CodeArith(fs, OpCode.OP_DIV, e1, e2); break; case BinOpr.OPR_MOD: CodeArith(fs, OpCode.OP_MOD, e1, e2); break; case BinOpr.OPR_POW: CodeArith(fs, OpCode.OP_POW, e1, e2); break; case BinOpr.OPR_EQ: CodeComp(fs, OpCode.OP_EQ, 1, e1, e2); break; case BinOpr.OPR_NE: CodeComp(fs, OpCode.OP_EQ, 0, e1, e2); break; case BinOpr.OPR_LT: CodeComp(fs, OpCode.OP_LT, 1, e1, e2); break; case BinOpr.OPR_LE: CodeComp(fs, OpCode.OP_LE, 1, e1, e2); break; case BinOpr.OPR_GT: CodeComp(fs, OpCode.OP_LT, 0, e1, e2); break; case BinOpr.OPR_GE: CodeComp(fs, OpCode.OP_LE, 0, e1, e2); break; default: LuaAssert(0); break; } }
public static void LuaKInfix (FuncState fs, BinOpr op, expdesc v) { switch (op) { case BinOpr.OPR_AND: { LuaKGoIfTrue(fs, v); break; } case BinOpr.OPR_OR: { LuaKGoIFalse(fs, v); break; } case BinOpr.OPR_CONCAT: { LuaKExp2NextReg(fs, v); /* operand must be on the `stack' */ break; } case BinOpr.OPR_ADD: case BinOpr.OPR_SUB: case BinOpr.OPR_MUL: case BinOpr.OPR_DIV: case BinOpr.OPR_MOD: case BinOpr.OPR_POW: { if ((IsNumeral(v)==0)) LuaKExp2RK(fs, v); break; } default: { LuaKExp2RK(fs, v); break; } } }
public static void Posfix(FuncState fs, BinOpr op, ExpDesc e1, ExpDesc e2, int line) { switch (op) { case BinOpr.AND: { Utl.Assert(e1.ExitTrue == NO_JUMP); DischargeVars(fs, e2); e2.ExitFalse = Concat(fs, e2.ExitFalse, e1.ExitFalse); e1.CopyFrom(e2); break; } case BinOpr.OR: { Utl.Assert(e1.ExitFalse == NO_JUMP); DischargeVars(fs, e2); e2.ExitTrue = Concat(fs, e2.ExitTrue, e1.ExitTrue); e1.CopyFrom(e2); break; } case BinOpr.CONCAT: { Exp2Val(fs, e2); var pe2 = fs.GetCode(e2); if (e2.Kind == ExpKind.VRELOCABLE && pe2.Value.GET_OPCODE() == OpCode.OP_CONCAT) { Utl.Assert(e1.Info == pe2.Value.GETARG_B() - 1); FreeExp(fs, e1); pe2.Value = pe2.Value.SETARG_B(e1.Info); e1.Kind = ExpKind.VRELOCABLE; e1.Info = e2.Info; } else { // operand must be on the `stack' Exp2NextReg(fs, e2); CodeArith(fs, OpCode.OP_CONCAT, e1, e2, line); } break; } case BinOpr.ADD: { CodeArith(fs, OpCode.OP_ADD, e1, e2, line); break; } case BinOpr.SUB: { CodeArith(fs, OpCode.OP_SUB, e1, e2, line); break; } case BinOpr.MUL: { CodeArith(fs, OpCode.OP_MUL, e1, e2, line); break; } case BinOpr.DIV: { CodeArith(fs, OpCode.OP_DIV, e1, e2, line); break; } case BinOpr.MOD: { CodeArith(fs, OpCode.OP_MOD, e1, e2, line); break; } case BinOpr.POW: { CodeArith(fs, OpCode.OP_POW, e1, e2, line); break; } case BinOpr.EQ: { CodeComp(fs, OpCode.OP_EQ, 1, e1, e2); break; } case BinOpr.LT: { CodeComp(fs, OpCode.OP_LT, 1, e1, e2); break; } case BinOpr.LE: { CodeComp(fs, OpCode.OP_LE, 1, e1, e2); break; } case BinOpr.NE: { CodeComp(fs, OpCode.OP_EQ, 0, e1, e2); break; } case BinOpr.GT: { CodeComp(fs, OpCode.OP_LT, 0, e1, e2); break; } case BinOpr.GE: { CodeComp(fs, OpCode.OP_LE, 0, e1, e2); break; } default: throw new NotImplementedException(string.Format("opcode {0}({1}, {2}) @line:{3}", op, e1, e2, line)); } }
public static void LuaKPosFix (FuncState fs, BinOpr op, expdesc e1, expdesc e2) { switch (op) { case BinOpr.OPR_AND: { LuaAssert(e1.t == NO_JUMP); /* list must be closed */ LuaKDischargeVars(fs, e2); LuaKConcat(fs, ref e2.f, e1.f); e1.Copy(e2); break; } case BinOpr.OPR_OR: { LuaAssert(e1.f == NO_JUMP); /* list must be closed */ LuaKDischargeVars(fs, e2); LuaKConcat(fs, ref e2.t, e1.t); e1.Copy(e2); break; } case BinOpr.OPR_CONCAT: { LuaKExp2Val(fs, e2); if (e2.k == expkind.VRELOCABLE && GET_OPCODE(GetCode(fs, e2)) == OpCode.OP_CONCAT) { LuaAssert(e1.u.s.info == GETARG_B(GetCode(fs, e2))-1); FreeExp(fs, e1); SETARG_B(GetCode(fs, e2), e1.u.s.info); e1.k = expkind.VRELOCABLE; e1.u.s.info = e2.u.s.info; } else { LuaKExp2NextReg(fs, e2); /* operand must be on the 'stack' */ CodeArith(fs, OpCode.OP_CONCAT, e1, e2); } break; } case BinOpr.OPR_ADD: CodeArith(fs, OpCode.OP_ADD, e1, e2); break; case BinOpr.OPR_SUB: CodeArith(fs, OpCode.OP_SUB, e1, e2); break; case BinOpr.OPR_MUL: CodeArith(fs, OpCode.OP_MUL, e1, e2); break; case BinOpr.OPR_DIV: CodeArith(fs, OpCode.OP_DIV, e1, e2); break; case BinOpr.OPR_MOD: CodeArith(fs, OpCode.OP_MOD, e1, e2); break; case BinOpr.OPR_POW: CodeArith(fs, OpCode.OP_POW, e1, e2); break; case BinOpr.OPR_EQ: CodeComp(fs, OpCode.OP_EQ, 1, e1, e2); break; case BinOpr.OPR_NE: CodeComp(fs, OpCode.OP_EQ, 0, e1, e2); break; case BinOpr.OPR_LT: CodeComp(fs, OpCode.OP_LT, 1, e1, e2); break; case BinOpr.OPR_LE: CodeComp(fs, OpCode.OP_LE, 1, e1, e2); break; case BinOpr.OPR_GT: CodeComp(fs, OpCode.OP_LT, 0, e1, e2); break; case BinOpr.OPR_GE: CodeComp(fs, OpCode.OP_LE, 0, e1, e2); break; default: LuaAssert(0); break; } }
public static void luaK_posfix(FuncState fs, BinOpr op, expdesc e1, expdesc e2) { switch (op) { case BinOpr.OPR_AND: { lua_assert(e1.t == NO_JUMP); /* list must be closed */ luaK_dischargevars(fs, e2); luaK_concat(fs, ref e2.f, e1.f); e1.Copy(e2); break; } case BinOpr.OPR_OR: { lua_assert(e1.f == NO_JUMP); /* list must be closed */ luaK_dischargevars(fs, e2); luaK_concat(fs, ref e2.t, e1.t); e1.Copy(e2); break; } case BinOpr.OPR_CONCAT: { luaK_exp2val(fs, e2); if (e2.k == expkind.VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OpCode.OP_CONCAT) { lua_assert(e1.u.s.info == GETARG_B(getcode(fs, e2)) - 1); freeexp(fs, e1); SETARG_B(getcode(fs, e2), e1.u.s.info); e1.k = expkind.VRELOCABLE; e1.u.s.info = e2.u.s.info; } else { luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ codearith(fs, OpCode.OP_CONCAT, e1, e2); } break; } case BinOpr.OPR_ADD: codearith(fs, OpCode.OP_ADD, e1, e2); break; case BinOpr.OPR_SUB: codearith(fs, OpCode.OP_SUB, e1, e2); break; case BinOpr.OPR_MUL: codearith(fs, OpCode.OP_MUL, e1, e2); break; case BinOpr.OPR_DIV: codearith(fs, OpCode.OP_DIV, e1, e2); break; case BinOpr.OPR_MOD: codearith(fs, OpCode.OP_MOD, e1, e2); break; case BinOpr.OPR_POW: codearith(fs, OpCode.OP_POW, e1, e2); break; case BinOpr.OPR_EQ: codecomp(fs, OpCode.OP_EQ, 1, e1, e2); break; case BinOpr.OPR_NE: codecomp(fs, OpCode.OP_EQ, 0, e1, e2); break; case BinOpr.OPR_LT: codecomp(fs, OpCode.OP_LT, 1, e1, e2); break; case BinOpr.OPR_LE: codecomp(fs, OpCode.OP_LE, 1, e1, e2); break; case BinOpr.OPR_GT: codecomp(fs, OpCode.OP_LT, 0, e1, e2); break; case BinOpr.OPR_GE: codecomp(fs, OpCode.OP_LE, 0, e1, e2); break; case BinOpr.OPR_RSHIFT: codearith(fs, OpCode.OP_RSHIFT, e1, e2); break; case BinOpr.OPR_LSHIFT: codearith(fs, OpCode.OP_LSHIFT, e1, e2); break; case BinOpr.OPR_BITAND: codearith(fs, OpCode.OP_BITAND, e1, e2); break; case BinOpr.OPR_BITOR: codearith(fs, OpCode.OP_BITOR, e1, e2); break; default: lua_assert(0); break; } }