32 #define NONVALIDVALUE cast(TValue *, luaO_nilobject)
35 #define isvalid(o) ((o) != luaO_nilobject)
38 #define ispseudo(i) ((i) <= LUA_REGISTRYINDEX)
41 #define isstackindex(i, o) (isvalid(o) && !ispseudo(i))
43 #define api_checkvalidindex(L, o) api_check(L, isvalid(o), "invalid index")
45 #define api_checkstackindex(L, i, o) \
46 api_check(L, isstackindex(i, o), "index not in the stack")
53 api_check(L, idx <= ci->top - (ci->
func + 1),
"unacceptable index");
58 api_check(L, idx != 0 && -idx <= L->top - (ci->
func + 1),
"invalid index");
62 return &
G(L)->l_registry;
81 int size = *(
int *)ud;
99 if (res && ci->
top < L->
top + size)
108 if (from == to)
return;
111 api_check(from,
G(from) ==
G(to),
"moving among independent states");
114 for (i = 0; i <
n; i++) {
125 G(L)->panic = panicf;
133 if (L == NULL)
return &
version;
134 else return G(L)->version;
163 api_check(L, idx <= L->stack_last - (func + 1),
"new top too large");
164 while (L->
top < (func + 1) + idx)
166 L->
top = (func + 1) + idx;
169 api_check(L, -(idx+1) <= (L->
top - (func + 1)),
"invalid new top");
193 for (q = L->
top; q > p; q--)
321 default:
api_check(L, 0,
"invalid option");
333 if (isnum) *isnum = 1;
337 if (isnum) *isnum = 0;
350 if (isnum) *isnum = 1;
354 if (isnum) *isnum = 0;
367 if (isnum) *isnum = 1;
371 if (isnum) *isnum = 0;
388 if (len != NULL) *len = 0;
396 if (len != NULL) *len =
tsvalue(o)->len;
426 default:
return NULL;
448 default:
return NULL;
471 luaG_runerror(L,
"C API - attempt to push a signaling NaN"));
592 return (
G(L)->mainthread == L);
674 if (narray > 0 || nrec > 0)
688 mt =
hvalue(obj)->metatable;
691 mt =
uvalue(obj)->metatable;
820 hvalue(obj)->metatable = mt;
828 uvalue(obj)->metatable = mt;
869 #define checkresults(L,na,nr) \
870 api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)), \
871 "results from function overflow current stack size")
876 if (ctx) *ctx = L->
ci->
u.
c.ctx;
877 return L->
ci->
u.
c.status;
888 "cannot use continuations inside hooks");
892 func = L->
top - (nargs+1);
893 if (k != NULL && L->
nny == 0) {
895 L->
ci->
u.
c.ctx = ctx;
929 "cannot use continuations inside hooks");
941 if (k == NULL || L->
nny > 0) {
968 const char *chunkname,
const char *
mode) {
972 if (!chunkname) chunkname =
"?";
977 if (f->nupvalues == 1) {
1154 if (ud) *ud =
G(L)->ud;
1184 switch (
ttype(fi)) {
1187 if (!(1 <= n &&
n <= f->nupvalues))
return NULL;
1189 if (owner) *owner =
obj2gco(f);
1196 if (!(1 <= n &&
n <= p->sizeupvalues))
return NULL;
1200 return (name == NULL) ?
"" :
getstr(name);
1202 default:
return NULL;
1247 return &f->
upvals[n - 1];
1253 switch (
ttype(fi)) {
1271 int fidx2,
int n2) {
LUA_API void lua_rawgeti(lua_State *L, int idx, int n)
const char * luaO_pushvfstring(lua_State *L, const char *fmt, va_list argp)
void luaE_setdebt(global_State *g, l_mem debt)
lua_Number luaO_arith(int op, lua_Number v1, lua_Number v2)
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)
l_noret luaG_runerror(lua_State *L, const char *fmt,...)
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
#define setuvalue(L, obj, x)
LUA_API void lua_getfield(lua_State *L, int idx, const char *k)
LUA_API void lua_replace(lua_State *L, int idx)
static UpVal ** getupvalref(lua_State *L, int fidx, int n, LClosure **pf)
int luaH_next(lua_State *L, Table *t, StkId key)
#define lua_number2integer(i, n)
#define equalobj(L, o1, o2)
void luaC_checkfinalizer(lua_State *L, GCObject *o, Table *mt)
LUA_API void lua_settop(lua_State *L, int idx)
LUA_API int lua_type(lua_State *L, int idx)
static TValue * index2addr(lua_State *L, int idx)
void luaH_resize(lua_State *L, Table *t, int nasize, int nhsize)
#define setbvalue(obj, x)
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 void lua_pushunsigned(lua_State *L, lua_Unsigned u)
static void f_call(lua_State *L, void *ud)
#define api_checkstackindex(L, i, o)
#define invalidateTMcache(t)
int luaU_dump(lua_State *L, const Proto *f, lua_Writer w, void *data, int strip)
LUA_API void lua_getglobal(lua_State *L, const char *var)
LUA_API int lua_gettop(lua_State *L)
LUA_API void lua_setuservalue(lua_State *L, int idx)
LUA_API const lua_Number * lua_version(lua_State *L)
#define ttislightuserdata(o)
const TValue * luaH_get(Table *t, const TValue *key)
void luaC_forcestep(lua_State *L)
#define setnvalue(obj, x)
LUA_API void lua_settable(lua_State *L, int idx)
const char *(* lua_Reader)(lua_State *L, void *ud, size_t *sz)
GLuint const GLfloat * val
LUA_API lua_CFunction lua_tocfunction(lua_State *L, int idx)
#define LUA_TLIGHTUSERDATA
void luaV_objlen(lua_State *L, StkId ra, const TValue *rb)
#define api_checkvalidindex(L, o)
const char * what() const
LUA_API int lua_dump(lua_State *L, lua_Writer writer, void *data)
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)
void luaV_arith(lua_State *L, StkId ra, const TValue *rb, const TValue *rc, TMS op)
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
#define luaC_barrier(L, p, v)
#define setfvalue(obj, x)
void luaV_gettable(lua_State *L, const TValue *t, TValue *key, StkId val)
LUA_API int lua_absindex(lua_State *L, int idx)
l_noret luaG_errormsg(lua_State *L)
LUA_API void * lua_newuserdata(lua_State *L, size_t size)
LUA_API void lua_callk(lua_State *L, int nargs, int nresults, int ctx, lua_CFunction k)
TString * luaS_new(lua_State *L, const char *str)
int(* lua_CFunction)(lua_State *L)
LUA_API int lua_gc(lua_State *L, int what, int data)
GLdouble GLdouble GLdouble b
LUA_API lua_Integer lua_tointegerx(lua_State *L, int idx, int *isnum)
GLdouble GLdouble GLdouble GLdouble q
#define sethvalue(L, obj, x)
LUA_API int lua_compare(lua_State *L, int index1, int index2, int op)
LUA_API void lua_rawgetp(lua_State *L, int idx, const void *p)
#define LUA_GCSETMAJORINC
LUA_API void lua_setglobal(lua_State *L, const char *var)
void luaC_changemode(lua_State *L, int mode)
struct CallInfo::@16::@18 c
LUA_API int lua_isstring(lua_State *L, int idx)
#define luaV_rawequalobj(o1, o2)
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 lua_Unsigned lua_tounsignedx(lua_State *L, int idx, int *isnum)
Udata * luaS_newudata(lua_State *L, size_t s, Table *e)
LUA_API int lua_toboolean(lua_State *L, int idx)
void luaZ_init(lua_State *L, ZIO *z, lua_Reader reader, void *data)
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_getmetatable(lua_State *L, int objindex)
LUA_API void * lua_upvalueid(lua_State *L, int fidx, int n)
LUA_API int lua_setmetatable(lua_State *L, int objindex)
void luaD_growstack(lua_State *L, int n)
int luaD_protectedparser(lua_State *L, ZIO *z, const char *name, const char *mode)
LUA_API void lua_remove(lua_State *L, int idx)
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 lua_Number lua_tonumberx(lua_State *L, int idx, int *isnum)
static void growstack(lua_State *L, void *ud)
Closure * luaF_newCclosure(lua_State *L, int n)
LUA_API void lua_pushnil(lua_State *L)
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)
LUA_API void lua_getuservalue(lua_State *L, int idx)
#define api_checknelems(L, n)
LUA_API void * lua_touserdata(lua_State *L, int idx)
LUA_API void lua_xmove(lua_State *from, lua_State *to, int n)
const TValue * luaH_getint(Table *t, int key)
LUA_API int lua_pcallk(lua_State *L, int nargs, int nresults, int errfunc, int ctx, lua_CFunction k)
int(* lua_Writer)(lua_State *L, const void *p, size_t sz, void *ud)
int luaV_lessthan(lua_State *L, const TValue *l, const TValue *r)
LUA_API void lua_rawset(lua_State *L, int idx)
#define luai_checknum(L, o, c)
#define setpvalue(obj, x)
#define setobj(L, obj1, obj2)
LUA_API int lua_load(lua_State *L, lua_Reader reader, void *data, const char *chunkname, const char *mode)
#define setclCvalue(L, obj, x)
LUA_API void lua_rawseti(lua_State *L, int idx, int n)
void luaH_setint(lua_State *L, Table *t, int key, TValue *value)
LUA_API void lua_rawsetp(lua_State *L, int idx, const void *p)
LUA_API int lua_iscfunction(lua_State *L, int idx)
static int writer(lua_State *L, const void *b, size_t size, void *B)
LUA_API void lua_insert(lua_State *L, int idx)
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)
LUA_API int lua_isnumber(lua_State *L, int idx)
static const char * aux_upvalue(StkId fi, int n, TValue **val, GCObject **owner)
LUA_UNSIGNED lua_Unsigned
static const char * reader(lua_State *L, void *ud, size_t *size)
int luaD_rawrunprotected(lua_State *L, Pfunc f, void *ud)
GLuint const GLchar * name
LUA_API void lua_gettable(lua_State *L, int idx)
LUA_API size_t lua_rawlen(lua_State *L, int idx)
LUA_API const char * lua_getupvalue(lua_State *L, int funcindex, int n)
#define lua_unsigned2number(u)
#define LUA_REGISTRYINDEX
LUA_API lua_CFunction lua_atpanic(lua_State *L, lua_CFunction panicf)
LUA_API int lua_error(lua_State *L)
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)
#define luaC_objbarrierback(L, p, o)
int luaV_tostring(lua_State *L, StkId obj)
void luaD_call(lua_State *L, StkId func, int nResults, int allowyield)
LUA_API int lua_checkstack(lua_State *L, int size)
LUA_API const char * lua_pushfstring(lua_State *L, const char *fmt,...)
static void moveto(lua_State *L, TValue *fr, int idx)
#define lua_number2unsigned(i, n)
void luaC_fullgc(lua_State *L, int isemergency)
void luaV_settable(lua_State *L, const TValue *t, TValue *key, StkId val)
#define setthvalue(L, obj, x)
LUA_API void lua_copy(lua_State *L, int fromidx, int toidx)
LUA_API int lua_getctx(lua_State *L, int *ctx)
TString * luaS_newlstr(lua_State *L, const char *str, size_t l)
#define luaC_objbarrier(L, p, o)
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
const std::string version
LUA_API void lua_rawget(lua_State *L, int idx)
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)
LUA_API void lua_arith(lua_State *L, int op)
#define checkresults(L, na, nr)
#define adjustresults(L, nres)