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))
367 luaG_runerror(L,
"'__newindex' chain too long; possible loop");
379 const char *l =
getstr(ls);
381 const char *r =
getstr(rs);
384 int temp = strcoll(l, r);
388 size_t len = strlen(l);
390 return (len == ll) ? 0 : 1;
589 else if (L == NULL)
return 0;
597 else if (L == NULL)
return 0;
616 #define tostring(L,o) \ 617 (ttisstring(o) || (cvt2str(o) && (luaO_tostring(L, o), 1))) 619 #define isemptystr(o) (ttisshrstring(o) && tsvalue(o)->shrlen == 0) 626 memcpy(buff + tl,
svalue(
s2v(top - n)), l *
sizeof(
char));
655 for (n = 1; n < total &&
tostring(L,
s2v(top - n - 1)); n++) {
720 return intop(-, 0, m);
724 if ((m ^ n) < 0 && m % n != 0)
744 if (r != 0 && (r ^ n) < 0)
762 #define NBITS cast_int(sizeof(lua_Integer) * CHAR_BIT) 767 #define luaV_shiftr(x,y) luaV_shiftl(x,-(y)) 771 if (y <= -
NBITS)
return 0;
772 else return intop(>>, x, -y);
775 if (y >=
NBITS)
return 0;
776 else return intop(<<, x, y);
793 for (i = 0; i < nup; i++) {
828 #if defined(LUA_COMPAT_LT_LE) 842 int total =
cast_int(top - 1 - (base + a));
867 #define l_addi(L,a,b) intop(+, a, b) 868 #define l_subi(L,a,b) intop(-, a, b) 869 #define l_muli(L,a,b) intop(*, a, b) 870 #define l_band(a,b) intop(&, a, b) 871 #define l_bor(a,b) intop(|, a, b) 872 #define l_bxor(a,b) intop(^, a, b) 874 #define l_lti(a,b) (a < b) 875 #define l_lei(a,b) (a <= b) 876 #define l_gti(a,b) (a > b) 877 #define l_gei(a,b) (a >= b) 884 #define op_arithI(L,iop,fop) { \ 885 TValue *v1 = vRB(i); \ 886 int imm = GETARG_sC(i); \ 887 if (ttisinteger(v1)) { \ 888 lua_Integer iv1 = ivalue(v1); \ 889 pc++; setivalue(s2v(ra), iop(L, iv1, imm)); \ 891 else if (ttisfloat(v1)) { \ 892 lua_Number nb = fltvalue(v1); \ 893 lua_Number fimm = cast_num(imm); \ 894 pc++; setfltvalue(s2v(ra), fop(L, nb, fimm)); \ 902 #define op_arithf_aux(L,v1,v2,fop) { \ 903 lua_Number n1; lua_Number n2; \ 904 if (tonumberns(v1, n1) && tonumberns(v2, n2)) { \ 905 pc++; setfltvalue(s2v(ra), fop(L, n1, n2)); \ 912 #define op_arithf(L,fop) { \ 913 TValue *v1 = vRB(i); \ 914 TValue *v2 = vRC(i); \ 915 op_arithf_aux(L, v1, v2, fop); } 921 #define op_arithfK(L,fop) { \ 922 TValue *v1 = vRB(i); \ 923 TValue *v2 = KC(i); \ 924 op_arithf_aux(L, v1, v2, fop); } 930 #define op_arith_aux(L,v1,v2,iop,fop) { \ 931 if (ttisinteger(v1) && ttisinteger(v2)) { \ 932 lua_Integer i1 = ivalue(v1); lua_Integer i2 = ivalue(v2); \ 933 pc++; setivalue(s2v(ra), iop(L, i1, i2)); \ 935 else op_arithf_aux(L, v1, v2, fop); } 941 #define op_arith(L,iop,fop) { \ 942 TValue *v1 = vRB(i); \ 943 TValue *v2 = vRC(i); \ 944 op_arith_aux(L, v1, v2, iop, fop); } 950 #define op_arithK(L,iop,fop) { \ 951 TValue *v1 = vRB(i); \ 952 TValue *v2 = KC(i); \ 953 op_arith_aux(L, v1, v2, iop, fop); } 959 #define op_bitwiseK(L,op) { \ 960 TValue *v1 = vRB(i); \ 961 TValue *v2 = KC(i); \ 963 lua_Integer i2 = ivalue(v2); \ 964 if (tointegerns(v1, &i1)) { \ 965 pc++; setivalue(s2v(ra), op(i1, i2)); \ 972 #define op_bitwise(L,op) { \ 973 TValue *v1 = vRB(i); \ 974 TValue *v2 = vRC(i); \ 975 lua_Integer i1; lua_Integer i2; \ 976 if (tointegerns(v1, &i1) && tointegerns(v2, &i2)) { \ 977 pc++; setivalue(s2v(ra), op(i1, i2)); \ 986 #define op_order(L,opi,opn,other) { \ 988 TValue *rb = vRB(i); \ 989 if (ttisinteger(s2v(ra)) && ttisinteger(rb)) { \ 990 lua_Integer ia = ivalue(s2v(ra)); \ 991 lua_Integer ib = ivalue(rb); \ 992 cond = opi(ia, ib); \ 994 else if (ttisnumber(s2v(ra)) && ttisnumber(rb)) \ 995 cond = opn(s2v(ra), rb); \ 997 Protect(cond = other(L, s2v(ra), rb)); \ 1005 #define op_orderI(L,opi,opf,inv,tm) { \ 1007 int im = GETARG_sB(i); \ 1008 if (ttisinteger(s2v(ra))) \ 1009 cond = opi(ivalue(s2v(ra)), im); \ 1010 else if (ttisfloat(s2v(ra))) { \ 1011 lua_Number fa = fltvalue(s2v(ra)); \ 1012 lua_Number fim = cast_num(im); \ 1013 cond = opf(fa, fim); \ 1016 int isf = GETARG_C(i); \ 1017 Protect(cond = luaT_callorderiTM(L, s2v(ra), im, inv, isf, tm)); \ 1035 #define RA(i) (base+GETARG_A(i)) 1036 #define RB(i) (base+GETARG_B(i)) 1037 #define vRB(i) s2v(RB(i)) 1038 #define KB(i) (k+GETARG_B(i)) 1039 #define RC(i) (base+GETARG_C(i)) 1040 #define vRC(i) s2v(RC(i)) 1041 #define KC(i) (k+GETARG_C(i)) 1042 #define RKC(i) ((TESTARG_k(i)) ? k + GETARG_C(i) : s2v(base + GETARG_C(i))) 1046 #define updatetrap(ci) (trap = ci->u.l.trap) 1048 #define updatebase(ci) (base = ci->func + 1) 1051 #define updatestack(ci) { if (trap) { updatebase(ci); ra = RA(i); } } 1058 #define dojump(ci,i,e) { pc += GETARG_sJ(i) + e; updatetrap(ci); } 1062 #define donextjump(ci) { Instruction ni = *pc; dojump(ci, ni, 1); } 1069 #define docondjump() if (cond != GETARG_k(i)) pc++; else donextjump(ci); 1075 #define savepc(L) (ci->u.l.savedpc = pc) 1082 #define savestate(L,ci) (savepc(L), L->top = ci->top) 1089 #define Protect(exp) (savestate(L,ci), (exp), updatetrap(ci)) 1092 #define ProtectNT(exp) (savepc(L), (exp), updatetrap(ci)) 1099 #define halfProtect(exp) (savestate(L,ci), (exp)) 1102 #define halfProtectNT(exp) (savepc(L), (exp)) 1105 #define checkGC(L,c) \ 1106 { luaC_condGC(L, (savepc(L), L->top = (c)), \ 1108 luai_threadyield(L); } 1112 #define vmfetch() { \ 1114 trap = luaG_traceexec(L, pc); \ 1121 #define vmdispatch(o) switch(o) 1122 #define vmcase(l) case l: 1123 #define vmbreak break 1132 #if LUA_USE_JUMPTABLE 1139 pc = ci->
u.
l.savedpc;
1143 else if (pc == cl->
p->
code)
1147 base = ci->
func + 1;
1332 if (b != 0 || c != 0)
1621 int delta = (nparams1) ? ci->
u.
l.nextraargs + nparams1 : 0;
1665 ci->
func -= ci->
u.
l.nextraargs + nparams1;
1710 idx =
intop(+, idx, step);
1743 memcpy(ra + 4, ra, 3 *
sizeof(*ra));
1744 L->
top = ra + 4 + 3;
1774 for (; n > 0; n--) {
unsigned short callstatus
static int lessthanothers(lua_State *L, const TValue *l, const TValue *r)
int luaV_tointeger(const TValue *obj, lua_Integer *p, F2Imod mode)
#define halfProtectNT(exp)
static int lessequalothers(lua_State *L, const TValue *l, const TValue *r)
#define luaV_fastget(L, t, k, slot, f)
#define luai_numunm(L, a)
LClosure * luaF_newLclosure(lua_State *L, int nupvals)
int luaF_close(lua_State *L, StkId level, int status)
#define op_arithK(L, iop, fop)
lua_Integer luaV_idiv(lua_State *L, lua_Integer m, lua_Integer n)
void luaT_trybiniTM(lua_State *L, const TValue *p1, lua_Integer i2, int flip, StkId res, TMS event)
#define op_bitwiseK(L, op)
void luaD_hookcall(lua_State *L, CallInfo *ci)
lua_Number luaV_modf(lua_State *L, lua_Number m, lua_Number n)
int luaV_lessequal(lua_State *L, const TValue *l, const TValue *r)
#define invalidateTMcache(t)
static int l_strton(const TValue *obj, TValue *result)
#define luai_numsub(L, a, b)
static void pushclosure(lua_State *L, Proto *p, UpVal **encup, StkId base, StkId ra)
const TValue * luaH_getstr(Table *t, TString *key)
#define luai_nummod(L, a, b, m)
#define op_order(L, opi, opn, other)
l_noret luaG_typeerror(lua_State *L, const TValue *o, const char *op)
void luaD_call(lua_State *L, StkId func, int nresults)
int luaV_equalobj(lua_State *L, const TValue *t1, const TValue *t2)
#define op_arithf(L, fop)
#define intop(op, v1, v2)
lua_Integer luaV_shiftl(lua_Integer x, lua_Integer y)
const TValue * luaH_getshortstr(Table *t, TString *key)
#define luaV_shiftr(x, y)
#define luaC_barrier(L, p, v)
TString * luaS_newlstr(lua_State *L, const char *str, size_t l)
static int forprep(lua_State *L, StkId ra)
static int cond(LexState *ls)
#define op_arithfK(L, fop)
#define setclLvalue2s(L, o, cl)
void luaT_adjustvarargs(lua_State *L, int nfixparams, CallInfo *ci, const Proto *p)
#define tointegerns(o, i)
TString * luaS_createlngstrobj(lua_State *L, size_t l)
#define op_orderI(L, opi, opf, inv, tm)
TValue * luaH_newkey(lua_State *L, Table *t, const TValue *key)
static int l_strcmp(const TString *ls, const TString *rs)
static int LEintfloat(lua_Integer i, lua_Number f)
void luaH_resize(lua_State *L, Table *t, unsigned int newasize, unsigned int nhsize)
void luaT_trybinassocTM(lua_State *L, const TValue *p1, const TValue *p2, int flip, StkId res, TMS event)
static int floatforloop(StkId ra)
#define lua_numbertointeger(n, p)
void luaD_poscall(lua_State *L, CallInfo *ci, int nres)
const TValue * luaT_gettmbyobj(lua_State *L, const TValue *o, TMS event)
static void copy2buff(StkId top, int n, char *buff)
#define luai_numpow(L, a, b)
volatile l_signalT hookmask
#define luaV_fastgeti(L, t, k, slot)
#define luai_numidiv(L, a, b)
l_noret luaG_runerror(lua_State *L, const char *fmt,...)
void luaD_pretailcall(lua_State *L, CallInfo *ci, StkId func, int narg1)
#define checkstackGCp(L, n, p)
#define LUA_VLIGHTUSERDATA
#define setsvalue2s(L, o, s)
Table * luaH_new(lua_State *L)
static int LEfloatint(lua_Number f, lua_Integer i)
l_noret luaG_forerror(lua_State *L, const TValue *o, const char *what)
void luaF_newtbcupval(lua_State *L, StkId level)
void luaV_execute(lua_State *L, CallInfo *ci)
void luaV_objlen(lua_State *L, StkId ra, const TValue *rb)
lua_Unsigned luaH_getn(Table *t)
#define op_arithI(L, iop, fop)
#define setivalue(obj, x)
basic_metatable< reference > metatable
#define setobj(L, obj1, obj2)
lua_Integer luaV_mod(lua_State *L, lua_Integer m, lua_Integer n)
#define luai_numadd(L, a, b)
void luaV_finishget(lua_State *L, const TValue *t, TValue *key, StkId val, const TValue *slot)
#define chgivalue(obj, x)
#define setfltvalue(obj, x)
int luaV_tonumber_(const TValue *obj, lua_Number *n)
#define luai_nummul(L, a, b)
int luaT_callorderTM(lua_State *L, const TValue *p1, const TValue *p2, TMS event)
int luaV_tointegerns(const TValue *obj, lua_Integer *p, F2Imod mode)
void luaH_resizearray(lua_State *L, Table *t, unsigned int nasize)
#define luaC_barrierback(L, p, v)
void luaV_finishset(lua_State *L, const TValue *t, TValue *key, TValue *val, const TValue *slot)
LUA_UNSIGNED lua_Unsigned
void luaT_getvarargs(lua_State *L, CallInfo *ci, StkId where, int wanted)
#define luai_numdiv(L, a, b)
int luaV_flttointeger(lua_Number n, lua_Integer *p, F2Imod mode)
UpVal * luaF_findupval(lua_State *L, StkId level)
void luaT_tryconcatTM(lua_State *L)
void luaV_concat(lua_State *L, int total)
#define op_bitwise(L, op)
struct CallInfo * previous
static int LTnum(const TValue *l, const TValue *r)
#define sethvalue2s(L, o, h)
static int LTintfloat(lua_Integer i, lua_Number f)
int luaV_lessthan(lua_State *L, const TValue *l, const TValue *r)
#define setobjs2s(L, o1, o2)
void luaT_callTM(lua_State *L, const TValue *f, const TValue *p1, const TValue *p2, const TValue *p3)
size_t luaO_str2num(const char *s, TValue *o)
LUAI_FUNC unsigned int luaH_realasize(const Table *t)
#define chgfltvalue(obj, x)
void luaT_callTMres(lua_State *L, const TValue *f, const TValue *p1, const TValue *p2, StkId res)
static int forlimit(lua_State *L, lua_Integer init, const TValue *lim, lua_Integer *p, lua_Integer step)
void luaV_finishOp(lua_State *L)
#define luaC_objbarrier(L, p, o)
const TValue * luaH_get(Table *t, const TValue *key)
int luaS_eqlngstr(TString *a, TString *b)
#define luaV_rawequalobj(t1, t2)
void luaD_tryfuncTM(lua_State *L, StkId func)
void luaT_trybinTM(lua_State *L, const TValue *p1, const TValue *p2, StkId res, TMS event)
static int LTfloatint(lua_Number f, lua_Integer i)
#define op_arith(L, iop, fop)
#define setobj2s(L, o1, o2)
struct CallInfo::@30::@32 l
#define luaV_finishfastset(L, t, slot, v)
static int LEnum(const TValue *l, const TValue *r)