46 #define isvalid(L, o) (!ttisnil(o) || o != &G(L)->nilvalue) 50 #define ispseudo(i) ((i) <= LUA_REGISTRYINDEX) 53 #define isupvalue(i) ((i) < LUA_REGISTRYINDEX) 61 if (o >= L->
top)
return &
G(L)->nilvalue;
69 return &
G(L)->l_registry;
74 return &
G(L)->nilvalue;
77 return (idx <= func->nupvalues) ? &func->
upvalue[idx-1] : &
G(L)->nilvalue;
113 if (res && ci->
top < L->
top + n)
122 if (from == to)
return;
125 api_check(from,
G(from) ==
G(to),
"moving among independent states");
128 for (i = 0; i < n; i++) {
140 G(L)->panic = panicf;
181 api_check(L, idx <= ci->
top - (func + 1),
"new top too large");
182 diff = ((func + 1) + idx) - L->
top;
183 for (; diff > 0; diff--)
187 api_check(L, -(idx+1) <= (L->
top - (func + 1)),
"invalid new top");
204 for (; from < to; from++, to--) {
222 api_check(L, (n >= 0 ? n : -n) <= (t - p + 1),
"invalid 'n'");
223 m = (n >= 0 ? t - n : p - n - 1);
339 default:
api_check(L, 0,
"invalid option");
387 if (len != NULL) *len = 0;
427 default:
return NULL;
605 return (
G(L)->mainthread == L);
635 reg =
hvalue(&
G(L)->l_registry);
734 if (narray > 0 || nrec > 0)
747 switch (
ttype(obj)) {
749 mt =
hvalue(obj)->metatable;
752 mt =
uvalue(obj)->metatable;
755 mt =
G(L)->mt[
ttype(obj)];
774 if (n <= 0 || n >
uvalue(o)->nuvalue) {
816 reg =
hvalue(&
G(L)->l_registry);
913 switch (
ttype(obj)) {
915 hvalue(obj)->metatable = mt;
923 uvalue(obj)->metatable = mt;
931 G(L)->mt[
ttype(obj)] = mt;
966 #define checkresults(L,na,nr) \ 967 api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)), \ 968 "results from function overflow current stack size") 976 "cannot use continuations inside hooks");
980 func = L->
top - (nargs+1);
983 L->
ci->
u.
c.ctx = ctx;
1017 "cannot use continuations inside hooks");
1055 const char *chunkname,
const char *mode) {
1059 if (!chunkname) chunkname =
"?";
1064 if (f->nupvalues >= 1) {
1107 va_start(argp, what);
1132 int data = va_arg(argp,
int);
1151 int data = va_arg(argp,
int);
1157 int data = va_arg(argp,
int);
1167 int minormul = va_arg(argp,
int);
1168 int majormul = va_arg(argp,
int);
1178 int pause = va_arg(argp,
int);
1179 int stepmul = va_arg(argp,
int);
1180 int stepsize = va_arg(argp,
int);
1208 errobj =
s2v(L->
top - 1);
1244 "marked index below or equal new one");
1280 if (ud) *ud =
G(L)->ud;
1314 api_check(L, 0 <= nuvalue && nuvalue < USHRT_MAX,
"invalid value");
1333 if (owner) *owner =
obj2gco(f);
1345 return (name == NULL) ?
"(no name)" :
getstr(name);
1347 default:
return NULL;
1390 api_check(L, (1 <= n && n <= f->p->sizeupvalues),
"invalid upvalue index");
1392 return &f->
upvals[n - 1];
1404 api_check(L, 1 <= n && n <= f->nupvalues,
"invalid upvalue index");
1416 int fidx2,
int n2) {
#define isdecGCmodegen(g)
unsigned short callstatus
LUA_API int lua_isstring(lua_State *L, int idx)
LUA_API const char * lua_getupvalue(lua_State *L, int funcindex, int n)
LUA_API void lua_xmove(lua_State *from, lua_State *to, int n)
LUA_API int lua_dump(lua_State *L, lua_Writer writer, void *data, int strip)
#define setuvalue(L, obj, x)
LUA_API int lua_isinteger(lua_State *L, int idx)
LUA_API void lua_toclose(lua_State *L, int idx)
LUA_API int lua_rawget(lua_State *L, int idx)
LUA_API const char * lua_pushvfstring(lua_State *L, const char *fmt, va_list argp)
#define luaV_fastget(L, t, k, slot, f)
static Table * gettable(lua_State *L, int idx)
void luaC_checkfinalizer(lua_State *L, GCObject *o, Table *mt)
void luaD_callnoyield(lua_State *L, StkId func, int nResults)
void luaC_step(lua_State *L)
int luaU_dump(lua_State *L, const Proto *f, lua_Writer w, void *data, int strip)
int luaF_close(lua_State *L, StkId level, int status)
LUA_API void lua_pushnil(lua_State *L)
LUA_API int lua_isnumber(lua_State *L, int idx)
static UpVal ** getupvalref(lua_State *L, int fidx, int n, LClosure **pf)
LUA_KCONTEXT lua_KContext
LUA_API const void * lua_topointer(lua_State *L, int idx)
LUA_API int lua_rawgeti(lua_State *L, int idx, lua_Integer n)
LUA_API lua_Number lua_version(lua_State *L)
const TValue * luaH_getint(Table *t, lua_Integer key)
void lua_setwarnf(lua_State *L, lua_WarnFunction f, void *ud)
#define ttisfulluserdata(o)
int luaV_lessequal(lua_State *L, const TValue *l, const TValue *r)
LUA_API int lua_setmetatable(lua_State *L, int objindex)
LUA_API int lua_toboolean(lua_State *L, int idx)
LUA_API void lua_rawsetp(lua_State *L, int idx, const void *p)
#define invalidateTMcache(t)
LUA_API void lua_setallocf(lua_State *L, lua_Alloc f, void *ud)
LUA_API void lua_rawset(lua_State *L, int idx)
void *(* pf)(int, unsigned char, char *, size_t)
void luaC_changemode(lua_State *L, int newmode)
LUA_API void * lua_touserdata(lua_State *L, int idx)
int(* lua_Writer)(lua_State *L, const void *p, size_t sz, void *ud)
LUA_API void lua_seti(lua_State *L, int idx, lua_Integer n)
Udata * luaS_newudata(lua_State *L, size_t s, int nuvalue)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
static int writer(lua_State *L, const void *b, size_t size, void *ud)
#define ttislightuserdata(o)
static void * touserdata(const TValue *o)
LUA_API int lua_compare(lua_State *L, int index1, int index2, int op)
LUA_API lua_Integer lua_tointegerx(lua_State *L, int idx, int *pisnum)
const TValue * luaH_getstr(Table *t, TString *key)
#define LUA_TLIGHTUSERDATA
LUA_API int lua_setiuservalue(lua_State *L, int idx, int n)
LUA_API int lua_error(lua_State *L)
void luaD_call(lua_State *L, StkId func, int nresults)
int luaV_equalobj(lua_State *L, const TValue *t1, const TValue *t2)
static int auxgetstr(lua_State *L, const TValue *t, const char *k)
struct CallInfo::@30::@33 c
static StkId index2stack(lua_State *L, int idx)
LUA_API const char * lua_pushstring(lua_State *L, const char *s)
TString * luaS_newlstr(lua_State *L, const char *str, size_t l)
#define luaC_barrier(L, p, v)
LUA_API int lua_isuserdata(lua_State *L, int idx)
#define setfvalue(obj, x)
LUA_API lua_Number lua_tonumberx(lua_State *L, int idx, int *pisnum)
LUA_API int lua_geti(lua_State *L, int idx, lua_Integer n)
LUA_API void lua_pushvalue(lua_State *L, int idx)
LUA_API int lua_rawgetp(lua_State *L, int idx, const void *p)
LUA_API void lua_settop(lua_State *L, int idx)
LUA_API int lua_getmetatable(lua_State *L, int objindex)
static void f_call(lua_State *L, void *ud)
LUA_API void lua_upvaluejoin(lua_State *L, int fidx1, int n1, int fidx2, int n2)
LUA_API void lua_setglobal(lua_State *L, const char *name)
LUA_API int lua_getglobal(lua_State *L, const char *name)
void(* lua_WarnFunction)(void *ud, const char *msg, int tocont)
int luaD_protectedparser(lua_State *L, ZIO *z, const char *name, const char *mode)
static void reverse(lua_State *L, StkId from, StkId to)
void luaZ_init(lua_State *L, ZIO *z, lua_Reader reader, void *data)
LUA_API int lua_status(lua_State *L)
int(* lua_CFunction)(lua_State *L)
TValue * luaH_set(lua_State *L, Table *t, const TValue *key)
LUA_API lua_CFunction lua_atpanic(lua_State *L, lua_CFunction panicf)
void luaH_resize(lua_State *L, Table *t, unsigned int newasize, unsigned int nhsize)
LUA_API void lua_settable(lua_State *L, int idx)
LUA_API void * lua_upvalueid(lua_State *L, int fidx, int n)
void *(* lua_Alloc)(void *ud, void *ptr, size_t osize, size_t nsize)
LUA_API void lua_pushboolean(lua_State *L, int b)
LUA_API int lua_iscfunction(lua_State *L, int idx)
static void aux_rawset(lua_State *L, int idx, TValue *key, int n)
LUA_API void lua_rawseti(lua_State *L, int idx, lua_Integer n)
int(* lua_KFunction)(lua_State *L, int status, lua_KContext ctx)
#define luaV_fastgeti(L, t, k, slot)
int luaD_pcall(lua_State *L, Pfunc func, void *u, ptrdiff_t old_top, ptrdiff_t ef)
LUA_API int lua_pcallk(lua_State *L, int nargs, int nresults, int errfunc, lua_KContext ctx, lua_KFunction k)
LUA_API int lua_gc(lua_State *L, int what,...)
LUA_API lua_CFunction lua_tocfunction(lua_State *L, int idx)
LUA_API void lua_arith(lua_State *L, int op)
LUA_API int lua_pushthread(lua_State *L)
LUA_API int lua_getiuservalue(lua_State *L, int idx, int n)
#define LUA_VLIGHTUSERDATA
#define setsvalue2s(L, o, s)
Table * luaH_new(lua_State *L)
const char * luaO_pushvfstring(lua_State *L, const char *fmt, va_list argp)
void luaE_warning(lua_State *L, const char *msg, int tocont)
LUA_API lua_State * lua_tothread(lua_State *L, int idx)
LUA_API size_t lua_stringtonumber(lua_State *L, const char *s)
LUA_API const char * lua_tolstring(lua_State *L, int idx, size_t *len)
static const char * aux_upvalue(TValue *fi, int n, TValue **val, GCObject **owner)
void luaF_newtbcupval(lua_State *L, StkId level)
#define api_checknelems(L, n)
LUA_API int lua_next(lua_State *L, int idx)
LUA_API void lua_concat(lua_State *L, int n)
const char *(* lua_Reader)(lua_State *L, void *ud, size_t *sz)
void luaV_objlen(lua_State *L, StkId ra, const TValue *rb)
void luaE_setdebt(global_State *g, l_mem debt)
lua_Unsigned luaH_getn(Table *t)
#define setpvalue(obj, x)
LUA_API void * lua_newuserdatauv(lua_State *L, size_t size, int nuvalue)
#define setivalue(obj, x)
#define setobj(L, obj1, obj2)
LUA_API int lua_absindex(lua_State *L, int idx)
LUA_API int lua_type(lua_State *L, int idx)
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
void luaV_finishget(lua_State *L, const TValue *t, TValue *key, StkId val, const TValue *slot)
void luaO_tostring(lua_State *L, TValue *obj)
LUA_API void lua_callk(lua_State *L, int nargs, int nresults, lua_KContext ctx, lua_KFunction k)
#define setfltvalue(obj, x)
TString * luaS_new(lua_State *L, const char *str)
l_noret luaG_errormsg(lua_State *L)
#define setclCvalue(L, obj, x)
LUA_API void lua_copy(lua_State *L, int fromidx, int toidx)
static int finishrawget(lua_State *L, const TValue *val)
LUA_API void lua_pushcclosure(lua_State *L, lua_CFunction fn, int n)
#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
LUA_API void lua_rotate(lua_State *L, int idx, int n)
LUA_API int lua_load(lua_State *L, lua_Reader reader, void *data, const char *chunkname, const char *mode)
int luaD_growstack(lua_State *L, int n, int raiseerror)
LUA_API lua_Alloc lua_getallocf(lua_State *L, void **ud)
void luaV_concat(lua_State *L, int total)
void luaH_setint(lua_State *L, Table *t, lua_Integer key, TValue *value)
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
#define LUA_REGISTRYINDEX
LUA_API void lua_pushlightuserdata(lua_State *L, void *p)
#define hastocloseCfunc(n)
#define api_check(l, e, msg)
LUA_API void lua_len(lua_State *L, int idx)
#define sethvalue2s(L, o, h)
int luaH_next(lua_State *L, Table *t, StkId key)
LUA_API const char * lua_pushfstring(lua_State *L, const char *fmt,...)
LUA_API const char * lua_setupvalue(lua_State *L, int funcindex, int n)
int luaV_lessthan(lua_State *L, const TValue *l, const TValue *r)
LUA_API const char * lua_pushlstring(lua_State *L, const char *s, size_t len)
#define setobjs2s(L, o1, o2)
void lua_warning(lua_State *L, const char *msg, int tocont)
size_t luaO_str2num(const char *s, TValue *o)
CClosure * luaF_newCclosure(lua_State *L, int nupvals)
#define setthvalue(L, obj, x)
static void auxsetstr(lua_State *L, const TValue *t, const char *k)
LUA_API int lua_getfield(lua_State *L, int idx, const char *k)
#define luaC_objbarrier(L, p, o)
const TValue * luaH_get(Table *t, const TValue *key)
void luaC_fullgc(lua_State *L, int isemergency)
LUA_API void lua_pushnumber(lua_State *L, lua_Number n)
LUA_API int lua_rawequal(lua_State *L, int index1, int index2)
void luaO_arith(lua_State *L, int op, const TValue *p1, const TValue *p2, StkId res)
#define luaV_rawequalobj(t1, t2)
#define checkresults(L, na, nr)
#define setobj2s(L, o1, o2)
LUA_API int lua_checkstack(lua_State *L, int n)
LUA_API int lua_gettable(lua_State *L, int idx)
LUA_API int lua_gettop(lua_State *L)
#define luaV_finishfastset(L, t, slot, v)
LUA_API lua_Unsigned lua_rawlen(lua_State *L, int idx)
LUA_API const char * lua_typename(lua_State *L, int t)
#define adjustresults(L, nres)
static TValue * index2value(lua_State *L, int idx)