26typedef unsigned __int64
U64;
28typedef unsigned long long U64;
143#define LUA_QL(x)"'"x"'"
144#define luai_apicheck(L,o){(void)L;}
145#define lua_number2str(s,n)sprintf((s),"%.14g",(n))
146#define lua_str2number(s,p)strtod((s),(p))
147#define luai_numadd(a,b)((a)+(b))
148#define luai_numsub(a,b)((a)-(b))
149#define luai_nummul(a,b)((a)*(b))
150#define luai_numdiv(a,b)((a)/(b))
151#define luai_nummod(a,b)((a)-floor((a)/(b))*(b))
152#define luai_numpow(a,b)(pow(a,b))
153#define luai_numunm(a)(-(a))
154#define luai_numeq(a,b)((a)==(b))
155#define luai_numlt(a,b)((a)<(b))
156#define luai_numle(a,b)((a)<=(b))
157#define luai_numisnan(a)(!luai_numeq((a),(a)))
158#define lua_number2int(i,d)((i)=(int)(d))
159#define lua_number2integer(i,d)((i)=(lua_Integer)(d))
160#define LUAI_THROW(L,c)longjmp((c)->b,1)
161#define LUAI_TRY(L,c,a)if(setjmp((c)->b)==0){a}
162#define lua_pclose(L,file)((void)((void)L,file),0)
163#define lua_upvalueindex(i)((-10002)-(i))
166typedef const char*(*lua_Reader)(
lua_State*L,
void*ud,
size_t*sz);
167typedef void*(*lua_Alloc)(
void*ud,
void*
ptr,
size_t osize,
size_t nsize);
170static void lua_settop(
lua_State*L,
int idx);
172static const char* lua_tolstring(
lua_State*L,
int idx,
size_t*
len);
173static size_t lua_objlen(
lua_State*L,
int idx);
174static void lua_pushlstring(
lua_State*L,
const char*
s,
size_t l);
176static void lua_createtable(
lua_State*L,
int narr,
int nrec);
177static void lua_setfield(
lua_State*L,
int idx,
const char*k);
178#define lua_pop(L,n)lua_settop(L,-(n)-1)
179#define lua_newtable(L)lua_createtable(L,0,0)
180#define lua_pushcfunction(L,f)lua_pushcclosure(L,(f),0)
181#define lua_strlen(L,i)lua_objlen(L,(i))
182#define lua_isfunction(L,n)(lua_type(L,(n))==6)
183#define lua_istable(L,n)(lua_type(L,(n))==5)
184#define lua_isnil(L,n)(lua_type(L,(n))==0)
185#define lua_isboolean(L,n)(lua_type(L,(n))==1)
186#define lua_isnone(L,n)(lua_type(L,(n))==(-1))
187#define lua_isnoneornil(L,n)(lua_type(L,(n))<=0)
188#define lua_pushliteral(L,s)lua_pushlstring(L,""s,(sizeof(s)/sizeof(char))-1)
189#define lua_setglobal(L,s)lua_setfield(L,(-10002),(s))
190#define lua_tostring(L,i)lua_tolstring(L,(i),NULL)
210#define IntPoint(p)((unsigned int)(lu_mem)(p))
213#define check_exp(c,e)(e)
214#define UNUSED(x)((void)(x))
215#define cast(t,exp)((t)(exp))
216#define cast_byte(i)cast(lu_byte,(i))
217#define cast_num(i)cast(lua_Number,(i))
218#define cast_int(i)cast(int,(i))
220#define condhardstacktests(x)((void)0)
234#define ttisnil(o)(ttype(o)==0)
235#define ttisnumber(o)(ttype(o)==3)
236#define ttisstring(o)(ttype(o)==4)
237#define ttistable(o)(ttype(o)==5)
238#define ttisfunction(o)(ttype(o)==6)
239#define ttisboolean(o)(ttype(o)==1)
240#define ttisuserdata(o)(ttype(o)==7)
241#define ttisthread(o)(ttype(o)==8)
242#define ttislightuserdata(o)(ttype(o)==2)
243#define ttype(o)((o)->tt)
244#define gcvalue(o)check_exp(iscollectable(o),(o)->value.gc)
245#define pvalue(o)check_exp(ttislightuserdata(o),(o)->value.p)
246#define nvalue(o)check_exp(ttisnumber(o),(o)->value.n)
247#define rawtsvalue(o)check_exp(ttisstring(o),&(o)->value.gc->ts)
248#define tsvalue(o)(&rawtsvalue(o)->tsv)
249#define rawuvalue(o)check_exp(ttisuserdata(o),&(o)->value.gc->u)
250#define uvalue(o)(&rawuvalue(o)->uv)
251#define clvalue(o)check_exp(ttisfunction(o),&(o)->value.gc->cl)
252#define hvalue(o)check_exp(ttistable(o),&(o)->value.gc->h)
253#define bvalue(o)check_exp(ttisboolean(o),(o)->value.b)
254#define thvalue(o)check_exp(ttisthread(o),&(o)->value.gc->th)
255#define l_isfalse(o)(ttisnil(o)||(ttisboolean(o)&&bvalue(o)==0))
256#define checkconsistency(obj)
257#define checkliveness(g,obj)
258#define setnilvalue(obj)((obj)->tt=0)
259#define setnvalue(obj,x){TValue*i_o=(obj);i_o->value.n=(x);i_o->tt=3;}
260#define setbvalue(obj,x){TValue*i_o=(obj);i_o->value.b=(x);i_o->tt=1;}
261#define setsvalue(L,obj,x){TValue*i_o=(obj);i_o->value.gc=cast(GCObject*,(x));i_o->tt=4;checkliveness(G(L),i_o);}
262#define setuvalue(L,obj,x){TValue*i_o=(obj);i_o->value.gc=cast(GCObject*,(x));i_o->tt=7;checkliveness(G(L),i_o);}
263#define setthvalue(L,obj,x){TValue*i_o=(obj);i_o->value.gc=cast(GCObject*,(x));i_o->tt=8;checkliveness(G(L),i_o);}
264#define setclvalue(L,obj,x){TValue*i_o=(obj);i_o->value.gc=cast(GCObject*,(x));i_o->tt=6;checkliveness(G(L),i_o);}
265#define sethvalue(L,obj,x){TValue*i_o=(obj);i_o->value.gc=cast(GCObject*,(x));i_o->tt=5;checkliveness(G(L),i_o);}
266#define setptvalue(L,obj,x){TValue*i_o=(obj);i_o->value.gc=cast(GCObject*,(x));i_o->tt=(8+1);checkliveness(G(L),i_o);}
267#define setobj(L,obj1,obj2){const TValue*o2=(obj2);TValue*o1=(obj1);o1->value=o2->value;o1->tt=o2->tt;checkliveness(G(L),o1);}
268#define setttype(obj,tt)(ttype(obj)=(tt))
269#define iscollectable(o)(ttype(o)>=4)
280#define getstr(ts)cast(const char*,(ts)+1)
281#define svalue(o)getstr(rawtsvalue(o))
344#define iscfunction(o)(ttype(o)==6&&clvalue(o)->c.isC)
367#define lmod(s,size)(check_exp((size&(size-1))==0,(cast(int,(s)&((size)-1)))))
368#define twoto(x)((size_t)1<<(x))
369#define sizenode(t)(twoto((t)->lsizenode))
370static const TValue luaO_nilobject_;
371#define ceillog2(x)(luaO_log2((x)-1)+1)
372static int luaO_log2(
unsigned int x);
373#define gfasttm(g,et,e)((et)==NULL?NULL:((et)->flags&(1u<<(e)))?NULL:luaT_gettm(et,e,(g)->tmname[e]))
374#define fasttm(l,et,e)gfasttm(G(l),et,e)
376#define luaM_reallocv(L,b,on,n,e)((cast(size_t,(n)+1)<=((size_t)(~(size_t)0)-2)/(e))?luaM_realloc_(L,(b),(on)*(e),(n)*(e)):luaM_toobig(L))
377#define luaM_freemem(L,b,s)luaM_realloc_(L,(b),(s),0)
378#define luaM_free(L,b)luaM_realloc_(L,(b),sizeof(*(b)),0)
379#define luaM_freearray(L,b,n,t)luaM_reallocv(L,(b),n,0,sizeof(t))
380#define luaM_malloc(L,t)luaM_realloc_(L,NULL,0,(t))
381#define luaM_new(L,t)cast(t*,luaM_malloc(L,sizeof(t)))
382#define luaM_newvector(L,n,t)cast(t*,luaM_reallocv(L,NULL,0,n,sizeof(t)))
383#define luaM_growvector(L,v,nelems,size,t,limit,e)if((nelems)+1>(size))((v)=cast(t*,luaM_growaux_(L,v,&(size),sizeof(t),limit,e)))
384#define luaM_reallocvector(L,v,oldn,n,t)((v)=cast(t*,luaM_reallocv(L,v,oldn,n,sizeof(t))))
385static void*luaM_realloc_(
lua_State*L,
void*block,
size_t oldsize,
389size_t size_elem,
int limit,
392#define char2int(c)cast(int,cast(unsigned char,(c)))
393#define zgetc(z)(((z)->n--)>0?char2int(*(z)->p++):luaZ_fill(z))
399#define luaZ_initbuffer(L,buff)((buff)->buffer=NULL,(buff)->buffsize=0)
400#define luaZ_buffer(buff)((buff)->buffer)
401#define luaZ_sizebuffer(buff)((buff)->buffsize)
402#define luaZ_bufflen(buff)((buff)->n)
403#define luaZ_resetbuffer(buff)((buff)->n=0)
404#define luaZ_resizebuffer(L,buff,size)(luaM_reallocvector(L,(buff)->buffer,(buff)->buffsize,size,char),(buff)->buffsize=size)
405#define luaZ_freebuffer(L,buff)luaZ_resizebuffer(L,buff,0)
413static int luaZ_fill(
ZIO*z);
415#define gt(L)(&L->l_gt)
416#define registry(L)(&G(L)->l_registry)
430#define curr_func(L)(clvalue(L->ci->func))
431#define ci_func(ci)(clvalue((ci)->func))
432#define f_isLua(ci)(!ci_func(ci)->c.isC)
433#define isLua(ci)(ttisfunction((ci)->func)&&f_isLua(ci))
500#define rawgco2ts(o)check_exp((o)->gch.tt==4,&((o)->ts))
501#define gco2ts(o)(&rawgco2ts(o)->tsv)
502#define rawgco2u(o)check_exp((o)->gch.tt==7,&((o)->u))
503#define gco2u(o)(&rawgco2u(o)->uv)
504#define gco2cl(o)check_exp((o)->gch.tt==6,&((o)->cl))
505#define gco2h(o)check_exp((o)->gch.tt==5,&((o)->h))
506#define gco2p(o)check_exp((o)->gch.tt==(8+1),&((o)->p))
507#define gco2uv(o)check_exp((o)->gch.tt==(8+2),&((o)->uv))
508#define ngcotouv(o)check_exp((o)==NULL||(o)->gch.tt==(8+2),&((o)->uv))
509#define gco2th(o)check_exp((o)->gch.tt==8,&((o)->th))
510#define obj2gco(v)(cast(GCObject*,(v)))
512#define pcRel(pc,p)(cast(int,(pc)-(p)->code)-1)
513#define getline_(f,pc)(((f)->lineinfo)?(f)->lineinfo[pc]:0)
514#define resethookcount(L)(L->hookcount=L->basehookcount)
517static void luaG_runerror(
lua_State*L,
const char*fmt,...);
518#define luaD_checkstack(L,n)if((char*)L->stack_last-(char*)L->top<=(n)*(int)sizeof(TValue))luaD_growstack(L,n);else condhardstacktests(luaD_reallocstack(L,L->stacksize-5-1));
519#define incr_top(L){luaD_checkstack(L,1);L->top++;}
520#define savestack(L,p)((char*)(p)-(char*)L->stack)
521#define restorestack(L,n)((TValue*)((char*)L->stack+(n)))
522#define saveci(L,p)((char*)(p)-(char*)L->base_ci)
523#define restoreci(L,n)((CallInfo*)((char*)L->base_ci+(n)))
526static void luaD_reallocCI(
lua_State*L,
int newsize);
527static void luaD_reallocstack(
lua_State*L,
int newsize);
529static void luaD_throw(
lua_State*L,
int errcode);
530static void*luaM_growaux_(
lua_State*L,
void*block,
int*
size,
size_t size_elems,
531int limit,
const char*errormsg){
536luaG_runerror(L,errormsg);
549luaG_runerror(L,
"memory allocation error: block too big");
552static void*luaM_realloc_(
lua_State*L,
void*block,
size_t osize,
size_t nsize){
555if(block==
NULL&&nsize>0)
560#define resetbits(x,m)((x)&=cast(lu_byte,~(m)))
561#define setbits(x,m)((x)|=(m))
562#define testbits(x,m)((x)&(m))
563#define bitmask(b)(1<<(b))
564#define bit2mask(b1,b2)(bitmask(b1)|bitmask(b2))
565#define l_setbit(x,b)setbits(x,bitmask(b))
566#define resetbit(x,b)resetbits(x,bitmask(b))
567#define testbit(x,b)testbits(x,bitmask(b))
568#define set2bits(x,b1,b2)setbits(x,(bit2mask(b1,b2)))
569#define reset2bits(x,b1,b2)resetbits(x,(bit2mask(b1,b2)))
570#define test2bits(x,b1,b2)testbits(x,(bit2mask(b1,b2)))
571#define iswhite(x)test2bits((x)->gch.marked,0,1)
572#define isblack(x)testbit((x)->gch.marked,2)
573#define isgray(x)(!isblack(x)&&!iswhite(x))
574#define otherwhite(g)(g->currentwhite^bit2mask(0,1))
575#define isdead(g,v)((v)->gch.marked&otherwhite(g)&bit2mask(0,1))
576#define changewhite(x)((x)->gch.marked^=bit2mask(0,1))
577#define gray2black(x)l_setbit((x)->gch.marked,2)
578#define valiswhite(x)(iscollectable(x)&&iswhite(gcvalue(x)))
579#define luaC_white(g)cast(lu_byte,(g)->currentwhite&bit2mask(0,1))
580#define luaC_checkGC(L){condhardstacktests(luaD_reallocstack(L,L->stacksize-5-1));if(G(L)->totalbytes>=G(L)->GCthreshold)luaC_step(L);}
581#define luaC_barrier(L,p,v){if(valiswhite(v)&&isblack(obj2gco(p)))luaC_barrierf(L,obj2gco(p),gcvalue(v));}
582#define luaC_barriert(L,t,v){if(valiswhite(v)&&isblack(obj2gco(t)))luaC_barrierback(L,t);}
583#define luaC_objbarrier(L,p,o){if(iswhite(obj2gco(o))&&isblack(obj2gco(p)))luaC_barrierf(L,obj2gco(p),obj2gco(o));}
584#define luaC_objbarriert(L,t,o){if(iswhite(obj2gco(o))&&isblack(obj2gco(t)))luaC_barrierback(L,t);}
590#define sizestring(s)(sizeof(union TString)+((s)->len+1)*sizeof(char))
591#define sizeudata(u)(sizeof(union Udata)+(u)->len)
592#define luaS_new(L,s)(luaS_newlstr(L,s,strlen(s)))
593#define luaS_newliteral(L,s)(luaS_newlstr(L,""s,(sizeof(s)/sizeof(char))-1))
594#define luaS_fix(s)l_setbit((s)->tsv.marked,5)
596#define tostring(L,o)((ttype(o)==4)||(luaV_tostring(L,o)))
597#define tonumber(o,n)(ttype(o)==3||(((o)=luaV_tonumber(o,n))!=NULL))
598#define equalobj(L,o1,o2)(ttype(o1)==ttype(o2)&&luaV_equalval(L,o1,o2))
602static void luaV_execute(
lua_State*L,
int nexeccalls);
604static const TValue luaO_nilobject_={{
NULL},0};
605static int luaO_int2fb(
unsigned int x){
612else return((e+1)<<3)|(
cast_int(x)-8);
614static int luaO_fb2int(
int x){
617else return((x&7)+8)<<(e-1);
619static int luaO_log2(
unsigned int x){
620static const lu_byte log_2[256]={
6210,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
6226,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6237,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
6247,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
6258,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
6268,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
6278,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
6288,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
631while(x>=256){l+=8;x>>=8;}
660static void pushstr(
lua_State*L,
const char*str){
664static const char*luaO_pushvfstring(
lua_State*L,
const char*fmt,va_list argp){
668const char*e=
strchr(fmt,
'%');
674const char*
s=va_arg(argp,
char*);
681buff[0]=
cast(
char,va_arg(argp,
int));
697char buff[4*
sizeof(
void*)+8];
698sprintf(buff,
"%p",va_arg(argp,
void*));
723static const char*luaO_pushfstring(
lua_State*L,
const char*fmt,...){
727msg=luaO_pushvfstring(L,fmt,argp);
731static void luaO_chunkid(
char*
out,
const char*source,
size_t bufflen){
751bufflen-=
sizeof(
" [string \"...\"] ");
753strcpy(
out,
"[string \"");
754if(source[
len]!=
'\0'){
764#define gnode(t,i)(&(t)->node[i])
765#define gkey(n)(&(n)->i_key.nk)
766#define gval(n)(&(n)->i_val)
767#define gnext(n)((n)->i_key.nk.next)
768#define key2tval(n)(&(n)->i_key.tvk)
772static const char*
const luaT_typenames[]={
773"nil",
"boolean",
"userdata",
"number",
774"string",
"table",
"function",
"userdata",
"thread",
778static const char*
const luaT_eventname[]={
779"__index",
"__newindex",
780"__gc",
"__mode",
"__eq",
781"__add",
"__sub",
"__mul",
"__div",
"__mod",
782"__pow",
"__unm",
"__len",
"__lt",
"__le",
787G(L)->tmname[i]=
luaS_new(L,luaT_eventname[i]);
792const TValue*tm=luaH_getstr(events,ename);
811return(mt?luaH_getstr(mt,
G(L)->tmname[event]):(&luaO_nilobject_));
813#define sizeCclosure(n)(cast(int,sizeof(CClosure))+cast(int,sizeof(TValue)*((n)-1)))
814#define sizeLclosure(n)(cast(int,sizeof(LClosure))+cast(int,sizeof(TValue*)*((n)-1)))
864static void unlinkupval(
UpVal*uv){
927#define MASK1(n,p)((~((~(Instruction)0)<<n))<<p)
928#define MASK0(n,p)(~MASK1(n,p))
929#define GET_OPCODE(i)(cast(OpCode,((i)>>0)&MASK1(6,0)))
930#define SET_OPCODE(i,o)((i)=(((i)&MASK0(6,0))|((cast(Instruction,o)<<0)&MASK1(6,0))))
931#define GETARG_A(i)(cast(int,((i)>>(0+6))&MASK1(8,0)))
932#define SETARG_A(i,u)((i)=(((i)&MASK0(8,(0+6)))|((cast(Instruction,u)<<(0+6))&MASK1(8,(0+6)))))
933#define GETARG_B(i)(cast(int,((i)>>(((0+6)+8)+9))&MASK1(9,0)))
934#define SETARG_B(i,b)((i)=(((i)&MASK0(9,(((0+6)+8)+9)))|((cast(Instruction,b)<<(((0+6)+8)+9))&MASK1(9,(((0+6)+8)+9)))))
935#define GETARG_C(i)(cast(int,((i)>>((0+6)+8))&MASK1(9,0)))
936#define SETARG_C(i,b)((i)=(((i)&MASK0(9,((0+6)+8)))|((cast(Instruction,b)<<((0+6)+8))&MASK1(9,((0+6)+8)))))
937#define GETARG_Bx(i)(cast(int,((i)>>((0+6)+8))&MASK1((9+9),0)))
938#define SETARG_Bx(i,b)((i)=(((i)&MASK0((9+9),((0+6)+8)))|((cast(Instruction,b)<<((0+6)+8))&MASK1((9+9),((0+6)+8)))))
939#define GETARG_sBx(i)(GETARG_Bx(i)-(((1<<(9+9))-1)>>1))
940#define SETARG_sBx(i,b)SETARG_Bx((i),cast(unsigned int,(b)+(((1<<(9+9))-1)>>1)))
941#define CREATE_ABC(o,a,b,c)((cast(Instruction,o)<<0)|(cast(Instruction,a)<<(0+6))|(cast(Instruction,b)<<(((0+6)+8)+9))|(cast(Instruction,c)<<((0+6)+8)))
942#define CREATE_ABx(o,a,bc)((cast(Instruction,o)<<0)|(cast(Instruction,a)<<(0+6))|(cast(Instruction,bc)<<((0+6)+8)))
943#define ISK(x)((x)&(1<<(9-1)))
944#define INDEXK(r)((int)(r)&~(1<<(9-1)))
945#define RKASK(x)((x)|(1<<(9-1)))
947#define getBMode(m)(cast(enum OpArgMask,(luaP_opmodes[m]>>4)&3))
948#define getCMode(m)(cast(enum OpArgMask,(luaP_opmodes[m]>>2)&3))
949#define testTMode(m)(luaP_opmodes[m]&(1<<7))
989static void luaD_seterrorobj(
lua_State*L,
int errcode,
StkId oldtop){
1007static void restore_stack_limit(
lua_State*L){
1011luaD_reallocCI(L,20000);
1017luaF_close(L,L->
base);
1021restore_stack_limit(L);
1025static void luaD_throw(
lua_State*L,
int errcode){
1033resetstack(L,errcode);
1056for(ci=L->
base_ci;ci<=L->ci;ci++){
1057ci->top=(ci->top-oldstack)+L->
stack;
1058ci->base=(ci->base-oldstack)+L->
stack;
1059ci->func=(ci->func-oldstack)+L->
stack;
1063static void luaD_reallocstack(
lua_State*L,
int newsize){
1065int realsize=newsize+1+5;
1069correctstack(L,oldstack);
1071static void luaD_reallocCI(
lua_State*L,
int newsize){
1078static void luaD_growstack(
lua_State*L,
int n){
1088luaD_reallocCI(L,2*L->
size_ci);
1090luaG_runerror(L,
"stack overflow");
1096int nfixargs=
p->numparams;
1099for(;actual<nfixargs;++actual)
1103for(i=0;i<nfixargs;i++){
1117luaG_typeerror(L,
func,
"call");
1124#define inc_ci(L)((L->ci==L->end_ci)?growCI(L):(condhardstacktests(luaD_reallocCI(L,L->size_ci)),++L->ci))
1141if(L->
top>base+
p->numparams)
1142L->
top=base+
p->numparams;
1146base=adjust_varargs(L,
p,nargs);
1156for(st=L->
top;st<ci->
top;st++)
1174luaD_poscall(L,L->
top-
n);
1186L->
base=(ci-1)->base;
1188for(i=wanted;i!=0&&firstResult<L->
top;i--)
1198luaG_runerror(L,
"C stack overflow");
1199else if(L->
nCcalls>=(200+(200>>3)))
1202if(luaD_precall(L,
func,nResults)==0)
1210unsigned short oldnCcalls=L->
nCcalls;
1218luaF_close(L,oldtop);
1219luaD_seterrorobj(L,
status,oldtop);
1225restore_stack_limit(L);
1235static void f_parser(
lua_State*L,
void*ud){
1241tf=luaY_parser(L,
p->z,
1245for(i=0;i<tf->
nups;i++)
1246cl->
l.
upvals[i]=luaF_newupval(L);
1259static void luaS_resize(
lua_State*L,
int newsize){
1267for(i=0;i<newsize;i++)newhash[i]=
NULL;
1268for(i=0;i<tb->
size;i++){
1272unsigned int h=
gco2ts(
p)->hash;
1273int h1=
lmod(h,newsize);
1274p->gch.next=newhash[h1];
1287if(l+1>(((
size_t)(~(
size_t)0)-2)-
sizeof(
TString))/
sizeof(
char))
1295memcpy(ts+1,str,l*
sizeof(
char));
1296((
char*)(ts+1))[l]=
'\0';
1303luaS_resize(L,tb->
size*2);
1308unsigned int h=
cast(
unsigned int,l);
1309size_t step=(l>>5)+1;
1311for(l1=l;l1>=step;l1-=step)
1312h=h^((h<<5)+(h>>2)+
cast(
unsigned char,str[l1-1]));
1313for(o=
G(L)->strt.hash[
lmod(h,
G(L)->strt.size)];
1322return newlstr(L,str,l,h);
1326if(
s>((
size_t)(~(
size_t)0)-2)-
sizeof(
Udata))
1332u->uv.metatable=
NULL;
1334u->uv.next=
G(L)->mainthread->next;
1338#define hashpow2(t,n)(gnode(t,lmod((n),sizenode(t))))
1339#define hashstr(t,str)hashpow2(t,(str)->tsv.hash)
1340#define hashboolean(t,p)hashpow2(t,p)
1341#define hashmod(t,n)(gnode(t,((n)%((sizenode(t)-1)|1))))
1342#define hashpointer(t,p)hashmod(t,IntPoint(p))
1343static const Node dummynode_={
1384if(0<i&&i<=t->sizearray)
1397luaG_runerror(L,
"invalid key to "LUA_QL(
"next"));
1402int i=findindex(L,t,
key);
1419static int computesizes(
int nums[],
int*narray){
1425for(i=0,twotoi=1;twotoi/2<*narray;i++,twotoi*=2){
1438static int countint(
const TValue*
key,
int*nums){
1439int k=arrayindex(
key);
1440if(0<k&&k<=(1<<(32-2))){
1447static int numusearray(
const Table*t,
int*nums){
1452for(lg=0,ttlg=1;lg<=(32-2);lg++,ttlg*=2){
1469static int numusehash(
const Table*t,
int*nums,
int*pnasize){
1500luaG_runerror(L,
"table overflow");
1519setarrayvector(L,t,nasize);
1520setnodevector(L,t,nhsize);
1523for(i=nasize;i<oldasize;i++){
1529for(i=
twoto(oldhsize)-1;i>=0;i--){
1534if(nold!=(&dummynode_))
1539resize(L,t,nasize,nsize);
1546for(i=0;i<=(32-2);i++)nums[i]=0;
1547nasize=numusearray(t,nums);
1549totaluse+=numusehash(t,nums,&nasize);
1550nasize+=countint(ek,nums);
1552na=computesizes(nums,&nasize);
1553resize(L,t,nasize,totaluse-na);
1564setarrayvector(L,t,narray);
1565setnodevector(L,t,nhash);
1569if(t->
node!=(&dummynode_))
1585Node*
n=getfreepos(t);
1588return luaH_set(L,t,
key);
1590othern=mainposition(t,
key2tval(mp));
1613Node*
n=hashnum(t,nk);
1619return(&luaO_nilobject_);
1629return(&luaO_nilobject_);
1633case 0:
return(&luaO_nilobject_);
1640return luaH_getnum(t,k);
1650return(&luaO_nilobject_);
1657if(
p!=(&luaO_nilobject_))
1660if(
ttisnil(
key))luaG_runerror(L,
"table index is nil");
1662luaG_runerror(L,
"table index is NaN");
1663return newkey(L,t,
key);
1668if(
p!=(&luaO_nilobject_))
1673return newkey(L,t,&k);
1678if(
p!=(&luaO_nilobject_))
1683return newkey(L,t,&k);
1686static int unbound_search(
Table*t,
unsigned int j){
1694while(!
ttisnil(luaH_getnum(t,i)))i++;
1699unsigned int m=(i+
j)/2;
1705static int luaH_getn(
Table*t){
1710unsigned int m=(i+
j)/2;
1716else if(t->
node==(&dummynode_))
1718else return unbound_search(t,
j);
1720#define makewhite(g,x)((x)->gch.marked=cast_byte(((x)->gch.marked&cast_byte(~(bitmask(2)|bit2mask(0,1))))|luaC_white(g)))
1721#define white2gray(x)reset2bits((x)->gch.marked,0,1)
1722#define black2gray(x)resetbit((x)->gch.marked,2)
1723#define stringmark(s)reset2bits((s)->tsv.marked,0,1)
1724#define isfinalized(u)testbit((u)->marked,3)
1725#define markfinalized(u)l_setbit((u)->marked,3)
1726#define markvalue(g,o){checkconsistency(o);if(iscollectable(o)&&iswhite(gcvalue(o)))reallymarkobject(g,gcvalue(o));}
1727#define markobject(g,t){if(iswhite(obj2gco(t)))reallymarkobject(g,obj2gco(t));}
1728#define setthreshold(g)(g->GCthreshold=(g->estimate/100)*g->gcpause)
1729static void removeentry(
Node*
n){
1782reallymarkobject(g,
u);
1786static size_t luaC_separateudata(
lua_State*L,
int all){
1791while((curr=*
p)!=
NULL){
1824if(weakkey||weakvalue){
1832if(weakkey&&weakvalue)
return 1;
1848return weakkey||weakvalue;
1853for(i=0;i<f->
sizek;i++)
1859for(i=0;i<f->
sizep;i++){
1887if(4*ci_used<L->size_ci&&2*8<L->
size_ci)
1888luaD_reallocCI(L,L->
size_ci/2);
1890if(4*s_used<L->stacksize&&
1900for(ci=l->
base_ci;ci<=l->ci;ci++){
1901if(lim<ci->
top)lim=ci->
top;
1907checkstacksizes(l,lim);
1916if(traversetable(g,h))
1924traverseclosure(g,cl);
1945sizeof(int)*
p->sizelineinfo+
1954while(g->
gray)m+=propagatemark(g);
1957static int iscleared(
const TValue*o,
int iskey){
1991case(8+1):luaF_freeproto(L,
gco2p(o));
break;
1992case 6:luaF_freeclosure(L,
gco2cl(o));
break;
1993case(8+2):luaF_freeupval(L,
gco2uv(o));
break;
1994case 5:luaH_free(L,
gco2h(o));
break;
1996luaE_freethread(L,
gco2th(o));
2011#define sweepwholelist(L,p)sweeplist(L,p,((lu_mem)(~(lu_mem)0)-2))
2063luaD_call(L,L->
top-2,0);
2116udsize=luaC_separateudata(L,0);
2118udsize+=propagateall(g);
2135return propagatemark(g);
2201reallymarkobject(g,
v);
2256static void luaX_lexerror(
LexState*ls,
const char*
msg,
int token);
2257#define state_size(x)(sizeof(x)+0)
2258#define fromstate(l)(cast(lu_byte*,(l))-0)
2259#define tostate(l)(cast(lua_State*,cast(lu_byte*,l)+0))
2282static void f_luaopen(
lua_State*L,
void*ud){
2315luaF_close(L,L->
stack);
2323luaF_close(L1,L1->
stack);
2365for(i=0;i<(8+1);i++)g->
mt[i]=
NULL;
2366if(luaD_rawrunprotected(L,f_luaopen,
NULL)!=0){
2374static void callallgcTM(
lua_State*L,
void*ud){
2380luaF_close(L,L->
stack);
2381luaC_separateudata(L,1);
2387}
while(luaD_rawrunprotected(L,callallgcTM,
NULL)!=0);
2390#define getcode(fs,e)((fs)->f->code[(e)->u.s.info])
2391#define luaK_codeAsBx(fs,o,A,sBx)luaK_codeABx(fs,o,A,(sBx)+(((1<<(9+9))-1)>>1))
2392#define luaK_setmultret(fs,e)luaK_setreturns(fs,e,(-1))
2396static void luaK_patchtohere(
FuncState*fs,
int list);
2397static void luaK_concat(
FuncState*fs,
int*l1,
int l2);
2399if(!
isLua(ci))
return-1;
2405int pc=currentpc(L,ci);
2414for(ci=L->
ci;level>0&&ci>L->
base_ci;ci--){
2452ar->
source=
"=(tail call)";
2461Table*t=luaH_new(L,0,0);
2465setbvalue(luaH_setnum(L,t,lineinfo[i]),1);
2518else if(ar->
i_ci!=0){
2522status=auxgetinfo(L,what,ar,f,ci);
2529collectvalidlines(L,f);
2540const char*t=luaT_typenames[
ttype(o)];
2541const char*
kind=(isinstack(L->
ci,o))?
2545luaG_runerror(L,
"attempt to %s %s "LUA_QL(
"%s")
" (a %s value)",
2548luaG_runerror(L,
"attempt to %s a %s value",op,t);
2552luaG_typeerror(L,p1,
"concatenate");
2556if(luaV_tonumber(p1,&temp)==
NULL)
2558luaG_typeerror(L,p2,
"perform arithmetic on");
2561const char*
t1=luaT_typenames[
ttype(p1)];
2562const char*
t2=luaT_typenames[
ttype(p2)];
2564luaG_runerror(L,
"attempt to compare two %s values",
t1);
2566luaG_runerror(L,
"attempt to compare %s with %s",
t1,
t2);
2573int line=currentline(L,ci);
2574luaO_chunkid(buff,
getstr(getluaproto(ci)->source),60);
2575luaO_pushfstring(L,
"%s:%d: %s",buff,
line,
msg);
2585luaD_call(L,L->
top-2,1);
2589static void luaG_runerror(
lua_State*L,
const char*fmt,...){
2592addinfo(L,luaO_pushvfstring(L,fmt,argp));
2596static int luaZ_fill(
ZIO*z){
2620#define opmode(t,a,b,c,m)(((t)<<7)|((a)<<6)|((b)<<4)|((c)<<2)|(m))
2661#define next(ls)(ls->current=zgetc(ls->z))
2662#define currIsNewline(ls)(ls->current=='\n'||ls->current=='\r')
2663static const char*
const luaX_tokens[]={
2664"and",
"break",
"do",
"else",
"elseif",
2665"end",
"false",
"for",
"function",
"if",
2666"in",
"local",
"nil",
"not",
"or",
"repeat",
2667"return",
"then",
"true",
"until",
"while",
2668"..",
"...",
"==",
">=",
"<=",
"~=",
2669"<number>",
"<name>",
"<string>",
"<eof>",
2672#define save_and_next(ls)(save(ls,ls->current),next(ls))
2673static void save(
LexState*ls,
int c){
2677if(b->
buffsize>=((
size_t)(~(
size_t)0)-2)/2)
2678luaX_lexerror(ls,
"lexical element too long",0);
2692static const char*luaX_token2str(
LexState*ls,
int token){
2694return(iscntrl(token))?luaO_pushfstring(ls->
L,
"char(%d)",token):
2695luaO_pushfstring(ls->L,
"%c",token);
2698return luaX_tokens[token-257];
2700static const char*txtToken(
LexState*ls,
int token){
2708return luaX_token2str(ls,token);
2711static void luaX_lexerror(
LexState*ls,
const char*
msg,
int token){
2716luaO_pushfstring(ls->
L,
"%s near "LUA_QL(
"%s"),
msg,txtToken(ls,token));
2719static void luaX_syntaxerror(
LexState*ls,
const char*
msg){
2724TString*ts=luaS_newlstr(L,str,l);
2732static void inclinenumber(
LexState*ls){
2738luaX_syntaxerror(ls,
"chunk has too many lines");
2752static int check_next(
LexState*ls,
const char*set){
2758static void buffreplace(
LexState*ls,
char from,
char to){
2762if(
p[
n]==from)
p[
n]=to;
2768if(check_next(ls,
"Ee"))
2775luaX_lexerror(ls,
"malformed number",
TK_NUMBER);
2796luaX_lexerror(ls,(seminfo)?
"unfinished long string":
2797"unfinished long comment",
TK_EOS);
2800if(skip_sep(ls)==sep){
2828luaX_lexerror(ls,
"unfinished string",
TK_EOS);
2832luaX_lexerror(ls,
"unfinished string",
TK_STRING);
2838case'a':c=
'\a';
break;
2839case'b':c=
'\b';
break;
2840case'f':c=
'\f';
break;
2841case'n':c=
'\n';
break;
2842case'r':c=
'\r';
break;
2843case't':c=
'\t';
break;
2844case'v':c=
'\v';
break;
2846case'\r':save(ls,
'\n');inclinenumber(ls);
continue;
2857}
while(++i<3&&isdigit(ls->
current));
2859luaX_lexerror(ls,
"escape sequence too large",
TK_STRING);
2891int sep=skip_sep(ls);
2894read_long_string(ls,
NULL,sep);
2904int sep=skip_sep(ls);
2906read_long_string(ls,seminfo,sep);
2909else if (sep!=-1)luaX_lexerror(ls,
"invalid long string delimiter",
TK_STRING);
2934read_string(ls,ls->
current,seminfo);
2939if(check_next(ls,
".")){
2940if(check_next(ls,
"."))
2944else if(!isdigit(ls->
current))
return'.';
2946read_numeral(ls,seminfo);
2959read_numeral(ls,seminfo);
2994static void luaX_lookahead(
LexState*ls){
2997#define hasjumps(e)((e)->t!=(e)->f)
2998static int isnumeral(
expdesc*e){
2999return(e->
k==
VKNUM&&e->
t==(-1)&&e->
f==(-1));
3001static void luaK_nil(
FuncState*fs,
int from,
int n){
3009previous=&fs->
f->
code[fs->
pc-1];
3013if(pfrom<=from&&from<=pto+1){
3028luaK_concat(fs,&
j,jpc);
3031static void luaK_ret(
FuncState*fs,
int first,
int nret){
3032luaK_codeABC(fs,
OP_RETURN,first,nret+1,0);
3035luaK_codeABC(fs,op,
A,
B,
C);
3036return luaK_jump(fs);
3038static void fixjump(
FuncState*fs,
int pc,
int dest){
3042luaX_syntaxerror(fs->
ls,
"control structure too long");
3063static int need_value(
FuncState*fs,
int list){
3064for(;list!=(-1);list=getjump(fs,list)){
3070static int patchtestreg(
FuncState*fs,
int node,
int reg){
3074if(reg!=((1<<8)-1)&®!=
GETARG_B(*i))
3080static void removevalues(
FuncState*fs,
int list){
3081for(;list!=(-1);list=getjump(fs,list))
3082patchtestreg(fs,list,((1<<8)-1));
3084static void patchlistaux(
FuncState*fs,
int list,
int vtarget,
int reg,
3087int next=getjump(fs,list);
3088if(patchtestreg(fs,list,reg))
3089fixjump(fs,list,vtarget);
3091fixjump(fs,list,dtarget);
3096patchlistaux(fs,fs->
jpc,fs->
pc,((1<<8)-1),fs->
pc);
3099static void luaK_patchlist(
FuncState*fs,
int list,
int target){
3101luaK_patchtohere(fs,list);
3103patchlistaux(fs,list,target,((1<<8)-1),target);
3106static void luaK_patchtohere(
FuncState*fs,
int list){
3108luaK_concat(fs,&fs->
jpc,list);
3110static void luaK_concat(
FuncState*fs,
int*l1,
int l2){
3117while((
next=getjump(fs,list))!=(-1))
3122static void luaK_checkstack(
FuncState*fs,
int n){
3126luaX_syntaxerror(fs->
ls,
"function or expression too complex");
3130static void luaK_reserveregs(
FuncState*fs,
int n){
3131luaK_checkstack(fs,
n);
3134static void freereg(
FuncState*fs,
int reg){
3145TValue*idx=luaH_set(L,fs->
h,k);
3147int oldsize=f->
sizek;
3154((1<<(9+9))-1),
"constant table overflow");
3164return addk(fs,&o,&o);
3169return addk(fs,&o,&o);
3174return addk(fs,&o,&o);
3180return addk(fs,&k,&
v);
3189luaK_reserveregs(fs,1);
3219freereg(fs,e->
u.
s.
aux);
3227luaK_setoneret(fs,e);
3233static int code_label(
FuncState*fs,
int A,
int b,
int jump){
3238luaK_dischargevars(fs,e);
3275luaK_reserveregs(fs,1);
3276discharge2reg(fs,e,fs->
freereg-1);
3280discharge2reg(fs,e,reg);
3282luaK_concat(fs,&e->
t,e->
u.
s.
info);
3287if(need_value(fs,e->
t)||need_value(fs,e->
f)){
3288int fj=(e->
k==
VJMP)?(-1):luaK_jump(fs);
3289p_f=code_label(fs,reg,0,1);
3290p_t=code_label(fs,reg,1,0);
3291luaK_patchtohere(fs,fj);
3293final=luaK_getlabel(fs);
3294patchlistaux(fs,e->
f,
final,reg,p_f);
3295patchlistaux(fs,e->
t,
final,reg,p_t);
3302luaK_dischargevars(fs,e);
3304luaK_reserveregs(fs,1);
3308luaK_dischargevars(fs,e);
3312exp2reg(fs,e,e->
u.
s.
info);
3316luaK_exp2nextreg(fs,e);
3321luaK_exp2anyreg(fs,e);
3323luaK_dischargevars(fs,e);
3332if(fs->
nk<=((1<<(9-1))-1)){
3342if(e->
u.
s.
info<=((1<<(9-1))-1))
3348return luaK_exp2anyreg(fs,e);
3358int e=luaK_exp2anyreg(fs,
ex);
3363int e=luaK_exp2anyreg(fs,
ex);
3368int e=luaK_exp2RK(fs,
ex);
3380luaK_exp2anyreg(fs,e);
3383luaK_reserveregs(fs,2);
3401discharge2anyreg(fs,e);
3407luaK_dischargevars(fs,e);
3419pc=jumponcond(fs,e,0);
3423luaK_concat(fs,&e->
f,pc);
3424luaK_patchtohere(fs,e->
t);
3429luaK_dischargevars(fs,e);
3440pc=jumponcond(fs,e,1);
3444luaK_concat(fs,&e->
t,pc);
3445luaK_patchtohere(fs,e->
f);
3449luaK_dischargevars(fs,e);
3465discharge2anyreg(fs,e);
3475{
int temp=e->
f;e->
f=e->
t;e->
t=temp;}
3476removevalues(fs,e->
f);
3477removevalues(fs,e->
t);
3480t->
u.
s.
aux=luaK_exp2RK(fs,k);
3485if(!isnumeral(e1)||!isnumeral(e2))
return 0;
3508if(constfolding(op,e1,e2))
3512int o1=luaK_exp2RK(fs,e1);
3521e1->
u.
s.
info=luaK_codeABC(fs,op,0,o1,o2);
3527int o1=luaK_exp2RK(fs,e1);
3528int o2=luaK_exp2RK(fs,e2);
3531if(cond==0&&op!=
OP_EQ){
3533temp=o1;o1=o2;o2=temp;
3536e1->
u.
s.
info=condjump(fs,op,cond,o1,o2);
3545luaK_exp2anyreg(fs,e);
3546codearith(fs,
OP_UNM,e,&e2);
3549case OPR_NOT:codenot(fs,e);
break;
3551luaK_exp2anyreg(fs,e);
3552codearith(fs,
OP_LEN,e,&e2);
3565luaK_goiffalse(fs,
v);
3569luaK_exp2nextreg(fs,
v);
3574if(!isnumeral(
v))luaK_exp2RK(fs,
v);
3586luaK_dischargevars(fs,e2);
3587luaK_concat(fs,&e2->
f,e1->
f);
3592luaK_dischargevars(fs,e2);
3593luaK_concat(fs,&e2->
t,e1->
t);
3605luaK_exp2nextreg(fs,e2);
3632(
INT_MAX-2),
"code size overflow");
3635(
INT_MAX-2),
"code size overflow");
3645static void luaK_setlist(
FuncState*fs,
int base,
int nelems,
int tostore){
3646int c=(nelems-1)/50+1;
3647int b=(tostore==(-1))?0:tostore;
3656#define hasmultret(k)((k)==VCALL||(k)==VVARARG)
3657#define getlocvar(fs,i)((fs)->f->locvars[(fs)->actvar[i]])
3658#define luaY_checklimit(fs,v,l,m)if((v)>(l))errorlimit(fs,l,m)
3668static void anchor_token(
LexState*ls){
3674static void error_expected(
LexState*ls,
int token){
3676luaO_pushfstring(ls->
L,
LUA_QL(
"%s")
" expected",luaX_token2str(ls,token)));
3678static void errorlimit(
FuncState*fs,
int limit,
const char*what){
3680luaO_pushfstring(fs->
L,
"main function has more than %d %s",limit,what):
3681luaO_pushfstring(fs->
L,
"function at line %d has more than %d %s",
3683luaX_lexerror(fs->
ls,
msg,0);
3685static int testnext(
LexState*ls,
int c){
3692static void check(
LexState*ls,
int c){
3694error_expected(ls,c);
3696static void checknext(
LexState*ls,
int c){
3700#define check_condition(ls,c,msg){if(!(c))luaX_syntaxerror(ls,msg);}
3701static void check_match(
LexState*ls,
int what,
int who,
int where){
3702if(!testnext(ls,what)){
3704error_expected(ls,what);
3706luaX_syntaxerror(ls,luaO_pushfstring(ls->
L,
3707LUA_QL(
"%s")
" expected (to close "LUA_QL(
"%s")
" at line %d)",
3708luaX_token2str(ls,what),luaX_token2str(ls,who),where));
3725init_exp(e,
VK,luaK_stringK(ls->
fs,
s));
3728codestring(ls,e,str_checkname(ls));
3735LocVar,SHRT_MAX,
"too many local variables");
3741#define new_localvarliteral(ls,v,n)new_localvar(ls,luaX_newstring(ls,""v,(sizeof(v)/sizeof(char))-1),n)
3747static void adjustlocalvars(
LexState*ls,
int nvars){
3754static void removevars(
LexState*ls,
int tolevel){
3763for(i=0;i<f->
nups;i++){
3771while(oldsize<f->sizeupvalues)f->
upvalues[oldsize++]=
NULL;
3786static void markupval(
FuncState*fs,
int level){
3793init_exp(var,
VGLOBAL,((1<<8)-1));
3797int v=searchvar(fs,
n);
3807var->
u.
s.
info=indexupvalue(fs,
n,var);
3814TString*varname=str_checkname(ls);
3816if(singlevaraux(fs,varname,var,1)==
VGLOBAL)
3817var->
u.
s.
info=luaK_stringK(fs,varname);
3821int extra=nvars-nexps;
3825luaK_setreturns(fs,e,extra);
3826if(extra>1)luaK_reserveregs(fs,extra-1);
3829if(e->
k!=
VVOID)luaK_exp2nextreg(fs,e);
3832luaK_reserveregs(fs,extra);
3833luaK_nil(fs,reg,extra);
3837static void enterlevel(
LexState*ls){
3839luaX_lexerror(ls,
"chunk has too many syntax levels",0);
3841#define leavelevel(ls)((ls)->L->nCcalls--)
3862int oldsize=f->
sizep;
3865((1<<(9+9))-1),
"constant table overflow");
3866while(oldsize<f->sizep)f->
p[oldsize++]=
NULL;
3870for(i=0;i<
func->f->nups;i++){
3872luaK_codeABC(fs,o,0,
func->upvalues[i].info,0);
3877Proto*f=luaF_newproto(L);
3894fs->
h=luaH_new(L,0,0);
3900static void close_func(
LexState*ls){
3919if(fs)anchor_token(ls);
3927open_func(&lexstate,&funcstate);
3928funcstate.f->is_vararg=2;
3929luaX_next(&lexstate);
3932close_func(&lexstate);
3938luaK_exp2anyreg(fs,
v);
3941luaK_indexed(fs,
v,&
key);
3946luaK_exp2val(
ls->
fs,
v);
3969rkkey=luaK_exp2RK(fs,&
key);
3976luaK_exp2nextreg(fs,&cc->
v);
3987luaK_setlist(fs,cc->
t->
u.
s.
info,cc->
na,(-1));
3992luaK_exp2nextreg(fs,&cc->
v);
4011luaK_exp2nextreg(ls->
fs,
t);
4014if(ls->
t.
token==
'}')
break;
4015closelistfield(fs,&cc);
4034}
while(testnext(ls,
',')||testnext(ls,
';'));
4035check_match(ls,
'}',
'{',
line);
4036lastlistfield(fs,&cc);
4049new_localvar(ls,str_checkname(ls),nparams++);
4057default:luaX_syntaxerror(ls,
"<name> or "LUA_QL(
"...")
" expected");
4061adjustlocalvars(ls,nparams);
4063luaK_reserveregs(fs,fs->
nactvar);
4067open_func(ls,&new_fs);
4072adjustlocalvars(ls,1);
4080pushclosure(ls,&new_fs,e);
4085while(testnext(ls,
',')){
4086luaK_exp2nextreg(ls->
fs,
v);
4100luaX_syntaxerror(ls,
"ambiguous syntax (function call x new statement)");
4108check_match(ls,
')',
'(',
line);
4112constructor(ls,&
args);
4121luaX_syntaxerror(ls,
"function arguments expected");
4130luaK_exp2nextreg(fs,&
args);
4133init_exp(f,
VCALL,luaK_codeABC(fs,
OP_CALL,base,nparams+1,2));
4134luaK_fixline(fs,
line);
4143check_match(ls,
')',
'(',
line);
4144luaK_dischargevars(ls->
fs,
v);
4152luaX_syntaxerror(ls,
"unexpected symbol");
4168luaK_exp2anyreg(fs,
v);
4170luaK_indexed(fs,
v,&
key);
4177luaK_self(fs,
v,&
key);
4182luaK_exp2nextreg(fs,
v);
4216"cannot use "LUA_QL(
"...")
" outside a vararg function");
4237static UnOpr getunopr(
int op){
4245static BinOpr getbinopr(
int op){
4269{6,6},{6,6},{7,7},{7,7},{7,7},
4272{3,3},{3,3},{3,3},{3,3},
4279uop=getunopr(ls->
t.
token);
4283luaK_prefix(ls->
fs,uop,
v);
4285else simpleexp(ls,
v);
4286op=getbinopr(ls->
t.
token);
4291luaK_infix(ls->
fs,op,
v);
4292nextop=subexpr(ls,&v2,priority[op].
right);
4293luaK_posfix(ls->
fs,op,
v,&v2);
4302static int block_follow(
int token){
4313enterblock(fs,&bl,0);
4325for(;lh;lh=lh->
prev){
4331if(lh->
v.
u.
s.
aux==
v->u.s.info){
4339luaK_reserveregs(fs,1);
4346if(testnext(ls,
',')){
4349primaryexp(ls,&nv.v);
4351check_conflict(ls,lh,&nv.v);
4353"variables in assignment");
4354assignment(ls,&nv,nvars+1);
4359nexps=explist1(ls,&e);
4361adjust_assign(ls,nvars,nexps,&e);
4366luaK_setoneret(ls->
fs,&e);
4367luaK_storevar(ls->
fs,&lh->
v,&e);
4372luaK_storevar(ls->
fs,&lh->
v,&e);
4378luaK_goiftrue(ls->
fs,&
v);
4390luaX_syntaxerror(ls,
"no loop to break");
4393luaK_concat(fs,&bl->
breaklist,luaK_jump(fs));
4401whileinit=luaK_getlabel(fs);
4403enterblock(fs,&bl,1);
4406luaK_patchlist(fs,luaK_jump(fs),whileinit);
4409luaK_patchtohere(fs,condexit);
4414int repeat_init=luaK_getlabel(fs);
4416enterblock(fs,&bl1,1);
4417enterblock(fs,&bl2,0);
4424luaK_patchlist(ls->
fs,condexit,repeat_init);
4428luaK_patchtohere(ls->
fs,condexit);
4430luaK_patchlist(ls->
fs,luaK_jump(fs),repeat_init);
4439luaK_exp2nextreg(ls->
fs,&e);
4442static void forbody(
LexState*ls,
int base,
int line,
int nvars,
int isnum){
4446adjustlocalvars(ls,3);
4449enterblock(fs,&bl,0);
4450adjustlocalvars(ls,nvars);
4451luaK_reserveregs(fs,nvars);
4454luaK_patchtohere(fs,prep);
4457luaK_fixline(fs,
line);
4458luaK_patchlist(fs,(isnum?endfor:luaK_jump(fs)),prep+1);
4466new_localvar(ls,varname,3);
4475luaK_reserveregs(fs,1);
4477forbody(ls,base,
line,1,1);
4488new_localvar(ls,indexname,nvars++);
4489while(testnext(ls,
','))
4490new_localvar(ls,str_checkname(ls),nvars++);
4493adjust_assign(ls,3,explist1(ls,&e),&e);
4494luaK_checkstack(fs,3);
4495forbody(ls,base,
line,nvars-3,0);
4501enterblock(fs,&bl,1);
4503varname=str_checkname(ls);
4505case'=':fornum(ls,varname,
line);
break;
4506case',':
case TK_IN:forlist(ls,varname);
break;
4507default:luaX_syntaxerror(ls,
LUA_QL(
"=")
" or "LUA_QL(
"in")
" expected");
4512static int test_then_block(
LexState*ls){
4524flist=test_then_block(ls);
4526luaK_concat(fs,&escapelist,luaK_jump(fs));
4527luaK_patchtohere(fs,flist);
4528flist=test_then_block(ls);
4531luaK_concat(fs,&escapelist,luaK_jump(fs));
4532luaK_patchtohere(fs,flist);
4537luaK_concat(fs,&escapelist,flist);
4538luaK_patchtohere(fs,escapelist);
4544new_localvar(ls,str_checkname(ls),0);
4546luaK_reserveregs(fs,1);
4547adjustlocalvars(ls,1);
4549luaK_storevar(fs,&
v,&b);
4557new_localvar(ls,str_checkname(ls),nvars++);
4558}
while(testnext(ls,
','));
4560nexps=explist1(ls,&e);
4565adjust_assign(ls,nvars,nexps,&e);
4566adjustlocalvars(ls,nvars);
4583needself=funcname(ls,&
v);
4585luaK_storevar(ls->
fs,&
v,&b);
4586luaK_fixline(ls->
fs,
line);
4607nret=explist1(ls,&e);
4618first=luaK_exp2anyreg(fs,&e);
4620luaK_exp2nextreg(fs,&e);
4625luaK_ret(fs,first,nret);
4682while(!islast&&!block_follow(ls->
t.
token)){
4683islast=statement(ls);
4718luaD_call(L,L->
top-3,1);
4731luaD_call(L,L->
top-4,0);
4735for(loop=0;loop<100;loop++){
4747luaG_typeerror(L,t,
"index");
4749callTMres(L,
val,tm,t,
key);
4754luaG_runerror(L,
"loop in gettable");
4759for(loop=0;loop<100;loop++){
4773luaG_typeerror(L,t,
"index");
4781luaG_runerror(L,
"loop in settable");
4785const TValue*tm=luaT_gettmbyobj(L,p1,event);
4787tm=luaT_gettmbyobj(L,p2,event);
4789callTMres(L,
res,tm,p1,p2);
4797if(mt1==mt2)
return tm1;
4800if(luaO_rawequalObj(tm1,tm2))
4806const TValue*tm1=luaT_gettmbyobj(L,p1,event);
4809tm2=luaT_gettmbyobj(L,p2,event);
4810if(!luaO_rawequalObj(tm1,tm2))
4812callTMres(L,L->
top,tm1,p1,p2);
4822if(temp!=0)
return temp;
4837return luaG_ordererror(L,l,r);
4842else if((
res=call_orderTM(L,l,r,
TM_LT))!=-1)
4844return luaG_ordererror(L,l,r);
4849return luaG_ordererror(L,l,r);
4854else if((
res=call_orderTM(L,l,r,
TM_LE))!=-1)
4856else if((
res=call_orderTM(L,r,l,
TM_LT))!=-1)
4858return luaG_ordererror(L,l,r);
4880if(tm==
NULL)
return 0;
4890luaG_concaterror(L,
top-2,
top-1);
4899if(l>=((
size_t)(~(
size_t)0)-2)-tl)luaG_runerror(L,
"string length overflow");
4902buffer=luaZ_openspace(L,&
G(L)->buff,tl);
4919if((b=luaV_tonumber(rb,&tempb))!=
NULL&&
4920(c=luaV_tonumber(rc,&tempc))!=
NULL){
4933else if(!call_binTM(L,rb,rc,ra,op))
4934luaG_aritherror(L,rb,rc);
4936#define runtime_check(L,c){if(!(c))break;}
4937#define RA(i)(base+GETARG_A(i))
4938#define RB(i)check_exp(getBMode(GET_OPCODE(i))==OpArgR,base+GETARG_B(i))
4939#define RKB(i)check_exp(getBMode(GET_OPCODE(i))==OpArgK,ISK(GETARG_B(i))?k+INDEXK(GETARG_B(i)):base+GETARG_B(i))
4940#define RKC(i)check_exp(getCMode(GET_OPCODE(i))==OpArgK,ISK(GETARG_C(i))?k+INDEXK(GETARG_C(i)):base+GETARG_C(i))
4941#define KBx(i)check_exp(getBMode(GET_OPCODE(i))==OpArgK,k+GETARG_Bx(i))
4942#define dojump(L,pc,i){(pc)+=(i);}
4943#define Protect(x){L->savedpc=pc;{x;};base=L->base;}
4944#define arith_op(op,tm){TValue*rb=RKB(i);TValue*rc=RKC(i);if(ttisnumber(rb)&&ttisnumber(rc)){lua_Number nb=nvalue(rb),nc=nvalue(rc);setnvalue(ra,op(nb,nc));}else Protect(Arith(L,ra,rb,rc,tm));}
4945static void luaV_execute(
lua_State*L,
int nexeccalls){
4989Protect(luaV_gettable(L,&g,rb,ra));
5015sethvalue(L,ra,luaH_new(L,luaO_fb2int(b),luaO_fb2int(c)));
5078if(!call_binTM(L,rb,(&luaO_nilobject_),ra,
TM_LEN))
5079luaG_typeerror(L,rb,
"get length of");
5142switch(luaD_precall(L,ra,nresults)){
5161switch(luaD_precall(L,ra,(-1))){
5169for(aux=0;pfunc+aux<L->
top;aux++)
5188if(b!=0)L->
top=ra+b-1;
5191b=luaD_poscall(L,ra);
5217luaG_runerror(L,
LUA_QL(
"for")
" initial value must be a number");
5219luaG_runerror(L,
LUA_QL(
"for")
" limit must be a number");
5221luaG_runerror(L,
LUA_QL(
"for")
" step must be a number");
5256luaH_resizearray(L,h,
last);
5274ncl=luaF_newLclosure(L,nup,cl->
env);
5276for(
j=0;
j<nup;
j++,pc++){
5311#define api_checknelems(L,n)luai_apicheck(L,(n)<=(L->top-L->base))
5312#define api_checkvalidindex(L,i)luai_apicheck(L,(i)!=(&luaO_nilobject_))
5313#define api_incr_top(L){luai_apicheck(L,L->top<L->ci->top);L->top++;}
5321else if(idx>(-10000)){
5332case(-10002):
return gt(L);
5336return(idx<=func->c.nupvalues)
5337?&
func->c.upvalue[idx-1]
5370static void lua_settop(
lua_State*L,
int idx){
5382static void lua_remove(
lua_State*L,
int idx){
5389static void lua_insert(
lua_State*L,
int idx){
5397static void lua_replace(
lua_State*L,
int idx){
5400luaG_runerror(L,
"no calling environment");
5417static void lua_pushvalue(
lua_State*L,
int idx){
5421static int lua_type(
lua_State*L,
int idx){
5422StkId o=index2adr(L,idx);
5423return(o==(&luaO_nilobject_))?(-1):
ttype(o);
5425static const char*lua_typename(
lua_State*L,
int t){
5427return(t==(-1))?
"no value":luaT_typenames[t];
5429static int lua_iscfunction(
lua_State*L,
int idx){
5430StkId o=index2adr(L,idx);
5433static int lua_isnumber(
lua_State*L,
int idx){
5435const TValue*o=index2adr(L,idx);
5438static int lua_isstring(
lua_State*L,
int idx){
5439int t=lua_type(L,idx);
5442static int lua_rawequal(
lua_State*L,
int index1,
int index2){
5443StkId o1=index2adr(L,index1);
5444StkId o2=index2adr(L,index2);
5445return(o1==(&luaO_nilobject_)||o2==(&luaO_nilobject_))?0
5446:luaO_rawequalObj(o1,o2);
5448static int lua_lessthan(
lua_State*L,
int index1,
int index2){
5451o1=index2adr(L,index1);
5452o2=index2adr(L,index2);
5453i=(o1==(&luaO_nilobject_)||o2==(&luaO_nilobject_))?0
5454:luaV_lessthan(L,o1,o2);
5459const TValue*o=index2adr(L,idx);
5467const TValue*o=index2adr(L,idx);
5477static int lua_toboolean(
lua_State*L,
int idx){
5478const TValue*o=index2adr(L,idx);
5481static const char*lua_tolstring(
lua_State*L,
int idx,
size_t*
len){
5482StkId o=index2adr(L,idx);
5484if(!luaV_tostring(L,o)){
5494static size_t lua_objlen(
lua_State*L,
int idx){
5495StkId o=index2adr(L,idx);
5498case 7:
return uvalue(o)->len;
5499case 5:
return luaH_getn(
hvalue(o));
5502l=(luaV_tostring(L,o)?
tsvalue(o)->len:0);
5509StkId o=index2adr(L,idx);
5512static void*lua_touserdata(
lua_State*L,
int idx){
5513StkId o=index2adr(L,idx);
5532static void lua_pushlstring(
lua_State*L,
const char*
s,
size_t len){
5537static void lua_pushstring(
lua_State*L,
const char*
s){
5543static const char*lua_pushvfstring(
lua_State*L,
const char*fmt,
5547ret=luaO_pushvfstring(L,fmt,argp);
5550static const char*lua_pushfstring(
lua_State*L,
const char*fmt,...){
5555ret=luaO_pushvfstring(L,fmt,argp);
5563cl=luaF_newCclosure(L,
n,getcurrenv(L));
5571static void lua_pushboolean(
lua_State*L,
int b){
5578return(
G(L)->mainthread==L);
5580static void lua_gettable(
lua_State*L,
int idx){
5584luaV_gettable(L,t,L->
top-1,L->
top-1);
5586static void lua_getfield(
lua_State*L,
int idx,
const char*k){
5592luaV_gettable(L,t,&
key,L->
top);
5595static void lua_rawget(
lua_State*L,
int idx){
5601static void lua_rawgeti(
lua_State*L,
int idx,
int n){
5608static void lua_createtable(
lua_State*L,
int narray,
int nrec){
5613static int lua_getmetatable(
lua_State*L,
int objindex){
5617obj=index2adr(L,objindex);
5638static void lua_getfenv(
lua_State*L,
int idx){
5658static void lua_settable(
lua_State*L,
int idx){
5663luaV_settable(L,t,L->
top-2,L->
top-1);
5666static void lua_setfield(
lua_State*L,
int idx,
const char*k){
5673luaV_settable(L,t,&
key,L->
top-1);
5676static void lua_rawset(
lua_State*L,
int idx){
5685static void lua_rawseti(
lua_State*L,
int idx,
int n){
5694static int lua_setmetatable(
lua_State*L,
int objindex){
5698obj=index2adr(L,objindex);
5708hvalue(obj)->metatable=mt;
5714uvalue(obj)->metatable=mt;
5727static int lua_setfenv(
lua_State*L,
int idx){
5752#define adjustresults(L,nres){if(nres==(-1)&&L->top>=L->ci->top)L->ci->top=L->top;}
5753#define checkresults(L,na,nr)luai_apicheck(L,(nr)==(-1)||(L->ci->top-L->top>=(nr)-(na)))
5754static void lua_call(
lua_State*L,
int nargs,
int nresults){
5759luaD_call(L,
func,nresults);
5779StkId o=index2adr(L,errfunc);
5783c.func=L->
top-(nargs+1);
5790const char*chunkname){
5793if(!chunkname)chunkname=
"?";
5794luaZ_init(L,&z,reader,
data);
5795status=luaD_protectedparser(L,&z,chunkname);
5803static int lua_next(
lua_State*L,
int idx){
5831u=luaS_newudata(L,
size,getcurrenv(L));
5836#define luaL_getn(L,i)((int)lua_objlen(L,i))
5837#define luaL_setn(L,i,j)((void)0)
5842static void luaI_openlib(
lua_State*L,
const char*libname,
5844static int luaL_argerror(
lua_State*L,
int numarg,
const char*extramsg);
5845static const char* luaL_checklstring(
lua_State*L,
int numArg,
5847static const char* luaL_optlstring(
lua_State*L,
int numArg,
5848const char*def,
size_t*l);
5852static int luaL_error(
lua_State*L,
const char*fmt,...);
5853static const char* luaL_findtable(
lua_State*L,
int idx,
5854const char*fname,
int szhint);
5855#define luaL_argcheck(L,cond,numarg,extramsg)((void)((cond)||luaL_argerror(L,(numarg),(extramsg))))
5856#define luaL_checkstring(L,n)(luaL_checklstring(L,(n),NULL))
5857#define luaL_optstring(L,n,d)(luaL_optlstring(L,(n),(d),NULL))
5858#define luaL_checkint(L,n)((int)luaL_checkinteger(L,(n)))
5859#define luaL_optint(L,n,d)((int)luaL_optinteger(L,(n),(d)))
5860#define luaL_typename(L,i)lua_typename(L,lua_type(L,(i)))
5861#define luaL_getmetatable(L,n)(lua_getfield(L,(-10000),(n)))
5862#define luaL_opt(L,f,n,d)(lua_isnoneornil(L,(n))?(d):f(L,(n)))
5869#define luaL_addchar(B,c)((void)((B)->p<((B)->buffer+BUFSIZ)||luaL_prepbuffer(B)),(*(B)->p++=(char)(c)))
5870#define luaL_addsize(B,n)((B)->p+=(n))
5872static int luaL_argerror(
lua_State*L,
int narg,
const char*extramsg){
5874if(!lua_getstack(L,0,&ar))
5875return luaL_error(L,
"bad argument #%d (%s)",narg,extramsg);
5876lua_getinfo(L,
"n",&ar);
5880return luaL_error(L,
"calling "LUA_QL(
"%s")
" on bad self (%s)",
5885return luaL_error(L,
"bad argument #%d to "LUA_QL(
"%s")
" (%s)",
5886narg,ar.
name,extramsg);
5888static int luaL_typerror(
lua_State*L,
int narg,
const char*tname){
5889const char*
msg=lua_pushfstring(L,
"%s expected, got %s",
5891return luaL_argerror(L,narg,
msg);
5893static void tag_error(
lua_State*L,
int narg,
int tag){
5894luaL_typerror(L,narg,lua_typename(L,tag));
5896static void luaL_where(
lua_State*L,
int level){
5898if(lua_getstack(L,level,&ar)){
5899lua_getinfo(L,
"Sl",&ar);
5907static int luaL_error(
lua_State*L,
const char*fmt,...){
5911lua_pushvfstring(L,fmt,argp);
5916static int luaL_newmetatable(
lua_State*L,
const char*tname){
5917lua_getfield(L,(-10000),tname);
5923lua_setfield(L,(-10000),tname);
5926static void*luaL_checkudata(
lua_State*L,
int ud,
const char*tname){
5927void*
p=lua_touserdata(L,ud);
5929if(lua_getmetatable(L,ud)){
5930lua_getfield(L,(-10000),tname);
5931if(lua_rawequal(L,-1,-2)){
5937luaL_typerror(L,ud,tname);
5940static void luaL_checkstack(
lua_State*L,
int space,
const char*mes){
5941if(!lua_checkstack(L,space))
5942luaL_error(L,
"stack overflow (%s)",mes);
5944static void luaL_checktype(
lua_State*L,
int narg,
int t){
5945if(lua_type(L,narg)!=t)
5948static void luaL_checkany(
lua_State*L,
int narg){
5949if(lua_type(L,narg)==(-1))
5950luaL_argerror(L,narg,
"value expected");
5952static const char*luaL_checklstring(
lua_State*L,
int narg,
size_t*
len){
5953const char*
s=lua_tolstring(L,narg,
len);
5954if(!
s)tag_error(L,narg,4);
5957static const char*luaL_optlstring(
lua_State*L,
int narg,
5958const char*def,
size_t*
len){
5964else return luaL_checklstring(L,narg,
len);
5968if(d==0&&!lua_isnumber(L,narg))
5974if(d==0&&!lua_isnumber(L,narg))
5980return luaL_opt(L,luaL_checkinteger,narg,def);
5982static int luaL_getmetafield(
lua_State*L,
int obj,
const char*event){
5983if(!lua_getmetatable(L,obj))
5985lua_pushstring(L,event);
5996static void luaL_register(
lua_State*L,
const char*libname,
5998luaI_openlib(L,libname,l,0);
6000static int libsize(
const luaL_Reg*l){
6005static void luaI_openlib(
lua_State*L,
const char*libname,
6009luaL_findtable(L,(-10000),
"_LOADED",1);
6010lua_getfield(L,-1,libname);
6013if(luaL_findtable(L,(-10002),libname,
size)!=
NULL)
6014luaL_error(L,
"name conflict for module "LUA_QL(
"%s"),libname);
6016lua_setfield(L,-3,libname);
6019lua_insert(L,-(nup+1));
6024lua_pushvalue(L,-nup);
6025lua_pushcclosure(L,l->
func,nup);
6026lua_setfield(L,-(nup+2),l->
name);
6030static const char*luaL_findtable(
lua_State*L,
int idx,
6031const char*fname,
int szhint){
6033lua_pushvalue(L,idx);
6037lua_pushlstring(L,fname,e-fname);
6041lua_createtable(L,0,(*e==
'.'?1:szhint));
6042lua_pushlstring(L,fname,e-fname);
6055#define bufflen(B)((B)->p-(B)->buffer)
6056#define bufffree(B)((size_t)(BUFSIZ-bufflen(B)))
6061lua_pushlstring(
B->L,
B->buffer,l);
6074if(
B->lvl-toget+1>=(20/2)||toplen>l){
6079}
while(toget<B->lvl);
6081B->lvl=
B->lvl-toget+1;
6089static void luaL_addlstring(
luaL_Buffer*
B,
const char*
s,
size_t l){
6095lua_concat(
B->L,
B->lvl);
6101const char*
s=lua_tolstring(L,-1,&vl);
6136static int errfile(
lua_State*L,
const char*what,
int fnameindex){
6137const char*serr=strerror(
errno);
6139lua_pushfstring(L,
"cannot %s %s: %s",what,filename,serr);
6140lua_remove(L,fnameindex);
6143static int luaL_loadfile(
lua_State*L,
const char*filename){
6147int fnameindex=lua_gettop(L)+1;
6154lua_pushfstring(L,
"@%s",filename);
6156if(lf.
f==
NULL)
return errfile(L,
"open",fnameindex);
6161while((c=getc(lf.
f))!=EOF&&c!=
'\n');
6162if(c==
'\n')c=getc(lf.
f);
6164if(c==
"\033Lua"[0]&&filename){
6165lf.
f=freopen(filename,
"rb",lf.
f);
6166if(lf.
f==
NULL)
return errfile(L,
"reopen",fnameindex);
6167while((c=getc(lf.
f))!=EOF&&c!=
"\033Lua"[0]);
6172readstatus=ferror(lf.
f);
6175lua_settop(L,fnameindex);
6176return errfile(L,
"read",fnameindex);
6178lua_remove(L,fnameindex);
6193static int luaL_loadbuffer(
lua_State*L,
const char*buff,
size_t size,
6198return lua_load(L,getS,&ls,
name);
6200static void*l_alloc(
void*ud,
void*
ptr,
size_t osize,
size_t nsize){
6208return realloc(
ptr,nsize);
6212fprintf(stderr,
"PANIC: unprotected error in call to Lua API (%s)\n",
6218if(L)lua_atpanic(L,&panic);
6225if(lua_isnumber(L,1)){
6226lua_pushnumber(L,lua_tonumber(L,1));
6235n=strtoul(s1,&s2,base);
6237while(isspace((
unsigned char)(*s2)))s2++;
6250if(lua_isstring(L,1)&&level>0){
6257static int luaB_setmetatable(
lua_State*L){
6259luaL_checktype(L,1,5);
6261"nil or table expected");
6262if(luaL_getmetafield(L,1,
"__metatable"))
6263luaL_error(L,
"cannot change a protected metatable");
6265lua_setmetatable(L,1);
6268static void getfunc(
lua_State*L,
int opt){
6274if(lua_getstack(L,level,&ar)==0)
6275luaL_argerror(L,1,
"invalid level");
6276lua_getinfo(L,
"f",&ar);
6278luaL_error(L,
"no function environment for tail call at level %d",
6283luaL_checktype(L,2,5);
6286if(lua_isnumber(L,1)&&lua_tonumber(L,1)==0){
6292else if(lua_iscfunction(L,-2)||lua_setfenv(L,-2)==0)
6294LUA_QL(
"setfenv")
" cannot change environment of given object");
6298luaL_checktype(L,1,5);
6310luaL_checktype(L,1,5);
6320luaL_checktype(L,1,5);
6328luaL_checktype(L,1,5);
6330lua_pushinteger(L,i);
6335luaL_checktype(L,1,5);
6338lua_pushinteger(L,0);
6352const char*
s=luaL_checklstring(L,1,&l);
6354return load_aux(L,luaL_loadbuffer(L,
s,l,chunkname));
6358return load_aux(L,luaL_loadfile(L,fname));
6362if(!lua_toboolean(L,1))
6363return luaL_error(L,
"%s",
luaL_optstring(L,2,
"assertion failed!"));
6364return lua_gettop(L);
6368luaL_checktype(L,1,5);
6373if(
n<=0||!lua_checkstack(L,
n))
6374return luaL_error(L,
"too many results to unpack");
6383status=lua_pcall(L,lua_gettop(L)-1,(-1),0);
6384lua_pushboolean(L,(
status==0));
6386return lua_gettop(L);
6390lua_newuserdata(L,0);
6391if(lua_toboolean(L,1)==0)
6396lua_pushboolean(L,1);
6401if(lua_getmetatable(L,1)){
6403validproxy=lua_toboolean(L,-1);
6407lua_getmetatable(L,1);
6409lua_setmetatable(L,2);
6412static const luaL_Reg base_funcs[]={
6413{
"assert",luaB_assert},
6414{
"error",luaB_error},
6415{
"loadfile",luaB_loadfile},
6416{
"loadstring",luaB_loadstring},
6418{
"pcall",luaB_pcall},
6419{
"rawget",luaB_rawget},
6420{
"setfenv",luaB_setfenv},
6421{
"setmetatable",luaB_setmetatable},
6422{
"tonumber",luaB_tonumber},
6424{
"unpack",luaB_unpack},
6430lua_pushcclosure(L,f,1);
6431lua_setfield(L,-2,
name);
6434lua_pushvalue(L,(-10002));
6436luaL_register(L,
"_G",base_funcs);
6439auxopen(L,
"ipairs",luaB_ipairs,ipairsaux);
6440auxopen(L,
"pairs",luaB_pairs,luaB_next);
6441lua_createtable(L,0,1);
6443lua_setmetatable(L,-2);
6445lua_setfield(L,-2,
"__mode");
6446lua_pushcclosure(L,luaB_newproxy,1);
6453#define aux_getn(L,n)(luaL_checktype(L,n,5),luaL_getn(L,n))
6457switch(lua_gettop(L)){
6467lua_rawgeti(L,1,i-1);
6473return luaL_error(L,
"wrong number of arguments to "LUA_QL(
"insert"));
6477lua_rawseti(L,1,
pos);
6486lua_rawgeti(L,1,
pos);
6488lua_rawgeti(L,1,
pos+1);
6489lua_rawseti(L,1,
pos);
6497if(!lua_isstring(L,-1))
6498luaL_error(L,
"invalid value (%s) at index %d in table for "
6506const char*sep=luaL_optlstring(L,2,
"",&lsep);
6507luaL_checktype(L,1,5);
6513luaL_addlstring(&b,sep,lsep);
6524static int sort_comp(
lua_State*L,
int a,
int b){
6528lua_pushvalue(L,
a-1);
6529lua_pushvalue(L,b-2);
6531res=lua_toboolean(L,-1);
6536return lua_lessthan(L,
a,b);
6543if(sort_comp(L,-1,-2))
6551if(sort_comp(L,-2,-1))
6556if(sort_comp(L,-1,-2))
6564lua_rawgeti(L,1,
u-1);
6568while(lua_rawgeti(L,1,++i),sort_comp(L,-1,-2)){
6569if(i>
u)luaL_error(L,
"invalid order function for sorting");
6572while(lua_rawgeti(L,1,--
j),sort_comp(L,-3,-1)){
6573if(
j<l)luaL_error(L,
"invalid order function for sorting");
6582lua_rawgeti(L,1,
u-1);
6596luaL_checkstack(L,40,
"");
6598luaL_checktype(L,2,6);
6611luaL_register(L,
"table",tab_funcs);
6614static const char*
const fnames[]={
"input",
"output"};
6615static int pushresult(
lua_State*L,
int i,
const char*filename){
6618lua_pushboolean(L,1);
6624lua_pushfstring(L,
"%s: %s",filename,strerror(en));
6626lua_pushfstring(L,
"%s",strerror(en));
6627lua_pushinteger(L,en);
6631static void fileerror(
lua_State*L,
int arg,
const char*filename){
6632lua_pushfstring(L,
"%s: %s",filename,strerror(
errno));
6635#define tofilep(L)((FILE**)luaL_checkudata(L,1,"FILE*"))
6639ud=lua_touserdata(L,1);
6640lua_getfield(L,(-10000),
"FILE*");
6641if(ud==
NULL||!lua_getmetatable(L,1)||!lua_rawequal(L,-2,-1))
6643else if(*((FILE**)ud)==
NULL)
6652luaL_error(L,
"attempt to use a closed file");
6656FILE**pf=(FILE**)lua_newuserdata(L,
sizeof(FILE*));
6659lua_setmetatable(L,-2);
6671return pushresult(L,ok,
NULL);
6677return pushresult(L,ok,
NULL);
6681lua_getfield(L,-1,
"__close");
6682return(lua_tocfunction(L,-1))(L);
6686lua_rawgeti(L,(-10001),2);
6701return(*pf==
NULL)?pushresult(L,0,filename):1;
6703static FILE*getiofile(
lua_State*L,
int findex){
6705lua_rawgeti(L,(-10001),findex);
6706f=*(FILE**)lua_touserdata(L,-1);
6708luaL_error(L,
"standard %s file is closed",fnames[findex-1]);
6718fileerror(L,1,filename);
6724lua_rawseti(L,(-10001),f);
6726lua_rawgeti(L,(-10001),f);
6730return g_iofile(L,1,
"r");
6733return g_iofile(L,2,
"w");
6736static void aux_lines(
lua_State*L,
int idx,
int toclose){
6737lua_pushvalue(L,idx);
6738lua_pushboolean(L,toclose);
6739lua_pushcclosure(L,io_readline,2);
6748lua_rawgeti(L,(-10001),1);
6754*pf=
fopen(filename,
"r");
6756fileerror(L,1,filename);
6757aux_lines(L,lua_gettop(L),1);
6761static int read_number(
lua_State*L,FILE*f){
6763if(
fscanf(f,
"%lf",&d)==1){
6775lua_pushlstring(L,
NULL,0);
6778static int read_line(
lua_State*L,FILE*f){
6783char*
p=luaL_prepbuffer(&b);
6786return(lua_objlen(L,-1)>0);
6789if(l==0||
p[l-1]!=
'\n')
6798static int read_chars(
lua_State*L,FILE*f,
size_t n){
6805char*
p=luaL_prepbuffer(&b);
6807nr=
fread(
p,
sizeof(
char),rlen,f);
6810}
while(
n>0&&nr==rlen);
6812return(
n==0||lua_objlen(L,-1)>0);
6814static int g_read(
lua_State*L,FILE*f,
int first){
6815int nargs=lua_gettop(L)-1;
6820success=read_line(L,f);
6824luaL_checkstack(L,nargs+20,
"too many arguments");
6826for(
n=first;nargs--&&success;
n++){
6827if(lua_type(L,
n)==3){
6828size_t l=(size_t)lua_tointeger(L,
n);
6829success=(l==0)?test_eof(L,f):read_chars(L,f,l);
6836success=read_number(L,f);
6839success=read_line(L,f);
6842read_chars(L,f,~((
size_t)0));
6846return luaL_argerror(L,
n,
"invalid format");
6852return pushresult(L,0,
NULL);
6860return g_read(L,getiofile(L,1),1);
6863return g_read(L,tofile(L),2);
6869luaL_error(L,
"file is already closed");
6870success=read_line(L,f);
6872return luaL_error(L,
"%s",strerror(
errno));
6884int nargs=lua_gettop(L)-1;
6887if(lua_type(L,
arg)==3){
6893const char*
s=luaL_checklstring(L,
arg,&l);
6900return g_write(L,getiofile(L,2),1);
6903return g_write(L,tofile(L),2);
6906return pushresult(L,
fflush(getiofile(L,2))==0,
NULL);
6909return pushresult(L,
fflush(tofile(L))==0,
NULL);
6917{
"output",io_output},
6933luaL_newmetatable(L,
"FILE*");
6935lua_setfield(L,-2,
"__index");
6936luaL_register(L,
NULL,flib);
6938static void createstdfile(
lua_State*L,FILE*f,
int k,
const char*fname){
6942lua_rawseti(L,(-10001),k);
6946lua_setfield(L,-3,fname);
6949lua_createtable(L,0,1);
6951lua_setfield(L,-2,
"__close");
6955newfenv(L,io_fclose);
6956lua_replace(L,(-10001));
6957luaL_register(L,
"io",iolib);
6958newfenv(L,io_noclose);
6959createstdfile(L,stdin,1,
"stdin");
6960createstdfile(L,stdout,2,
"stdout");
6961createstdfile(L,stderr,0,
"stderr");
6963lua_getfield(L,-1,
"popen");
6964newfenv(L,io_pclose);
6969static int os_pushresult(
lua_State*L,
int i,
const char*filename){
6972lua_pushboolean(L,1);
6977lua_pushfstring(L,
"%s: %s",filename,strerror(en));
6978lua_pushinteger(L,en);
6984return os_pushresult(L,remove(filename)==0,filename);
6995{
"remove",os_remove},
7000luaL_register(L,
"os",syslib);
7003#define uchar(c)((unsigned char)(c))
7010const char*
s=luaL_checklstring(L,1,&l);
7024const char*
s=luaL_checklstring(L,1,&l);
7035const char*
s=luaL_checklstring(L,1,&l);
7045const char*
s=luaL_checklstring(L,1,&l);
7049luaL_addlstring(&b,
s,l);
7055const char*
s=luaL_checklstring(L,1,&l);
7056ptrdiff_t posi=posrelat(luaL_optinteger(L,2,1),l);
7057ptrdiff_t pose=posrelat(luaL_optinteger(L,3,posi),l);
7060if((
size_t)pose>l)pose=l;
7061if(posi>pose)
return 0;
7062n=(int)(pose-posi+1);
7064luaL_error(L,
"string slice too long");
7065luaL_checkstack(L,
n,
"string slice too long");
7067lua_pushinteger(L,
uchar(
s[posi+i-1]));
7093static int check_capture(
MatchState*ms,
int l){
7096return luaL_error(ms->
L,
"invalid capture index");
7101for(level--;level>=0;level--)
7103return luaL_error(ms->
L,
"invalid pattern capture");
7105static const char*classend(
MatchState*ms,
const char*
p){
7109luaL_error(ms->
L,
"malformed pattern (ends with "LUA_QL(
"%%")
")");
7116luaL_error(ms->
L,
"malformed pattern (missing "LUA_QL(
"]")
")");
7117if(*(
p++)==
'%'&&*
p!=
'\0')
7127static int match_class(
int c,
int cl){
7130case'a':
res=isalpha(c);
break;
7131case'c':
res=iscntrl(c);
break;
7132case'd':
res=isdigit(c);
break;
7133case'l':
res=islower(c);
break;
7134case'p':
res=ispunct(c);
break;
7135case's':
res=isspace(c);
break;
7136case'u':
res=isupper(c);
break;
7137case'w':
res=isalnum(c);
break;
7138case'x':
res=isxdigit(c);
break;
7139case'z':
res=(c==0);
break;
7140default:
return(cl==c);
7142return(islower(cl)?
res:!
res);
7144static int matchbracketclass(
int c,
const char*
p,
const char*ec){
7153if(match_class(c,
uchar(*
p)))
7156else if((*(
p+1)==
'-')&&(
p+2<ec)){
7161else if(
uchar(*
p)==c)
return sig;
7165static int singlematch(
int c,
const char*
p,
const char*ep){
7168case'%':
return match_class(c,
uchar(*(
p+1)));
7169case'[':
return matchbracketclass(c,
p,ep-1);
7170default:
return(
uchar(*
p)==c);
7174static const char*matchbalance(
MatchState*ms,
const char*
s,
7177luaL_error(ms->
L,
"unbalanced pattern");
7185if(--
cont==0)
return s+1;
7187else if(*
s==b)
cont++;
7192static const char*max_expand(
MatchState*ms,
const char*
s,
7193const char*
p,
const char*ep){
7204static const char*min_expand(
MatchState*ms,
const char*
s,
7205const char*
p,
const char*ep){
7215static const char*start_capture(
MatchState*ms,
const char*
s,
7216const char*
p,
int what){
7219if(level>=32)luaL_error(ms->
L,
"too many captures");
7227static const char*end_capture(
MatchState*ms,
const char*
s,
7229int l=capture_to_close(ms);
7236static const char*match_capture(
MatchState*ms,
const char*
s,
int l){
7238l=check_capture(ms,l);
7250return start_capture(ms,
s,
p+2,(-2));
7252return start_capture(ms,
s,
p+1,(-1));
7255return end_capture(ms,
s,
p+1);
7260s=matchbalance(ms,
s,
p+2);
7265const char*ep;
char previous;
7268luaL_error(ms->
L,
"missing "LUA_QL(
"[")
" after "
7269LUA_QL(
"%%f")
" in pattern");
7272if(matchbracketclass(
uchar(previous),
p,ep-1)||
7277if(isdigit(
uchar(*(
p+1)))){
7278s=match_capture(ms,
s,
uchar(*(
p+1)));
7295const char*ep=classend(ms,
p);
7305return max_expand(ms,
s,
p,ep);
7308return(m?max_expand(ms,
s+1,
p,ep):
NULL);
7311return min_expand(ms,
s,
p,ep);
7321static const char*lmemfind(
const char*s1,
size_t l1,
7322const char*s2,
size_t l2){
7324else if(l2>l1)
return NULL;
7329while(l1>0&&(init=(
const char*)memchr(s1,*s2,l1))!=
NULL){
7331if(memcmp(init,s2+1,l2)==0)
7341static void push_onecapture(
MatchState*ms,
int i,
const char*
s,
7345lua_pushlstring(ms->
L,
s,e-
s);
7347luaL_error(ms->
L,
"invalid capture index");
7351if(l==(-1))luaL_error(ms->
L,
"unfinished capture");
7358static int push_captures(
MatchState*ms,
const char*
s,
const char*e){
7360int nlevels=(ms->
level==0&&
s)?1:ms->level;
7361luaL_checkstack(ms->
L,nlevels,
"too many captures");
7362for(i=0;i<nlevels;i++)
7363push_onecapture(ms,i,
s,e);
7366static int str_find_aux(
lua_State*L,
int find){
7368const char*
s=luaL_checklstring(L,1,&l1);
7369const char*
p=luaL_checklstring(L,2,&l2);
7370ptrdiff_t init=posrelat(luaL_optinteger(L,3,1),l1)-1;
7372else if((
size_t)(init)>l1)init=(
ptrdiff_t)l1;
7373if(find&&(lua_toboolean(L,4)||
7375const char*s2=lmemfind(
s+init,l1-init,
p,l2);
7377lua_pushinteger(L,s2-
s+1);
7378lua_pushinteger(L,s2-
s+l2);
7384int anchor=(*
p==
'^')?(
p++,1):0;
7385const char*s1=
s+init;
7394lua_pushinteger(L,s1-
s+1);
7395lua_pushinteger(L,
res-
s);
7396return push_captures(&ms,
NULL,0)+2;
7399return push_captures(&ms,s1,
res);
7401}
while(s1++<ms.
src_end&&!anchor);
7407return str_find_aux(L,1);
7410return str_find_aux(L,0);
7428if(e==src)newstart++;
7429lua_pushinteger(L,newstart);
7431return push_captures(&ms,src,e);
7440lua_pushinteger(L,0);
7441lua_pushcclosure(L,gmatch_aux,3);
7447const char*news=lua_tolstring(ms->
L,3,&l);
7453if(!isdigit(
uchar(news[i])))
7455else if(news[i]==
'0')
7456luaL_addlstring(b,
s,e-
s);
7458push_onecapture(ms,news[i]-
'1',
s,e);
7467switch(lua_type(L,3)){
7476n=push_captures(ms,
s,e);
7481push_onecapture(ms,0,
s,e);
7486if(!lua_toboolean(L,-1)){
7488lua_pushlstring(L,
s,e-
s);
7490else if(!lua_isstring(L,-1))
7491luaL_error(L,
"invalid replacement value (a %s)",
luaL_typename(L,-1));
7496const char*src=luaL_checklstring(L,1,&srcl);
7498int tr=lua_type(L,3);
7500int anchor=(*
p==
'^')?(
p++,1):0;
7506"string/function/table expected");
7517add_value(&ms,&b,src,e);
7526luaL_addlstring(&b,src,ms.
src_end-src);
7528lua_pushinteger(L,
n);
7533const char*
s=luaL_checklstring(L,
arg,&l);
7537case'"':
case'\\':
case'\n':{
7543luaL_addlstring(b,
"\\r",2);
7547luaL_addlstring(b,
"\\000",4);
7559static const char*scanformat(
lua_State*L,
const char*strfrmt,
char*form){
7560const char*
p=strfrmt;
7562if((
size_t)(
p-strfrmt)>=
sizeof(
"-+ #0"))
7563luaL_error(L,
"invalid format (repeated flags)");
7572luaL_error(L,
"invalid format (width or precision too long)");
7574strncpy(form,strfrmt,
p-strfrmt+1);
7579static void addintlen(
char*form){
7582strcpy(form+l-1,
"l");
7583form[l+
sizeof(
"l")-2]=spec;
7584form[l+
sizeof(
"l")-1]=
'\0';
7587int top=lua_gettop(L);
7590const char*strfrmt=luaL_checklstring(L,
arg,&sfl);
7591const char*strfrmt_end=strfrmt+sfl;
7594while(strfrmt<strfrmt_end){
7597else if(*++strfrmt==
'%')
7600char form[(
sizeof(
"-+ #0")+
sizeof(
"l")+10)];
7603luaL_argerror(L,
arg,
"no value");
7604strfrmt=scanformat(L,strfrmt,form);
7607sprintf(buff,form,(
int)luaL_checknumber(L,
arg));
7612sprintf(buff,form,(
long)luaL_checknumber(L,
arg));
7615case'o':
case'u':
case'x':
case'X':{
7617sprintf(buff,form,(
unsigned long)luaL_checknumber(L,
arg));
7620case'e':
case'E':
case'f':
7622sprintf(buff,form,(
double)luaL_checknumber(L,
arg));
7631const char*
s=luaL_checklstring(L,
arg,&l);
7632if(!
strchr(form,
'.')&&l>=100){
7633lua_pushvalue(L,
arg);
7643return luaL_error(L,
"invalid option "LUA_QL(
"%%%c")
" to "
7644LUA_QL(
"format"),*(strfrmt-1));
7647luaL_addlstring(&b,buff,
strlen(buff));
7657{
"format",str_format},
7667static void createmetatable(
lua_State*L){
7668lua_createtable(L,0,1);
7671lua_setmetatable(L,-2);
7674lua_setfield(L,-2,
"__index");
7678luaL_register(L,
"string",strlib);
7684{
"table",luaopen_table},
7687{
"string",luaopen_string},
7694lua_pushstring(L,
lib->name);
7701bn.n=lua_tonumber(L,idx)+6755399441055744.0;
7702if(bn.n==0.0&&!lua_isnumber(L,idx))luaL_typerror(L,idx,
"number");
7705#define BRET(b)lua_pushnumber(L,(lua_Number)(int)(b));return 1;
7711int i;
UB b=barg(L,1);
for(i=lua_gettop(L);i>1;i--)b&=barg(L,i);
BRET(b)}
7713int i;
UB b=barg(L,1);
for(i=lua_gettop(L);i>1;i--)b|=barg(L,i);
BRET(b)}
7715int i;
UB b=barg(L,1);
for(i=lua_gettop(L);i>1;i--)b^=barg(L,i);
BRET(b)}
7717UB b=barg(L,1),
n=barg(L,2)&31;
BRET(b<<
n)}
7719UB b=barg(L,1),
n=barg(L,2)&31;
BRET(b>>
n)}
7721UB b=barg(L,1),
n=barg(L,2)&31;
BRET((
int)b>>
n)}
7723UB b=barg(L,1),
n=barg(L,2)&31;
BRET((b<<
n)|(b>>(32-
n)))}
7725UB b=barg(L,1),
n=barg(L,2)&31;
BRET((b>>
n)|(b<<(32-
n)))}
7727UB b=barg(L,1);b=(b>>24)|((b>>8)&0xff00)|((b&0xff00)<<8)|(b<<24);
BRET(b)}
7731const char*hexdigits=
"0123456789abcdef";
7734if(
n<0){
n=-
n;hexdigits=
"0123456789ABCDEF";}
7736for(i=(
int)
n;--i>=0;){
buf[i]=hexdigits[b&15];b>>=4;}
7737lua_pushlstring(L,
buf,(
size_t)
n);
7740static const struct luaL_Reg bitlib[]={
7759luaL_register(L,
"bit",bitlib);
7760if(argc<2)
return sizeof(
void*);
7761lua_createtable(L,0,1);
7762lua_pushstring(L,argv[1]);
7765if(luaL_loadfile(L,argv[1]))
7768lua_pushstring(L,argv[i]);
7769if(lua_pcall(L,argc-2,0,0)){
fprintf($stream, string $format, mixed ... $values)
strcoll(string $string1, string $string2)
fwrite($stream, string $data, ?int $length=null)
strpbrk(string $string, string $characters)
fopen(string $filename, string $mode, bool $use_include_path=false, $context=null)
count(Countable|array $value, int $mode=COUNT_NORMAL)
fscanf($stream, string $format, mixed &... $vars)
fread($stream, int $length)
strcspn(string $string, string $characters, int $offset=0, ?int $length=null)
fgets($stream, ?int $length=null)
strchr(string $haystack, string $needle, bool $before_needle=false)
zend_ffi_ctype_name_buf buf
sprintf("0x%X", $numelems)
#define lua_number2integer(i, d)
#define luaZ_sizebuffer(buff)
void(* Pfunc)(lua_State *L, void *ud)
#define setptvalue(L, obj, x)
#define lua_pclose(L, file)
#define luaM_freearray(L, b, n, t)
#define new_localvarliteral(ls, v, n)
#define luaM_freemem(L, b, s)
#define lua_istable(L, n)
const char *(* lua_Reader)(lua_State *L, void *ud, size_t *sz)
#define luaS_newliteral(L, s)
#define luai_numdiv(a, b)
#define luai_numpow(a, b)
#define luaL_getmetatable(L, n)
#define luaC_barrier(L, p, v)
#define luaZ_initbuffer(L, buff)
#define setbvalue(obj, x)
#define setsvalue(L, obj, x)
#define luaZ_bufflen(buff)
#define setttype(obj, tt)
#define api_checkvalidindex(L, i)
#define luai_numadd(a, b)
void *(* lua_Alloc)(void *ud, void *ptr, size_t osize, size_t nsize)
#define luaL_typename(L, i)
#define luaL_addsize(B, n)
#define lua_pushcfunction(L, f)
#define luaM_malloc(L, t)
#define luaM_growvector(L, v, nelems, size, t, limit, e)
#define restorestack(L, n)
#define lua_number2int(i, d)
#define CREATE_ABx(o, a, bc)
#define lua_pushliteral(L, s)
#define opmode(t, a, b, c, m)
#define lua_str2number(s, p)
#define luai_numsub(a, b)
#define luaK_setmultret(fs, e)
#define luaZ_resetbuffer(buff)
#define luaZ_freebuffer(L, buff)
#define luaM_reallocv(L, b, on, n, e)
#define sweepwholelist(L, p)
#define luaL_addchar(B, c)
#define luaL_setn(L, i, j)
#define luaY_checklimit(fs, v, l, m)
#define checkresults(L, na, nr)
#define setnvalue(obj, x)
#define luaM_newvector(L, n, t)
#define lua_number2str(s, n)
#define luaL_optstring(L, n, d)
#define lua_isfunction(L, n)
#define luaK_codeAsBx(fs, o, A, sBx)
#define setclvalue(L, obj, x)
#define set2bits(x, b1, b2)
#define luaC_objbarriert(L, t, o)
#define CREATE_ABC(o, a, b, c)
int(* lua_CFunction)(lua_State *L)
#define luaC_objbarrier(L, p, o)
#define hashboolean(t, p)
#define api_checknelems(L, n)
#define setthvalue(L, obj, x)
void(* lua_Hook)(lua_State *L, lua_Debug *ar)
#define equalobj(L, o1, o2)
#define luaZ_buffer(buff)
#define gfasttm(g, et, e)
#define luaM_reallocvector(L, v, oldn, n, t)
#define luaD_checkstack(L, n)
#define luaZ_resizebuffer(L, buff, size)
#define setuvalue(L, obj, x)
#define luaL_optint(L, n, d)
#define sethvalue(L, obj, x)
#define lua_setglobal(L, s)
#define luai_nummod(a, b)
#define hashpointer(t, p)
#define luai_apicheck(L, o)
#define lua_upvalueindex(i)
#define resethookcount(L)
#define save_and_next(ls)
#define lua_tostring(L, i)
#define runtime_check(L, c)
#define luaL_opt(L, f, n, d)
#define setobj(L, obj1, obj2)
#define luai_nummul(a, b)
#define LUAI_TRY(L, c, a)
#define luaL_checkstring(L, n)
#define luaL_checkint(L, n)
#define condhardstacktests(x)
#define check_condition(ls, c, msg)
#define currIsNewline(ls)
#define luaC_barriert(L, t, v)
#define lua_isboolean(L, n)
#define lua_isnoneornil(L, n)
#define adjustresults(L, nres)
#define luaL_argcheck(L, cond, numarg, extramsg)
unsigned const char * end
unsigned const char * pos
unsigned char key[REFLECTION_KEY_LEN]
file_private int match(struct magic_set *, struct magic *, size_t, const struct buffer *, size_t, int, int, int, uint16_t *, uint16_t *, int *, int *, int *, int *, int *)
struct BlockCnt * previous
const Instruction * savedpc
unsigned short actvar[200]
struct MatchState::@120131246100120052064267210373337351142355163201 capture[32]
union UpVal::@275257324137165337304352246243010373124003120264 u
struct UpVal::@275257324137165337304352246243010373124003120264::@135107111276262225004235301025015007353276352267 l
union expdesc::@041141057303045127141122225106320251102201046222 u
struct expdesc::@041141057303045127141122225106320251102201046222::@224146035374335351044146163155135212216230167264 s
struct lua_State * mainthread
struct lua_longjmp * errorJmp
unsigned short baseCcalls
const Instruction * savedpc
struct lua_longjmp * previous
struct TKey::@212376176040020173121071275237135232242014215374 nk
struct TString::@214251145010007037147007316171114361307056376330 tsv
struct Udata::@217325143057140064336162176003334340274303160166 uv
exit(string|int $status=0)
strcmp(string $string1, string $string2)
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)