public static void luaK_prefix(FuncState fs, UnOpr op, expdesc e) { expdesc e2 = new expdesc(); e2.t = e2.f = NO_JUMP; e2.k = expkind.VKNUM; e2.u.nval = 0; switch (op) { case UnOpr.OPR_MINUS: { if (isnumeral(e) != 0 && e.u.nval != 0) /* minus non-zero constant? */ { e.u.nval = luai_numunm(null, e.u.nval); /* fold it */ } else { luaK_exp2anyreg(fs, e); codearith(fs, OpCode.OP_UNM, e, e2); } break; } case UnOpr.OPR_NOT: codenot(fs, e); break; case UnOpr.OPR_LEN: { luaK_exp2anyreg(fs, e); /* cannot operate on constants */ codearith(fs, OpCode.OP_LEN, e, e2); break; } default: lua_assert(0); break; } }
public static void luaK_prefix(FuncState fs, UnOpr op, expdesc e, int line) { expdesc e2 = new expdesc(); e2.t = e2.f = NO_JUMP; e2.k = expkind.VKFLT; e2.u.nval = 0; switch (op) { case UnOpr.OPR_MINUS: { if (0 == constfolding(OpCode.OP_UNM, e, e)) /* cannot fold it? */ { luaK_exp2anyreg(fs, e); codearith(fs, OpCode.OP_UNM, e, e2, line); } break; } case UnOpr.OPR_NOT: codenot(fs, e); break; case UnOpr.OPR_LEN: { luaK_exp2anyreg(fs, e); /* cannot operate on constants */ codearith(fs, OpCode.OP_LEN, e, e2, line); break; } default: lua_assert(0); break; } }
public static void luaK_prefix(FuncState fs, UnOpr op, expdesc e) { expdesc e2 = new expdesc(); e2.t = e2.f = NO_JUMP; e2.k = expkind.VKNUM; e2.u.nval = 0; switch (op) { case UnOpr.OPR_MINUS: { if (isnumeral(e) == 0) { luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */ } codearith(fs, OpCode.OP_UNM, e, e2); break; } case UnOpr.OPR_NOT: codenot(fs, e); break; case UnOpr.OPR_LEN: { luaK_exp2anyreg(fs, e); /* cannot operate on constants */ codearith(fs, OpCode.OP_LEN, e, e2); break; } default: lua_assert(0); break; } }
public static void LuaKPrefix(FuncState fs, UnOpr op, expdesc e) { expdesc e2 = new expdesc(); e2.t = e2.f = NO_JUMP; e2.k = expkind.VKNUM; e2.u.nval = 0; switch (op) { case UnOpr.OPR_MINUS: { if (IsNumeral(e) == 0) { LuaKExp2AnyReg(fs, e); /* cannot operate on non-numeric constants */ } CodeArith(fs, OpCode.OP_UNM, e, e2); break; } case UnOpr.OPR_NOT: CodeNot(fs, e); break; case UnOpr.OPR_LEN: { LuaKExp2AnyReg(fs, e); /* cannot operate on constants */ CodeArith(fs, OpCode.OP_LEN, e, e2); break; } default: LuaAssert(0); break; } }
public static void luaK_prefix(FuncState fs, UnOpr op, expdesc e, int line) { expdesc e2 = new expdesc(); e2.t = NO_JUMP; e2.f = NO_JUMP; e2.k = expkind.VKINT; e2.u.ival = 0; switch (op) { case UnOpr.OPR_MINUS: goto case UnOpr.OPR_LEN; case UnOpr.OPR_BNOT: goto case UnOpr.OPR_LEN; case UnOpr.OPR_LEN: { lcode.codeexpval(fs, OpCode.OP_UNM + (int)(op - UnOpr.OPR_MINUS), e, e2, line); break; } case UnOpr.OPR_NOT: { lcode.codenot(fs, e); break; } default: { lua_assert(false); break; } } }
public static void luaK_prefix(FuncState fs, UnOpr op, expdesc e, int line) { expdesc e2 = new expdesc(); e2.t = e2.f = NO_JUMP; e2.k = expkind.VKINT; e2.u.ival = 0; switch (op) { case UnOpr.OPR_MINUS: case UnOpr.OPR_BNOT: case UnOpr.OPR_LEN: { codeexpval(fs, (OpCode)((op - UnOpr.OPR_MINUS) + OpCode.OP_UNM), e, e2, line); break; } case UnOpr.OPR_NOT: codenot(fs, e); break; default: lua_assert(0); break; } }
public static void Prefix(FuncState fs, UnOpr op, ExpDesc e, int line) { ExpDesc e2 = new ExpDesc(); e2.ExitTrue = NO_JUMP; e2.ExitFalse = NO_JUMP; e2.Kind = ExpKind.VKNUM; e2.NumberValue = 0.0; switch (op) { case UnOpr.MINUS: { if (IsNumeral(e)) // minus constant? { e.NumberValue = -e.NumberValue; } else { Exp2AnyReg(fs, e); CodeArith(fs, OpCode.OP_UNM, e, e2, line); } } break; case UnOpr.NOT: { CodeNot(fs, e); } break; case UnOpr.LEN: { Exp2AnyReg(fs, e); // cannot operate on constants CodeArith(fs, OpCode.OP_LEN, e, e2, line); } break; default: throw new Exception("[Coder]Prefix Unknown UnOpr:" + op); } }
/* ** Aplly prefix operation 'op' to expression 'e'. */ public static void luaK_prefix(FuncState fs, UnOpr op, expdesc e, int line) { //static const expdesc ef = {VKINT, {0}, NO_JUMP, NO_JUMP}; switch (op) { case UnOpr.OPR_MINUS: case UnOpr.OPR_BNOT: /* use 'ef' as fake 2nd operand */ if (0 != constfolding(fs, (int)op + LUA_OPUNM, e, luaK_prefix_ef)) { break; } /* FALLTHROUGH */ goto case UnOpr.OPR_LEN; case UnOpr.OPR_LEN: codeunexpval(fs, (OpCode)((int)op + OpCode.OP_UNM), e, line); break; case UnOpr.OPR_NOT: codenot(fs, e); break; default: lua_assert(0); break; } }
public static void LuaKPrefix (FuncState fs, UnOpr op, expdesc e) { expdesc e2 = new expdesc(); e2.t = e2.f = NO_JUMP; e2.k = expkind.VKNUM; e2.u.nval = 0; switch (op) { case UnOpr.OPR_MINUS: { if (IsNumeral(e)==0) LuaKExp2AnyReg(fs, e); /* cannot operate on non-numeric constants */ CodeArith(fs, OpCode.OP_UNM, e, e2); break; } case UnOpr.OPR_NOT: CodeNot(fs, e); break; case UnOpr.OPR_LEN: { LuaKExp2AnyReg(fs, e); /* cannot operate on constants */ CodeArith(fs, OpCode.OP_LEN, e, e2); break; } default: LuaAssert(0); break; } }
public static void Prefix( FuncState fs, UnOpr op, ExpDesc e, int line ) { ExpDesc e2 = new ExpDesc(); e2.ExitTrue = NO_JUMP; e2.ExitFalse = NO_JUMP; e2.Kind = ExpKind.VKNUM; e2.NumberValue = 0.0; switch( op ) { case UnOpr.MINUS: { if( IsNumeral( e ) ) // minus constant? { e.NumberValue = -e.NumberValue; } else { Exp2AnyReg( fs, e ); CodeArith( fs, OpCode.OP_UNM, e, e2, line ); } } break; case UnOpr.NOT: { CodeNot( fs, e ); } break; case UnOpr.LEN: { Exp2AnyReg( fs, e ); // cannot operate on constants CodeArith( fs, OpCode.OP_LEN, e, e2, line ); } break; default: throw new Exception("[Coder]Prefix Unknown UnOpr:" + op); } }
/* ** 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_prefix (FuncState fs, UnOpr op, expdesc e) { expdesc e2 = new expdesc(); e2.t = e2.f = NO_JUMP; e2.k = expkind.VKNUM; e2.u.nval = 0; switch (op) { case UnOpr.OPR_MINUS: { if (isnumeral(e)==0) luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */ codearith(fs, OpCode.OP_UNM, e, e2); break; } case UnOpr.OPR_NOT: codenot(fs, e); break; case UnOpr.OPR_LEN: { luaK_exp2anyreg(fs, e); /* cannot operate on constants */ codearith(fs, OpCode.OP_LEN, e, e2); break; } default: lua_assert(0); break; } }