Lines Matching refs:L
47 int luaV_tostring (lua_State *L, StkId obj) { in luaV_tostring() argument
54 setsvalue2s(L, obj, luaS_newlstr(L, s, l)); in luaV_tostring()
60 static void traceexec (lua_State *L) { in traceexec() argument
61 CallInfo *ci = L->ci; in traceexec()
62 lu_byte mask = L->hookmask; in traceexec()
63 int counthook = ((mask & LUA_MASKCOUNT) && L->hookcount == 0); in traceexec()
65 resethookcount(L); /* reset count */ in traceexec()
71 luaD_hook(L, LUA_HOOKCOUNT, -1); /* call count hook */ in traceexec()
77 ci->u.l.savedpc <= L->oldpc || /* when jump back (loop), or when */ in traceexec()
78 newline != getfuncline(p, pcRel(L->oldpc, p))) /* enter a new line */ in traceexec()
79 luaD_hook(L, LUA_HOOKLINE, newline); /* call line hook */ in traceexec()
81 L->oldpc = ci->u.l.savedpc; in traceexec()
82 if (L->status == LUA_YIELD) { /* did hook yield? */ in traceexec()
84 L->hookcount = 1; /* undo decrement to zero */ in traceexec()
87 ci->func = L->top - 1; /* protect stack below results */ in traceexec()
88 luaD_throw(L, LUA_YIELD); in traceexec()
93 static void callTM (lua_State *L, const TValue *f, const TValue *p1, in callTM() argument
95 ptrdiff_t result = savestack(L, p3); in callTM()
96 setobj2s(L, L->top++, f); /* push function */ in callTM()
97 setobj2s(L, L->top++, p1); /* 1st argument */ in callTM()
98 setobj2s(L, L->top++, p2); /* 2nd argument */ in callTM()
100 setobj2s(L, L->top++, p3); /* 3rd argument */ in callTM()
102 luaD_call(L, L->top - (4 - hasres), hasres, isLua(L->ci)); in callTM()
104 p3 = restorestack(L, result); in callTM()
105 setobjs2s(L, p3, --L->top); in callTM()
110 void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { in luaV_gettable() argument
118 (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */ in luaV_gettable()
119 setobj2s(L, val, res); in luaV_gettable()
124 else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))) in luaV_gettable()
125 luaG_typeerror(L, t, "index"); in luaV_gettable()
127 callTM(L, tm, t, key, val, 1); in luaV_gettable()
132 luaG_runerror(L, "loop in gettable"); in luaV_gettable()
136 void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { in luaV_settable() argument
147 ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL && in luaV_settable()
152 (oldval = luaH_newkey(L, h, key), 1)))) { in luaV_settable()
154 setobj2t(L, oldval, val); /* assign new value to that entry */ in luaV_settable()
156 luaC_barrierback(L, obj2gco(h), val); in luaV_settable()
162 if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) in luaV_settable()
163 luaG_typeerror(L, t, "index"); in luaV_settable()
166 callTM(L, tm, t, key, val, 0); in luaV_settable()
171 luaG_runerror(L, "loop in settable"); in luaV_settable()
175 static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2, in call_binTM() argument
177 const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ in call_binTM()
179 tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ in call_binTM()
181 callTM(L, tm, p1, p2, res, 1); in call_binTM()
186 static const TValue *get_equalTM (lua_State *L, Table *mt1, Table *mt2, in get_equalTM() argument
188 const TValue *tm1 = fasttm(L, mt1, event); in get_equalTM()
192 tm2 = fasttm(L, mt2, event); in get_equalTM()
200 static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2, in call_orderTM() argument
202 if (!call_binTM(L, p1, p2, L->top, event)) in call_orderTM()
205 return !l_isfalse(L->top); in call_orderTM()
231 int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { in luaV_lessthan() argument
234 return luai_numlt(L, nvalue(l), nvalue(r)); in luaV_lessthan()
237 else if ((res = call_orderTM(L, l, r, TM_LT)) < 0) in luaV_lessthan()
238 luaG_ordererror(L, l, r); in luaV_lessthan()
243 int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r) { in luaV_lessequal() argument
246 return luai_numle(L, nvalue(l), nvalue(r)); in luaV_lessequal()
249 else if ((res = call_orderTM(L, l, r, TM_LE)) >= 0) /* first try `le' */ in luaV_lessequal()
251 else if ((res = call_orderTM(L, r, l, TM_LT)) < 0) /* else try `lt' */ in luaV_lessequal()
252 luaG_ordererror(L, l, r); in luaV_lessequal()
260 int luaV_equalobj_ (lua_State *L, const TValue *t1, const TValue *t2) { in luaV_equalobj_() argument
273 else if (L == NULL) return 0; in luaV_equalobj_()
274 tm = get_equalTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable, TM_EQ); in luaV_equalobj_()
279 else if (L == NULL) return 0; in luaV_equalobj_()
280 tm = get_equalTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ); in luaV_equalobj_()
288 callTM(L, tm, t1, t2, L->top, 1); /* call TM */ in luaV_equalobj_()
289 return !l_isfalse(L->top); in luaV_equalobj_()
293 void luaV_concat (lua_State *L, int total) { in luaV_concat() argument
296 StkId top = L->top; in luaV_concat()
298 if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { in luaV_concat()
299 if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) in luaV_concat()
300 luaG_concaterror(L, top-2, top-1); in luaV_concat()
303 (void)tostring(L, top - 2); /* result is first operand */ in luaV_concat()
305 setobjs2s(L, top - 2, top - 1); /* result is second op. */ in luaV_concat()
313 for (i = 1; i < total && tostring(L, top-i-1); i++) { in luaV_concat()
316 luaG_runerror(L, "string length overflow"); in luaV_concat()
319 buffer = luaZ_openspace(L, &G(L)->buff, tl); in luaV_concat()
327 setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl)); in luaV_concat()
330 L->top -= n-1; /* popped 'n' strings and pushed one */ in luaV_concat()
335 void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) { in luaV_objlen() argument
340 tm = fasttm(L, h->metatable, TM_LEN); in luaV_objlen()
350 tm = luaT_gettmbyobj(L, rb, TM_LEN); in luaV_objlen()
352 luaG_typeerror(L, rb, "get length of"); in luaV_objlen()
356 callTM(L, tm, rb, rb, ra, 1); in luaV_objlen()
371 static lua_Number luaV_div (lua_State *L, lua_Number m, lua_Number n) { in luaV_div() argument
374 luaG_runerror(L, "attempt to divide by zero"); in luaV_div()
391 static lua_Number luaV_mod (lua_State *L, lua_Number m, lua_Number n) { in luaV_mod() argument
394 luaG_runerror(L, "attempt to perform 'n%%0'"); in luaV_mod()
409 void luaV_arith (lua_State *L, StkId ra, const TValue *rb, in luaV_arith() argument
421 res = luaV_div(L, nvalue(b), nvalue(c)); in luaV_arith()
423 res = luaV_mod(L, nvalue(b), nvalue(c)); in luaV_arith()
429 else if (!call_binTM(L, rb, rc, ra, op)) in luaV_arith()
430 luaG_aritherror(L, rb, rc); in luaV_arith()
461 static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, in pushclosure() argument
466 Closure *ncl = luaF_newLclosure(L, nup); in pushclosure()
468 setclLvalue(L, ra, ncl); /* anchor new closure in stack */ in pushclosure()
471 ncl->l.upvals[i] = luaF_findupval(L, base + uv[i].idx); in pushclosure()
475 luaC_barrierproto(L, p, ncl); in pushclosure()
483 void luaV_finishOp (lua_State *L) { in luaV_finishOp() argument
484 CallInfo *ci = L->ci; in luaV_finishOp()
492 setobjs2s(L, base + GETARG_A(inst), --L->top); in luaV_finishOp()
496 int res = !l_isfalse(L->top - 1); in luaV_finishOp()
497 L->top--; in luaV_finishOp()
501 ttisnil(luaT_gettmbyobj(L, base + GETARG_B(inst), TM_LE))) in luaV_finishOp()
509 StkId top = L->top - 1; /* top when 'call_binTM' was called */ in luaV_finishOp()
512 setobj2s(L, top - 2, top); /* put TM result in proper position */ in luaV_finishOp()
514 L->top = top - 1; /* top is one after last element (at top-2) */ in luaV_finishOp()
515 luaV_concat(L, total); /* concat them (may yield again) */ in luaV_finishOp()
518 setobj2s(L, ci->u.l.base + GETARG_A(inst), L->top - 1); in luaV_finishOp()
519 L->top = ci->top; /* restore top */ in luaV_finishOp()
524 L->top = ci->top; /* correct top */ in luaV_finishOp()
529 L->top = ci->top; /* adjust results */ in luaV_finishOp()
545 #define luai_runtimecheck(L, c) /* void */ argument
564 if (a > 0) luaF_close(L, ci->u.l.base + a - 1); \
573 #define checkGC(L,c) \ argument
574 Protect( luaC_condGC(L,{L->top = (c); /* limit of live values */ \
575 luaC_step(L); \
576 L->top = ci->top;}) /* restore top */ \
577 luai_threadyield(L); )
585 setnvalue(ra, op(L, nb, nc)); \
587 else { Protect(luaV_arith(L, ra, rb, rc, tm)); } }
594 void luaV_execute (lua_State *L) { in luaV_execute() argument
595 CallInfo *ci = L->ci; in luaV_execute()
600 lua_assert(ci == L->ci); in luaV_execute()
608 if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && in luaV_execute()
609 (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { in luaV_execute()
610 Protect(traceexec(L)); in luaV_execute()
615 lua_assert(base <= L->top && L->top < L->stack + L->stacksize); in luaV_execute()
618 setobjs2s(L, ra, RB(i)); in luaV_execute()
622 setobj2s(L, ra, rb); in luaV_execute()
628 setobj2s(L, ra, rb); in luaV_execute()
642 setobj2s(L, ra, cl->upvals[b]->v); in luaV_execute()
646 Protect(luaV_gettable(L, cl->upvals[b]->v, RKC(i), ra)); in luaV_execute()
649 Protect(luaV_gettable(L, RB(i), RKC(i), ra)); in luaV_execute()
653 Protect(luaV_settable(L, cl->upvals[a]->v, RKB(i), RKC(i))); in luaV_execute()
657 setobj(L, uv->v, ra); in luaV_execute()
658 luaC_barrier(L, uv, ra); in luaV_execute()
661 Protect(luaV_settable(L, ra, RKB(i), RKC(i))); in luaV_execute()
666 Table *t = luaH_new(L); in luaV_execute()
667 sethvalue(L, ra, t); in luaV_execute()
669 luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c)); in luaV_execute()
670 checkGC(L, ra + 1); in luaV_execute()
674 setobjs2s(L, ra+1, rb); in luaV_execute()
675 Protect(luaV_gettable(L, rb, RKC(i), ra)); in luaV_execute()
702 setnvalue(ra, luai_numunm(L, nb)); in luaV_execute()
705 Protect(luaV_arith(L, ra, rb, rb, TM_UNM)); in luaV_execute()
714 Protect(luaV_objlen(L, ra, RB(i))); in luaV_execute()
720 L->top = base + c + 1; /* mark the end of concat operands */ in luaV_execute()
721 Protect(luaV_concat(L, c - b + 1)); in luaV_execute()
724 setobjs2s(L, ra, rb); in luaV_execute()
725 checkGC(L, (ra >= rb ? ra + 1 : rb)); in luaV_execute()
726 L->top = ci->top; /* restore top */ in luaV_execute()
735 if (cast_int(equalobj(L, rb, rc)) != GETARG_A(i)) in luaV_execute()
743 if (luaV_lessthan(L, RKB(i), RKC(i)) != GETARG_A(i)) in luaV_execute()
751 if (luaV_lessequal(L, RKB(i), RKC(i)) != GETARG_A(i)) in luaV_execute()
768 setobjs2s(L, ra, rb); in luaV_execute()
775 if (b != 0) L->top = ra+b; /* else previous instruction set top */ in luaV_execute()
776 if (luaD_precall(L, ra, nresults)) { /* C function? */ in luaV_execute()
777 if (nresults >= 0) L->top = ci->top; /* adjust results */ in luaV_execute()
781 ci = L->ci; in luaV_execute()
788 if (b != 0) L->top = ra+b; /* else previous instruction set top */ in luaV_execute()
790 if (luaD_precall(L, ra, LUA_MULTRET)) /* C function? */ in luaV_execute()
794 CallInfo *nci = L->ci; /* called frame */ in luaV_execute()
802 if (cl->p->sizep > 0) luaF_close(L, oci->u.l.base); in luaV_execute()
805 setobjs2s(L, ofunc + aux, nfunc + aux); in luaV_execute()
807 oci->top = L->top = ofunc + (L->top - nfunc); /* correct top */ in luaV_execute()
810 ci = L->ci = oci; /* remove new frame */ in luaV_execute()
811 lua_assert(L->top == oci->u.l.base + getproto(ofunc)->maxstacksize); in luaV_execute()
817 if (b != 0) L->top = ra+b-1; in luaV_execute()
818 if (cl->p->sizep > 0) luaF_close(L, base); in luaV_execute()
819 b = luaD_poscall(L, ra); in luaV_execute()
823 ci = L->ci; in luaV_execute()
824 if (b) L->top = ci->top; in luaV_execute()
832 lua_Number idx = luai_numadd(L, nvalue(ra), step); /* increment index */ in luaV_execute()
834 if (luai_numlt(L, 0, step) ? luai_numle(L, idx, limit) in luaV_execute()
835 : luai_numle(L, limit, idx)) { in luaV_execute()
846 luaG_runerror(L, LUA_QL("for") " initial value must be a number"); in luaV_execute()
848 luaG_runerror(L, LUA_QL("for") " limit must be a number"); in luaV_execute()
850 luaG_runerror(L, LUA_QL("for") " step must be a number"); in luaV_execute()
851 setnvalue(ra, luai_numsub(L, nvalue(ra), nvalue(pstep))); in luaV_execute()
856 setobjs2s(L, cb+2, ra+2); in luaV_execute()
857 setobjs2s(L, cb+1, ra+1); in luaV_execute()
858 setobjs2s(L, cb, ra); in luaV_execute()
859 L->top = cb + 3; /* func. + 2 args (state and index) */ in luaV_execute()
860 Protect(luaD_call(L, cb, GETARG_C(i), 1)); in luaV_execute()
861 L->top = ci->top; in luaV_execute()
870 setobjs2s(L, ra, ra + 1); /* save control variable */ in luaV_execute()
879 if (n == 0) n = cast_int(L->top - ra) - 1; in luaV_execute()
884 luai_runtimecheck(L, ttistable(ra)); in luaV_execute()
888 luaH_resizearray(L, h, last); /* pre-allocate it at once */ in luaV_execute()
891 luaH_setint(L, h, last--, val); in luaV_execute()
892 luaC_barrierback(L, obj2gco(h), val); in luaV_execute()
894 L->top = ci->top; /* correct top (in case of previous open call) */ in luaV_execute()
900 pushclosure(L, p, cl->upvals, base, ra); /* create a new one */ in luaV_execute()
902 setclLvalue(L, ra, ncl); /* push cashed closure */ in luaV_execute()
903 checkGC(L, ra + 1); in luaV_execute()
911 Protect(luaD_checkstack(L, n)); in luaV_execute()
913 L->top = ra + n; in luaV_execute()
917 setobjs2s(L, ra + j, base - n + j); in luaV_execute()