38#if !defined(LUA_USE_JUMPTABLE)
40#define LUA_USE_JUMPTABLE 1
42#define LUA_USE_JUMPTABLE 0
49#define MAXTAGLOOP 2000
58#define NBM (l_floatatt(MANT_DIG))
67#if ((((LUA_MAXINTEGER >> (NBM / 4)) >> (NBM / 4)) >> (NBM / 4)) \
68 >> (NBM - (3 * (NBM / 4)))) > 0
71#define MAXINTFITSF ((lua_Unsigned)1 << NBM)
74#define l_intfitsf(i) ((MAXINTFITSF + l_castS2U(i)) <= (2 * MAXINTFITSF))
78#define l_intfitsf(i) 1
124 if (mode ==
F2Ieq)
return 0;
185 if (step < 0)
return 1;
189 if (step > 0)
return 1;
193 return (step > 0 ? init > *p : init < *p);
217 if (
forlimit(L, init, plimit, &limit, step))
238 if (l_unlikely(!
tonumber(plimit, &limit)))
240 if (l_unlikely(!
tonumber(pstep, &step)))
242 if (l_unlikely(!
tonumber(pinit, &init)))
295 if (l_unlikely(
notm(tm)))
349 if (l_unlikely(
notm(tm)))
364 luaG_runerror(L,
"'__newindex' chain too long; possible loop");
376 const char *l =
getstr(ls);
378 const char *r =
getstr(rs);
381 int temp = strcoll(l, r);
385 size_t len = strlen(l);
387 return (len == ll) ? 0 : 1;
392 l += len; ll -= len; r += len; lr -= len;
591 else if (L ==
NULL)
return 0;
599 else if (L ==
NULL)
return 0;
618#define tostring(L,o) \
619 (ttisstring(o) || (cvt2str(o) && (luaO_tostring(L, o), 1)))
621#define isemptystr(o) (ttisshrstring(o) && tsvalue(o)->shrlen == 0)
628 memcpy(buff + tl,
svalue(
s2v(top - n)), l *
sizeof(
char));
657 for (n = 1; n < total &&
tostring(L,
s2v(top - n - 1)); n++) {
659 if (l_unlikely(l >= (
MAX_SIZE/
sizeof(
char)) - tl))
703 if (l_unlikely(
notm(tm)))
719 if (l_unlikely(
l_castS2U(n) + 1u <= 1u)) {
722 return intop(-, 0, m);
726 if ((m ^ n) < 0 && m % n != 0)
739 if (l_unlikely(
l_castS2U(n) + 1u <= 1u)) {
746 if (r != 0 && (r ^ n) < 0)
764#define NBITS cast_int(sizeof(lua_Integer) * CHAR_BIT)
769#define luaV_shiftr(x,y) luaV_shiftl(x,-(y))
773 if (y <= -
NBITS)
return 0;
774 else return intop(>>, x, -y);
777 if (y >=
NBITS)
return 0;
778 else return intop(<<, x, y);
795 for (i = 0; i < nup; i++) {
830#if defined(LUA_COMPAT_LT_LE)
844 int total =
cast_int(top - 1 - (base +
a));
873#define l_addi(L,a,b) intop(+, a, b)
874#define l_subi(L,a,b) intop(-, a, b)
875#define l_muli(L,a,b) intop(*, a, b)
876#define l_band(a,b) intop(&, a, b)
877#define l_bor(a,b) intop(|, a, b)
878#define l_bxor(a,b) intop(^, a, b)
880#define l_lti(a,b) (a < b)
881#define l_lei(a,b) (a <= b)
882#define l_gti(a,b) (a > b)
883#define l_gei(a,b) (a >= b)
890#define op_arithI(L,iop,fop) { \
891 TValue *v1 = vRB(i); \
892 int imm = GETARG_sC(i); \
893 if (ttisinteger(v1)) { \
894 lua_Integer iv1 = ivalue(v1); \
895 pc++; setivalue(s2v(ra), iop(L, iv1, imm)); \
897 else if (ttisfloat(v1)) { \
898 lua_Number nb = fltvalue(v1); \
899 lua_Number fimm = cast_num(imm); \
900 pc++; setfltvalue(s2v(ra), fop(L, nb, fimm)); \
908#define op_arithf_aux(L,v1,v2,fop) { \
909 lua_Number n1; lua_Number n2; \
910 if (tonumberns(v1, n1) && tonumberns(v2, n2)) { \
911 pc++; setfltvalue(s2v(ra), fop(L, n1, n2)); \
918#define op_arithf(L,fop) { \
919 TValue *v1 = vRB(i); \
920 TValue *v2 = vRC(i); \
921 op_arithf_aux(L, v1, v2, fop); }
927#define op_arithfK(L,fop) { \
928 TValue *v1 = vRB(i); \
929 TValue *v2 = KC(i); lua_assert(ttisnumber(v2)); \
930 op_arithf_aux(L, v1, v2, fop); }
936#define op_arith_aux(L,v1,v2,iop,fop) { \
937 if (ttisinteger(v1) && ttisinteger(v2)) { \
938 lua_Integer i1 = ivalue(v1); lua_Integer i2 = ivalue(v2); \
939 pc++; setivalue(s2v(ra), iop(L, i1, i2)); \
941 else op_arithf_aux(L, v1, v2, fop); }
947#define op_arith(L,iop,fop) { \
948 TValue *v1 = vRB(i); \
949 TValue *v2 = vRC(i); \
950 op_arith_aux(L, v1, v2, iop, fop); }
956#define op_arithK(L,iop,fop) { \
957 TValue *v1 = vRB(i); \
958 TValue *v2 = KC(i); lua_assert(ttisnumber(v2)); \
959 op_arith_aux(L, v1, v2, iop, fop); }
965#define op_bitwiseK(L,op) { \
966 TValue *v1 = vRB(i); \
967 TValue *v2 = KC(i); \
969 lua_Integer i2 = ivalue(v2); \
970 if (tointegerns(v1, &i1)) { \
971 pc++; setivalue(s2v(ra), op(i1, i2)); \
978#define op_bitwise(L,op) { \
979 TValue *v1 = vRB(i); \
980 TValue *v2 = vRC(i); \
981 lua_Integer i1; lua_Integer i2; \
982 if (tointegerns(v1, &i1) && tointegerns(v2, &i2)) { \
983 pc++; setivalue(s2v(ra), op(i1, i2)); \
992#define op_order(L,opi,opn,other) { \
994 TValue *rb = vRB(i); \
995 if (ttisinteger(s2v(ra)) && ttisinteger(rb)) { \
996 lua_Integer ia = ivalue(s2v(ra)); \
997 lua_Integer ib = ivalue(rb); \
998 cond = opi(ia, ib); \
1000 else if (ttisnumber(s2v(ra)) && ttisnumber(rb)) \
1001 cond = opn(s2v(ra), rb); \
1003 Protect(cond = other(L, s2v(ra), rb)); \
1011#define op_orderI(L,opi,opf,inv,tm) { \
1013 int im = GETARG_sB(i); \
1014 if (ttisinteger(s2v(ra))) \
1015 cond = opi(ivalue(s2v(ra)), im); \
1016 else if (ttisfloat(s2v(ra))) { \
1017 lua_Number fa = fltvalue(s2v(ra)); \
1018 lua_Number fim = cast_num(im); \
1019 cond = opf(fa, fim); \
1022 int isf = GETARG_C(i); \
1023 Protect(cond = luaT_callorderiTM(L, s2v(ra), im, inv, isf, tm)); \
1041#define RA(i) (base+GETARG_A(i))
1042#define RB(i) (base+GETARG_B(i))
1043#define vRB(i) s2v(RB(i))
1044#define KB(i) (k+GETARG_B(i))
1045#define RC(i) (base+GETARG_C(i))
1046#define vRC(i) s2v(RC(i))
1047#define KC(i) (k+GETARG_C(i))
1048#define RKC(i) ((TESTARG_k(i)) ? k + GETARG_C(i) : s2v(base + GETARG_C(i)))
1052#define updatetrap(ci) (trap = ci->u.l.trap)
1054#define updatebase(ci) (base = ci->func + 1)
1057#define updatestack(ci) \
1058 { if (l_unlikely(trap)) { updatebase(ci); ra = RA(i); } }
1065#define dojump(ci,i,e) { pc += GETARG_sJ(i) + e; updatetrap(ci); }
1069#define donextjump(ci) { Instruction ni = *pc; dojump(ci, ni, 1); }
1076#define docondjump() if (cond != GETARG_k(i)) pc++; else donextjump(ci);
1082#define savepc(L) (ci->u.l.savedpc = pc)
1089#define savestate(L,ci) (savepc(L), L->top = ci->top)
1096#define Protect(exp) (savestate(L,ci), (exp), updatetrap(ci))
1099#define ProtectNT(exp) (savepc(L), (exp), updatetrap(ci))
1105#define halfProtect(exp) (savestate(L,ci), (exp))
1108#define checkGC(L,c) \
1109 { luaC_condGC(L, (savepc(L), L->top = (c)), \
1111 luai_threadyield(L); }
1115#define vmfetch() { \
1116 if (l_unlikely(trap)) { \
1117 trap = luaG_traceexec(L, pc); \
1124#define vmdispatch(o) switch(o)
1125#define vmcase(l) case l:
1126#define vmbreak break
1135#if LUA_USE_JUMPTABLE
1144 if (l_unlikely(trap)) {
1145 if (pc == cl->
p->
code) {
1153 base = ci->
func + 1;
1340 if (b != 0 || c != 0)
1637 int delta = (nparams1) ? ci->
u.
l.
nextraargs + nparams1 : 0;
1697 for (nres = ci->
nresults; l_unlikely(nres > 0); nres--)
1717 for (; l_unlikely(nres > 1); nres--)
1736 idx =
intop(+, idx, step);
1769 memcpy(ra + 4, ra, 3 *
sizeof(*ra));
1770 L->
top = ra + 4 + 3;
1800 for (; n > 0; n--) {
1821 if (l_unlikely(trap)) {
void luaG_runerror(lua_State *L, const char *fmt,...)
void luaG_typeerror(lua_State *L, const TValue *o, const char *op)
int luaD_precall(lua_State *L, StkId func, int nresults)
void luaD_call(lua_State *L, StkId func, int nResults)
int luaD_poscall(lua_State *L, StkId firstResult)
Closure * luaF_newLclosure(lua_State *L, int nelems, Table *e)
UpVal * luaF_findupval(lua_State *L, StkId level)
void luaF_close(lua_State *L, StkId level)
#define luaC_barrier(L, p, v)
#define luaC_objbarrier(L, p, o)
#define setobj(L, obj1, obj2)
static int cond(LexState *ls)
TString * luaS_newlstr(lua_State *L, const char *str, size_t l)
const TValue * luaH_get(Table *t, const TValue *key)
Table * luaH_new(lua_State *L, int narray, int nhash)
const TValue * luaH_getstr(Table *t, TString *key)
void luaH_resizearray(lua_State *L, Table *t, int nasize)
const TValue * luaT_gettmbyobj(lua_State *L, const TValue *o, TMS event)
#define luaC_barrierback(L, p, v)
int luaS_eqlngstr(TString *a, TString *b)
void luaH_resize(lua_State *L, Table *t, int nasize, int nhsize)
#define invalidateTMcache(t)
LUA_UNSIGNED lua_Unsigned
#define luaV_rawequalobj(o1, o2)
#define luai_nummul(L, a, b)
#define luai_numdiv(L, a, b)
#define luai_numpow(L, a, b)
#define luai_numunm(L, a)
#define luai_numsub(L, a, b)
#define luai_numidiv(L, a, b)
#define luai_nummod(L, a, b, m)
#define luai_numadd(L, a, b)
size_t luaO_str2num(const char *s, TValue *o)
#define chgivalue(obj, x)
#define setfltvalue(obj, x)
#define setivalue(obj, x)
#define chgfltvalue(obj, x)
TString * luaS_createlngstrobj(lua_State *L, size_t l)
const TValue * luaH_getshortstr(Table *t, TString *key)
void luaT_trybinTM(lua_State *L, const TValue *p1, const TValue *p2, StkId res, TMS event)
void luaT_callTM(lua_State *L, const TValue *f, const TValue *p1, const TValue *p2, TValue *p3, int hasres)
int luaT_callorderTM(lua_State *L, const TValue *p1, const TValue *p2, TMS event)
#define lua_numbertointeger(n, p)
#define luaV_fastget(L, t, k, slot, f)
#define intop(op, v1, v2)
l_noret luaG_forerror(lua_State *L, const TValue *o, const char *what)
void luaD_pretailcall(lua_State *L, CallInfo *ci, StkId func, int narg1)
void luaD_hookcall(lua_State *L, CallInfo *ci)
void luaD_tryfuncTM(lua_State *L, StkId func)
#define checkstackGCp(L, n, p)
void luaF_newtbcupval(lua_State *L, StkId level)
void luaF_closeupval(lua_State *L, StkId level)
#define LUA_VLIGHTUSERDATA
#define setclLvalue2s(L, o, cl)
void luaH_finishset(lua_State *L, Table *t, const TValue *key, const TValue *slot, TValue *value)
LUAI_FUNC unsigned int luaH_realasize(const Table *t)
void luaT_adjustvarargs(lua_State *L, int nfixparams, CallInfo *ci, const Proto *p)
void luaT_trybiniTM(lua_State *L, const TValue *p1, lua_Integer i2, int flip, StkId res, TMS event)
void luaT_trybinassocTM(lua_State *L, const TValue *p1, const TValue *p2, int flip, StkId res, TMS event)
void luaT_callTMres(lua_State *L, const TValue *f, const TValue *p1, const TValue *p2, StkId res)
void luaT_getvarargs(lua_State *L, CallInfo *ci, StkId where, int wanted)
void luaT_tryconcatTM(lua_State *L)
int luaV_lessequal(lua_State *L, const TValue *l, const TValue *r)
static int lessthanothers(lua_State *L, const TValue *l, const TValue *r)
#define luaV_shiftr(x, y)
void luaV_finishset(lua_State *L, const TValue *t, TValue *key, TValue *val, const TValue *slot)
static int LTnum(const TValue *l, const TValue *r)
void luaV_execute(lua_State *L, CallInfo *ci)
static int LEfloatint(lua_Number f, lua_Integer i)
#define op_arithfK(L, fop)
void luaV_concat(lua_State *L, int total)
#define op_arithf(L, fop)
int luaV_flttointeger(lua_Number n, lua_Integer *p, F2Imod mode)
#define op_order(L, opi, opn, other)
void luaV_finishget(lua_State *L, const TValue *t, TValue *key, StkId val, const TValue *slot)
int luaV_equalobj(lua_State *L, const TValue *t1, const TValue *t2)
static void pushclosure(lua_State *L, Proto *p, UpVal **encup, StkId base, StkId ra)
static int LTfloatint(lua_Number f, lua_Integer i)
#define op_bitwiseK(L, op)
#define op_arithI(L, iop, fop)
#define op_bitwise(L, op)
static int forlimit(lua_State *L, lua_Integer init, const TValue *lim, lua_Integer *p, lua_Integer step)
static void copy2buff(StkId top, int n, char *buff)
int luaV_lessthan(lua_State *L, const TValue *l, const TValue *r)
lua_Integer luaV_idiv(lua_State *L, lua_Integer m, lua_Integer n)
void luaV_finishOp(lua_State *L)
static int forprep(lua_State *L, StkId ra)
int luaV_tointeger(const TValue *obj, lua_Integer *p, F2Imod mode)
static int lessequalothers(lua_State *L, const TValue *l, const TValue *r)
static int LEnum(const TValue *l, const TValue *r)
void luaV_objlen(lua_State *L, StkId ra, const TValue *rb)
static int LEintfloat(lua_Integer i, lua_Number f)
lua_Number luaV_modf(lua_State *L, lua_Number m, lua_Number n)
#define op_orderI(L, opi, opf, inv, tm)
#define op_arith(L, iop, fop)
static int l_strton(const TValue *obj, TValue *result)
lua_Integer luaV_shiftl(lua_Integer x, lua_Integer y)
int luaV_tonumber_(const TValue *obj, lua_Number *n)
static int floatforloop(StkId ra)
static int LTintfloat(lua_Integer i, lua_Number f)
int luaV_tointegerns(const TValue *obj, lua_Integer *p, F2Imod mode)
lua_Integer luaV_mod(lua_State *L, lua_Integer m, lua_Integer n)
static int l_strcmp(const TString *ls, const TString *rs)
#define op_arithK(L, iop, fop)
#define tointegerns(o, i)
#define luaV_fastgeti(L, t, k, slot)
#define luaV_finishfastset(L, t, slot, v)
struct CallInfo * previous
struct CallInfo::@64::@65 l
const Instruction * savedpc
const Instruction * oldpc