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;
65 api_check(L, idx != 0 && -idx <= L->top - (ci->
func + 1),
"invalid index");
69 return &
G(L)->l_registry;
74 return &
G(L)->nilvalue;
77 return (idx <= func->nupvalues) ? &func->
upvalue[idx-1] : &
G(L)->nilvalue;
87 api_check(L, o < L->top,
"unacceptable index");
91 api_check(L, idx != 0 && -idx <= L->top - (ci->
func + 1),
"invalid index");
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;
1386 static const UpVal *
const nullup = NULL;
1392 if (1 <= n && n <= f->
p->sizeupvalues)
1393 return &f->
upvals[n - 1];
1395 return (
UpVal**)&nullup;
1407 if (1 <= n && n <= f->nupvalues)
1422 int fidx2,
int n2) {
1426 api_check(L, *up1 != NULL && *up2 != NULL,
"invalid upvalue index");
#define isdecGCmodegen(g)
unsigned short callstatus
const char * luaO_pushvfstring(lua_State *L, const char *fmt, va_list argp)
void luaE_setdebt(global_State *g, l_mem debt)
void luaV_concat(lua_State *L, int total)
LUA_API lua_Alloc lua_getallocf(lua_State *L, void **ud)
LUA_API void lua_pushlightuserdata(lua_State *L, void *p)
LUA_API void lua_setallocf(lua_State *L, lua_Alloc f, void *ud)
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
#define setuvalue(L, obj, x)
struct CallInfo::@13::@16 c
static UpVal ** getupvalref(lua_State *L, int fidx, int n, LClosure **pf)
int luaH_next(lua_State *L, Table *t, StkId key)
LUA_API lua_Number lua_version(lua_State *L)
LUA_API lua_Number lua_tonumberx(lua_State *L, int idx, int *pisnum)
void luaC_changemode(lua_State *L, int newmode)
#define luaV_fastget(L, t, k, slot, f)
void luaC_checkfinalizer(lua_State *L, GCObject *o, Table *mt)
LUA_API void lua_settop(lua_State *L, int idx)
void luaV_finishget(lua_State *L, const TValue *t, TValue *key, StkId val, const TValue *slot)
LUA_API int lua_type(lua_State *L, int idx)
static TValue * index2value(lua_State *L, int idx)
LUA_API void lua_callk(lua_State *L, int nargs, int nresults, lua_KContext ctx, lua_KFunction k)
LUA_KCONTEXT lua_KContext
void luaC_step(lua_State *L)
LUA_API void lua_pushboolean(lua_State *L, int b)
LUA_API int lua_rawgeti(lua_State *L, int idx, lua_Integer n)
lua_Unsigned luaH_getn(Table *t)
#define ttisfulluserdata(o)
int luaD_growstack(lua_State *L, int n, int raiseerror)
static void f_call(lua_State *L, void *ud)
#define invalidateTMcache(t)
int luaU_dump(lua_State *L, const Proto *f, lua_Writer w, void *data, int strip)
int(* lua_Writer)(lua_State *L, const void *p, size_t sz, void *ud)
LUA_API void lua_rawseti(lua_State *L, int idx, lua_Integer n)
LUA_API int lua_gettop(lua_State *L)
const TValue * luaH_getstr(Table *t, TString *key)
LUA_API int lua_gettable(lua_State *L, int idx)
#define ttislightuserdata(o)
const TValue * luaH_get(Table *t, const TValue *key)
LUA_API int lua_getglobal(lua_State *L, const char *name)
LUA_API void lua_settable(lua_State *L, int idx)
LUA_API lua_CFunction lua_tocfunction(lua_State *L, int idx)
LUA_API int lua_rawget(lua_State *L, int idx)
#define LUA_TLIGHTUSERDATA
void luaV_objlen(lua_State *L, StkId ra, const TValue *rb)
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
LUA_API int lua_checkstack(lua_State *L, int n)
TValue * luaH_set(lua_State *L, Table *t, const TValue *key)
LUA_API int lua_isuserdata(lua_State *L, int idx)
LUA_API void lua_pushcclosure(lua_State *L, lua_CFunction fn, int n)
CClosure * luaF_newCclosure(lua_State *L, int nupvals)
#define luaC_barrier(L, p, v)
#define setfvalue(obj, x)
LUA_API int lua_absindex(lua_State *L, int idx)
l_noret luaG_errormsg(lua_State *L)
Udata * luaS_newudata(lua_State *L, size_t s, int nuvalue)
void luaO_arith(lua_State *L, int op, const TValue *p1, const TValue *p2, StkId res)
TString * luaS_new(lua_State *L, const char *str)
void(* lua_WarnFunction)(void *ud, const char *msg, int tocont)
LUA_API int lua_compare(lua_State *L, int index1, int index2, int op)
void lua_warning(lua_State *L, const char *msg, int tocont)
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
void luaH_resize(lua_State *L, Table *t, unsigned int newasize, unsigned int nhsize)
int(* lua_CFunction)(lua_State *L)
LUA_API int lua_isstring(lua_State *L, int idx)
LUA_API int lua_rawequal(lua_State *L, int index1, int index2)
int luaD_pcall(lua_State *L, Pfunc func, void *u, ptrdiff_t old_top, ptrdiff_t ef)
LUA_API void * lua_newuserdatauv(lua_State *L, size_t size, int nuvalue)
void *(* lua_Alloc)(void *ud, void *ptr, size_t osize, size_t nsize)
LUA_API int lua_toboolean(lua_State *L, int idx)
void luaZ_init(lua_State *L, ZIO *z, lua_Reader reader, void *data)
const TValue * luaH_getint(Table *t, lua_Integer key)
LUA_API void lua_upvaluejoin(lua_State *L, int fidx1, int n1, int fidx2, int n2)
LUA_API lua_State * lua_tothread(lua_State *L, int idx)
LUA_API const char * lua_pushlstring(lua_State *L, const char *s, size_t len)
LUA_API int lua_pcallk(lua_State *L, int nargs, int nresults, int errfunc, lua_KContext ctx, lua_KFunction k)
LUA_API int lua_getmetatable(lua_State *L, int objindex)
int(* lua_KFunction)(lua_State *L, int status, lua_KContext ctx)
LUA_API void lua_setglobal(lua_State *L, const char *name)
LUA_API int lua_rawgetp(lua_State *L, int idx, const void *p)
LUA_API void * lua_upvalueid(lua_State *L, int fidx, int n)
LUA_API int lua_setmetatable(lua_State *L, int objindex)
int luaD_protectedparser(lua_State *L, ZIO *z, const char *name, const char *mode)
static void aux_rawset(lua_State *L, int idx, TValue *key, int n)
#define luaV_fastgeti(L, t, k, slot)
LUA_API int lua_setiuservalue(lua_State *L, int idx, int n)
LUA_API int lua_gc(lua_State *L, int what,...)
LUA_API int lua_dump(lua_State *L, lua_Writer writer, void *data, int strip)
LUA_API const char * lua_tolstring(lua_State *L, int idx, size_t *len)
LUA_API int lua_status(lua_State *L)
int luaV_lessequal(lua_State *L, const TValue *l, const TValue *r)
LUA_API void lua_toclose(lua_State *L, int idx)
static int writer(lua_State *L, const void *b, size_t size, void *ud)
#define LUA_VLIGHTUSERDATA
LUA_API void lua_pushnil(lua_State *L)
#define setsvalue2s(L, o, s)
LUA_API const char * lua_setupvalue(lua_State *L, int funcindex, int n)
LUA_API void lua_pushnumber(lua_State *L, lua_Number n)
LUA_API void lua_len(lua_State *L, int idx)
LUA_API int lua_pushthread(lua_State *L)
Table * luaH_new(lua_State *L)
#define api_checknelems(L, n)
LUA_API void * lua_touserdata(lua_State *L, int idx)
LUA_API lua_Integer lua_tointegerx(lua_State *L, int idx, int *pisnum)
LUA_API void lua_xmove(lua_State *from, lua_State *to, int n)
const char *(* lua_Reader)(lua_State *L, void *ud, size_t *sz)
int luaV_lessthan(lua_State *L, const TValue *l, const TValue *r)
LUA_API void lua_rawset(lua_State *L, int idx)
void luaF_newtbcupval(lua_State *L, StkId level)
int luaF_close(lua_State *L, StkId level, int status)
#define setpvalue(obj, x)
#define setivalue(obj, x)
#define setobj(L, obj1, obj2)
static map_location::DIRECTION s
#define setfltvalue(obj, x)
LUA_API int lua_load(lua_State *L, lua_Reader reader, void *data, const char *chunkname, const char *mode)
static int finishrawget(lua_State *L, const TValue *val)
#define setclCvalue(L, obj, x)
LUA_API void lua_rawsetp(lua_State *L, int idx, const void *p)
LUA_API size_t lua_stringtonumber(lua_State *L, const char *s)
LUA_API int lua_iscfunction(lua_State *L, int idx)
LUA_API void lua_rotate(lua_State *L, int idx, int n)
LUA_API void lua_pushvalue(lua_State *L, int idx)
LUA_API const char * lua_pushvfstring(lua_State *L, const char *fmt, va_list argp)
#define luaC_barrierback(L, p, v)
void luaD_call(lua_State *L, StkId func, int nResults)
LUA_API int lua_isinteger(lua_State *L, int idx)
LUA_API int lua_isnumber(lua_State *L, int idx)
LUA_UNSIGNED lua_Unsigned
void luaV_finishset(lua_State *L, const TValue *t, TValue *key, TValue *val, const TValue *slot)
size_t luaO_str2num(const char *s, TValue *o)
void luaO_tostring(lua_State *L, TValue *obj)
void luaD_callnoyield(lua_State *L, StkId func, int nResults)
static int auxgetstr(lua_State *L, const TValue *t, const char *k)
void luaE_warning(lua_State *L, const char *msg, int tocont)
static StkId index2stack(lua_State *L, int idx)
LUA_API const char * lua_getupvalue(lua_State *L, int funcindex, int n)
LUA_API lua_Unsigned lua_rawlen(lua_State *L, int idx)
LUA_API int lua_getiuservalue(lua_State *L, int idx, int n)
static Table * gettable(lua_State *L, int idx)
#define LUA_REGISTRYINDEX
LUA_API lua_CFunction lua_atpanic(lua_State *L, lua_CFunction panicf)
LUA_API int lua_error(lua_State *L)
#define hastocloseCfunc(n)
LUA_API const void * lua_topointer(lua_State *L, int idx)
#define api_check(l, e, msg)
LUA_API void lua_concat(lua_State *L, int n)
static const char * aux_upvalue(TValue *fi, int n, TValue **val, GCObject **owner)
#define sethvalue2s(L, o, h)
#define setobjs2s(L, o1, o2)
LUA_API const char * lua_pushfstring(lua_State *L, const char *fmt,...)
LUA_API int lua_geti(lua_State *L, int idx, lua_Integer n)
void lua_setwarnf(lua_State *L, lua_WarnFunction f, void *ud)
void luaC_fullgc(lua_State *L, int isemergency)
#define setthvalue(L, obj, x)
static void reverse(lua_State *L, StkId from, StkId to)
LUA_API void lua_copy(lua_State *L, int fromidx, int toidx)
static void auxsetstr(lua_State *L, const TValue *t, const char *k)
TString * luaS_newlstr(lua_State *L, const char *str, size_t l)
#define luaC_objbarrier(L, p, o)
LUA_API int lua_getfield(lua_State *L, int idx, const char *k)
static void * touserdata(const TValue *o)
int luaV_equalobj(lua_State *L, const TValue *t1, const TValue *t2)
static map_location::DIRECTION n
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
#define luaV_rawequalobj(t1, t2)
void luaH_setint(lua_State *L, Table *t, lua_Integer key, TValue *value)
LUA_API const char * lua_pushstring(lua_State *L, const char *s)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
LUA_API int lua_next(lua_State *L, int idx)
LUA_API const char * lua_typename(lua_State *L, int t)
#define setobj2s(L, o1, o2)
LUA_API void lua_arith(lua_State *L, int op)
#define checkresults(L, na, nr)
#define luaV_finishfastset(L, t, slot, v)
LUA_API void lua_seti(lua_State *L, int idx, lua_Integer n)
#define adjustresults(L, nres)