• Home
  • Raw
  • Download

Lines Matching +full:- +full:l

43 ** Error-recovery functions
58 #define LUAI_THROW(L,c) throw(c) argument
59 #define LUAI_TRY(L,c,a) \ argument
60 try { a } catch(...) { if ((c)->status == 0) (c)->status = -1; }
66 #define LUAI_THROW(L,c) _longjmp((c)->b, 1) argument
67 #define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } argument
73 #define LUAI_THROW(L,c) longjmp((c)->b, 1) argument
74 #define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } argument
91 void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { in luaD_seterrorobj() argument
94 setsvalue2s(L, oldtop, G(L)->memerrmsg); /* reuse preregistered msg. */ in luaD_seterrorobj()
98 setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); in luaD_seterrorobj()
106 setobjs2s(L, oldtop, L->top - 1); /* error message on current top */ in luaD_seterrorobj()
110 L->top = oldtop + 1; in luaD_seterrorobj()
114 l_noret luaD_throw (lua_State *L, int errcode) { in luaD_throw() argument
115 if (L->errorJmp) { /* thread has an error handler? */ in luaD_throw()
116 L->errorJmp->status = errcode; /* set status */ in luaD_throw()
117 LUAI_THROW(L, L->errorJmp); /* jump to it */ in luaD_throw()
120 global_State *g = G(L); in luaD_throw()
121 errcode = luaF_close(L, L->stack, errcode); /* close all upvalues */ in luaD_throw()
122 L->status = cast_byte(errcode); /* mark it as dead */ in luaD_throw()
123 if (g->mainthread->errorJmp) { /* main thread has a handler? */ in luaD_throw()
124 setobjs2s(L, g->mainthread->top++, L->top - 1); /* copy error obj. */ in luaD_throw()
125 luaD_throw(g->mainthread, errcode); /* re-throw in main thread */ in luaD_throw()
128 if (g->panic) { /* panic function? */ in luaD_throw()
129 luaD_seterrorobj(L, errcode, L->top); /* assume EXTRA_STACK */ in luaD_throw()
130 if (L->ci->top < L->top) in luaD_throw()
131 L->ci->top = L->top; /* pushing msg. can break this invariant */ in luaD_throw()
132 lua_unlock(L); in luaD_throw()
133 g->panic(L); /* call panic function (last chance to jump out) */ in luaD_throw()
141 int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { in luaD_rawrunprotected() argument
142 global_State *g = G(L); in luaD_rawrunprotected()
143 l_uint32 oldnCcalls = g->Cstacklimit - (L->nCcalls + L->nci); in luaD_rawrunprotected()
146 lj.previous = L->errorJmp; /* chain new error handler */ in luaD_rawrunprotected()
147 L->errorJmp = &lj; in luaD_rawrunprotected()
148 LUAI_TRY(L, &lj, in luaD_rawrunprotected()
149 (*f)(L, ud); in luaD_rawrunprotected()
151 L->errorJmp = lj.previous; /* restore old error handler */ in luaD_rawrunprotected()
152 L->nCcalls = g->Cstacklimit - oldnCcalls - L->nci; in luaD_rawrunprotected()
164 static void correctstack (lua_State *L, StkId oldstack, StkId newstack) { in correctstack() argument
169 L->top = (L->top - oldstack) + newstack; in correctstack()
170 for (up = L->openupval; up != NULL; up = up->u.open.next) in correctstack()
171 up->v = s2v((uplevel(up) - oldstack) + newstack); in correctstack()
172 for (ci = L->ci; ci != NULL; ci = ci->previous) { in correctstack()
173 ci->top = (ci->top - oldstack) + newstack; in correctstack()
174 ci->func = (ci->func - oldstack) + newstack; in correctstack()
176 ci->u.l.trap = 1; /* signal to update 'trap' in 'luaV_execute' */ in correctstack()
185 int luaD_reallocstack (lua_State *L, int newsize, int raiseerror) { in luaD_reallocstack() argument
186 int lim = L->stacksize; in luaD_reallocstack()
187 StkId newstack = luaM_reallocvector(L, L->stack, lim, newsize, StackValue); in luaD_reallocstack()
189 lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK); in luaD_reallocstack()
192 luaM_error(L); in luaD_reallocstack()
197 correctstack(L, L->stack, newstack); in luaD_reallocstack()
198 L->stack = newstack; in luaD_reallocstack()
199 L->stacksize = newsize; in luaD_reallocstack()
200 L->stack_last = L->stack + newsize - EXTRA_STACK; in luaD_reallocstack()
209 int luaD_growstack (lua_State *L, int n, int raiseerror) { in luaD_growstack() argument
210 int size = L->stacksize; in luaD_growstack()
214 luaD_throw(L, LUA_ERRERR); /* error inside message handler */ in luaD_growstack()
218 int needed = cast_int(L->top - L->stack) + n + EXTRA_STACK; in luaD_growstack()
225 luaD_reallocstack(L, ERRORSTACKSIZE, raiseerror); in luaD_growstack()
227 luaG_runerror(L, "stack overflow"); in luaD_growstack()
231 return luaD_reallocstack(L, newsize, raiseerror); in luaD_growstack()
235 static int stackinuse (lua_State *L) { in stackinuse() argument
237 StkId lim = L->top; in stackinuse()
238 for (ci = L->ci; ci != NULL; ci = ci->previous) { in stackinuse()
239 if (lim < ci->top) lim = ci->top; in stackinuse()
241 lua_assert(lim <= L->stack_last); in stackinuse()
242 return cast_int(lim - L->stack) + 1; /* part of stack in use */ in stackinuse()
246 void luaD_shrinkstack (lua_State *L) { in luaD_shrinkstack() argument
247 int inuse = stackinuse(L); in luaD_shrinkstack()
253 if (inuse <= (LUAI_MAXSTACK - EXTRA_STACK) && goodsize < L->stacksize) in luaD_shrinkstack()
254 luaD_reallocstack(L, goodsize, 0); /* ok if that fails */ in luaD_shrinkstack()
256 condmovestack(L,{},{}); /* (change only for debugging) */ in luaD_shrinkstack()
257 luaE_shrinkCI(L); /* shrink CI list */ in luaD_shrinkstack()
261 void luaD_inctop (lua_State *L) { in luaD_inctop() argument
262 luaD_checkstack(L, 1); in luaD_inctop()
263 L->top++; in luaD_inctop()
271 ** called. (Both 'L->hook' and 'L->hookmask', which trigger this
274 void luaD_hook (lua_State *L, int event, int line, in luaD_hook() argument
276 lua_Hook hook = L->hook; in luaD_hook()
277 if (hook && L->allowhook) { /* make sure there is a hook */ in luaD_hook()
279 CallInfo *ci = L->ci; in luaD_hook()
280 ptrdiff_t top = savestack(L, L->top); in luaD_hook()
281 ptrdiff_t ci_top = savestack(L, ci->top); in luaD_hook()
288 ci->u2.transferinfo.ftransfer = ftransfer; in luaD_hook()
289 ci->u2.transferinfo.ntransfer = ntransfer; in luaD_hook()
291 luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ in luaD_hook()
292 if (L->top + LUA_MINSTACK > ci->top) in luaD_hook()
293 ci->top = L->top + LUA_MINSTACK; in luaD_hook()
294 L->allowhook = 0; /* cannot call hooks inside a hook */ in luaD_hook()
295 ci->callstatus |= mask; in luaD_hook()
296 lua_unlock(L); in luaD_hook()
297 (*hook)(L, &ar); in luaD_hook()
298 lua_lock(L); in luaD_hook()
299 lua_assert(!L->allowhook); in luaD_hook()
300 L->allowhook = 1; in luaD_hook()
301 ci->top = restorestack(L, ci_top); in luaD_hook()
302 L->top = restorestack(L, top); in luaD_hook()
303 ci->callstatus &= ~mask; in luaD_hook()
313 void luaD_hookcall (lua_State *L, CallInfo *ci) { in luaD_hookcall() argument
314 int hook = (ci->callstatus & CIST_TAIL) ? LUA_HOOKTAILCALL : LUA_HOOKCALL; in luaD_hookcall()
316 if (!(L->hookmask & LUA_MASKCALL)) /* some other hook? */ in luaD_hookcall()
318 p = clLvalue(s2v(ci->func))->p; in luaD_hookcall()
319 L->top = ci->top; /* prepare top */ in luaD_hookcall()
320 ci->u.l.savedpc++; /* hooks assume 'pc' is already incremented */ in luaD_hookcall()
321 luaD_hook(L, hook, -1, 1, p->numparams); in luaD_hookcall()
322 ci->u.l.savedpc--; /* correct 'pc' */ in luaD_hookcall()
326 static StkId rethook (lua_State *L, CallInfo *ci, StkId firstres, int nres) { in rethook() argument
327 ptrdiff_t oldtop = savestack(L, L->top); /* hook may change top */ in rethook()
330 Proto *p = ci_func(ci)->p; in rethook()
331 if (p->is_vararg) in rethook()
332 delta = ci->u.l.nextraargs + p->numparams + 1; in rethook()
333 if (L->top < ci->top) in rethook()
334 L->top = ci->top; /* correct top to run hook */ in rethook()
336 if (L->hookmask & LUA_MASKRET) { /* is return hook on? */ in rethook()
338 ci->func += delta; /* if vararg, back to virtual 'func' */ in rethook()
339 ftransfer = cast(unsigned short, firstres - ci->func); in rethook()
340 luaD_hook(L, LUA_HOOKRET, -1, ftransfer, nres); /* call it */ in rethook()
341 ci->func -= delta; in rethook()
343 if (isLua(ci = ci->previous)) in rethook()
344 L->oldpc = pcRel(ci->u.l.savedpc, ci_func(ci)->p); /* update 'oldpc' */ in rethook()
345 return restorestack(L, oldtop); in rethook()
354 void luaD_tryfuncTM (lua_State *L, StkId func) { in luaD_tryfuncTM() argument
355 const TValue *tm = luaT_gettmbyobj(L, s2v(func), TM_CALL); in luaD_tryfuncTM()
358 luaG_typeerror(L, s2v(func), "call"); /* nothing to call */ in luaD_tryfuncTM()
359 for (p = L->top; p > func; p--) /* open space for metamethod */ in luaD_tryfuncTM()
360 setobjs2s(L, p, p-1); in luaD_tryfuncTM()
361 L->top++; /* stack space pre-allocated by the caller */ in luaD_tryfuncTM()
362 setobj2s(L, func, tm); /* metamethod is the new function to be called */ in luaD_tryfuncTM()
372 static void moveresults (lua_State *L, StkId res, int nres, int wanted) { in moveresults() argument
377 L->top = res; in moveresults()
383 setobjs2s(L, res, L->top - nres); /* move it to proper place */ in moveresults()
384 L->top = res + 1; in moveresults()
389 default: /* multiple results (or to-be-closed variables) */ in moveresults()
390 if (hastocloseCfunc(wanted)) { /* to-be-closed variables? */ in moveresults()
391 ptrdiff_t savedres = savestack(L, res); in moveresults()
392 luaF_close(L, res, LUA_OK); /* may change the stack */ in moveresults()
393 res = restorestack(L, savedres); in moveresults()
400 firstresult = L->top - nres; /* index of first result */ in moveresults()
403 setobjs2s(L, res + i, firstresult + i); in moveresults()
406 L->top = res + wanted; /* top points after the last result */ in moveresults()
414 void luaD_poscall (lua_State *L, CallInfo *ci, int nres) { in luaD_poscall() argument
415 if (L->hookmask) in luaD_poscall()
416 L->top = rethook(L, ci, L->top - nres, nres); in luaD_poscall()
417 L->ci = ci->previous; /* back to caller */ in luaD_poscall()
419 moveresults(L, ci->func, nres, ci->nresults); in luaD_poscall()
424 #define next_ci(L) (L->ci->next ? L->ci->next : luaE_extendCI(L)) argument
432 void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int narg1) { in luaD_pretailcall() argument
433 Proto *p = clLvalue(s2v(func))->p; in luaD_pretailcall()
434 int fsize = p->maxstacksize; /* frame size */ in luaD_pretailcall()
435 int nfixparams = p->numparams; in luaD_pretailcall()
438 setobjs2s(L, ci->func + i, func + i); in luaD_pretailcall()
439 checkstackGC(L, fsize); in luaD_pretailcall()
440 func = ci->func; /* moved-down function */ in luaD_pretailcall()
443 ci->top = func + 1 + fsize; /* top for new function */ in luaD_pretailcall()
444 lua_assert(ci->top <= L->stack_last); in luaD_pretailcall()
445 ci->u.l.savedpc = p->code; /* starting point */ in luaD_pretailcall()
446 ci->callstatus |= CIST_TAIL; in luaD_pretailcall()
447 L->top = func + narg1; /* set top */ in luaD_pretailcall()
457 void luaD_call (lua_State *L, StkId func, int nresults) { in luaD_call() argument
462 f = clCvalue(s2v(func))->f; in luaD_call()
469 checkstackGCp(L, LUA_MINSTACK, func); /* ensure minimum stack size */ in luaD_call()
470 L->ci = ci = next_ci(L); in luaD_call()
471 ci->nresults = nresults; in luaD_call()
472 ci->callstatus = CIST_C; in luaD_call()
473 ci->top = L->top + LUA_MINSTACK; in luaD_call()
474 ci->func = func; in luaD_call()
475 lua_assert(ci->top <= L->stack_last); in luaD_call()
476 if (L->hookmask & LUA_MASKCALL) { in luaD_call()
477 int narg = cast_int(L->top - func) - 1; in luaD_call()
478 luaD_hook(L, LUA_HOOKCALL, -1, 1, narg); in luaD_call()
480 lua_unlock(L); in luaD_call()
481 n = (*f)(L); /* do the actual call */ in luaD_call()
482 lua_lock(L); in luaD_call()
483 api_checknelems(L, n); in luaD_call()
484 luaD_poscall(L, ci, n); in luaD_call()
489 Proto *p = clLvalue(s2v(func))->p; in luaD_call()
490 int narg = cast_int(L->top - func) - 1; /* number of real arguments */ in luaD_call()
491 int nfixparams = p->numparams; in luaD_call()
492 int fsize = p->maxstacksize; /* frame size */ in luaD_call()
493 checkstackGCp(L, fsize, func); in luaD_call()
494 L->ci = ci = next_ci(L); in luaD_call()
495 ci->nresults = nresults; in luaD_call()
496 ci->u.l.savedpc = p->code; /* starting point */ in luaD_call()
497 ci->callstatus = 0; in luaD_call()
498 ci->top = func + 1 + fsize; in luaD_call()
499 ci->func = func; in luaD_call()
500 L->ci = ci; in luaD_call()
502 setnilvalue(s2v(L->top++)); /* complete missing arguments */ in luaD_call()
503 lua_assert(ci->top <= L->stack_last); in luaD_call()
504 luaV_execute(L, ci); /* run the function */ in luaD_call()
508 checkstackGCp(L, 1, func); /* space for metamethod */ in luaD_call()
509 luaD_tryfuncTM(L, func); /* try to get '__call' metamethod */ in luaD_call()
519 void luaD_callnoyield (lua_State *L, StkId func, int nResults) { in luaD_callnoyield() argument
520 incXCcalls(L); in luaD_callnoyield()
521 if (getCcalls(L) <= CSTACKERR) { /* possible C stack overflow? */ in luaD_callnoyield()
522 luaE_exitCcall(L); /* to compensate decrement in next call */ in luaD_callnoyield()
523 luaE_enterCcall(L); /* check properly */ in luaD_callnoyield()
525 luaD_call(L, func, nResults); in luaD_callnoyield()
526 decXCcalls(L); in luaD_callnoyield()
534 static void finishCcall (lua_State *L, int status) { in finishCcall() argument
535 CallInfo *ci = L->ci; in finishCcall()
538 lua_assert(ci->u.c.k != NULL && yieldable(L)); in finishCcall()
540 lua_assert((ci->callstatus & CIST_YPCALL) || status == LUA_YIELD); in finishCcall()
541 if (ci->callstatus & CIST_YPCALL) { /* was inside a pcall? */ in finishCcall()
542 ci->callstatus &= ~CIST_YPCALL; /* continuation is also inside it */ in finishCcall()
543 L->errfunc = ci->u.c.old_errfunc; /* with the same error function */ in finishCcall()
547 adjustresults(L, ci->nresults); in finishCcall()
548 lua_unlock(L); in finishCcall()
549 n = (*ci->u.c.k)(L, status, ci->u.c.ctx); /* call continuation function */ in finishCcall()
550 lua_lock(L); in finishCcall()
551 api_checknelems(L, n); in finishCcall()
552 luaD_poscall(L, ci, n); /* finish 'luaD_call' */ in finishCcall()
559 ** interruption long-jumps out of the loop). If the coroutine is
564 static void unroll (lua_State *L, void *ud) { in unroll() argument
567 finishCcall(L, *(int *)ud); /* finish 'lua_pcallk' callee */ in unroll()
568 while ((ci = L->ci) != &L->base_ci) { /* something in the stack */ in unroll()
570 finishCcall(L, LUA_YIELD); /* complete its execution */ in unroll()
572 luaV_finishOp(L); /* finish interrupted instruction */ in unroll()
573 luaV_execute(L, ci); /* execute down to higher C 'boundary' */ in unroll()
583 static CallInfo *findpcall (lua_State *L) { in findpcall() argument
585 for (ci = L->ci; ci != NULL; ci = ci->previous) { /* search for a pcall */ in findpcall()
586 if (ci->callstatus & CIST_YPCALL) in findpcall()
598 static int recover (lua_State *L, int status) { in recover() argument
600 CallInfo *ci = findpcall(L); in recover()
603 oldtop = restorestack(L, ci->u2.funcidx); in recover()
604 luaF_close(L, oldtop, status); /* may change the stack */ in recover()
605 oldtop = restorestack(L, ci->u2.funcidx); in recover()
606 luaD_seterrorobj(L, status, oldtop); in recover()
607 L->ci = ci; in recover()
608 L->allowhook = getoah(ci->callstatus); /* restore original 'allowhook' */ in recover()
609 luaD_shrinkstack(L); in recover()
610 L->errfunc = ci->u.c.old_errfunc; in recover()
620 static int resume_error (lua_State *L, const char *msg, int narg) { in resume_error() argument
621 L->top -= narg; /* remove args from the stack */ in resume_error()
622 setsvalue2s(L, L->top, luaS_new(L, msg)); /* push error message */ in resume_error()
623 api_incr_top(L); in resume_error()
624 lua_unlock(L); in resume_error()
633 ** function), plus erroneous cases: non-suspended coroutine or dead
636 static void resume (lua_State *L, void *ud) { in resume() argument
638 StkId firstArg = L->top - n; /* first argument */ in resume()
639 CallInfo *ci = L->ci; in resume()
640 if (L->status == LUA_OK) { /* starting a coroutine? */ in resume()
641 luaD_call(L, firstArg - 1, LUA_MULTRET); in resume()
644 lua_assert(L->status == LUA_YIELD); in resume()
645 L->status = LUA_OK; /* mark that it is running (again) */ in resume()
647 luaV_execute(L, ci); /* just continue running Lua code */ in resume()
649 if (ci->u.c.k != NULL) { /* does it have a continuation function? */ in resume()
650 lua_unlock(L); in resume()
651 n = (*ci->u.c.k)(L, LUA_YIELD, ci->u.c.ctx); /* call continuation */ in resume()
652 lua_lock(L); in resume()
653 api_checknelems(L, n); in resume()
655 luaD_poscall(L, ci, n); /* finish 'luaD_call' */ in resume()
657 unroll(L, NULL); /* run continuation */ in resume()
661 LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs, in lua_resume() argument
664 lua_lock(L); in lua_resume()
665 if (L->status == LUA_OK) { /* may be starting a coroutine */ in lua_resume()
666 if (L->ci != &L->base_ci) /* not in base level? */ in lua_resume()
667 return resume_error(L, "cannot resume non-suspended coroutine", nargs); in lua_resume()
668 else if (L->top - (L->ci->func + 1) == nargs) /* no function? */ in lua_resume()
669 return resume_error(L, "cannot resume dead coroutine", nargs); in lua_resume()
671 else if (L->status != LUA_YIELD) /* ended with errors? */ in lua_resume()
672 return resume_error(L, "cannot resume dead coroutine", nargs); in lua_resume()
674 L->nCcalls = CSTACKTHREAD; in lua_resume()
676 L->nCcalls = getCcalls(from) - L->nci - CSTACKCF; in lua_resume()
677 if (L->nCcalls <= CSTACKERR) in lua_resume()
678 return resume_error(L, "C stack overflow", nargs); in lua_resume()
679 luai_userstateresume(L, nargs); in lua_resume()
680 api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs); in lua_resume()
681 status = luaD_rawrunprotected(L, resume, &nargs); in lua_resume()
683 while (errorstatus(status) && recover(L, status)) { in lua_resume()
685 status = luaD_rawrunprotected(L, unroll, &status); in lua_resume()
688 lua_assert(status == L->status); /* normal end or yield */ in lua_resume()
690 L->status = cast_byte(status); /* mark thread as 'dead' */ in lua_resume()
691 luaD_seterrorobj(L, status, L->top); /* push error message */ in lua_resume()
692 L->ci->top = L->top; in lua_resume()
694 *nresults = (status == LUA_YIELD) ? L->ci->u2.nyield in lua_resume()
695 : cast_int(L->top - (L->ci->func + 1)); in lua_resume()
696 lua_unlock(L); in lua_resume()
701 LUA_API int lua_isyieldable (lua_State *L) { in lua_isyieldable() argument
702 return yieldable(L); in lua_isyieldable()
706 LUA_API int lua_yieldk (lua_State *L, int nresults, lua_KContext ctx, in lua_yieldk() argument
709 luai_userstateyield(L, nresults); in lua_yieldk()
710 lua_lock(L); in lua_yieldk()
711 ci = L->ci; in lua_yieldk()
712 api_checknelems(L, nresults); in lua_yieldk()
713 if (unlikely(!yieldable(L))) { in lua_yieldk()
714 if (L != G(L)->mainthread) in lua_yieldk()
715 luaG_runerror(L, "attempt to yield across a C-call boundary"); in lua_yieldk()
717 luaG_runerror(L, "attempt to yield from outside a coroutine"); in lua_yieldk()
719 L->status = LUA_YIELD; in lua_yieldk()
722 api_check(L, k == NULL, "hooks cannot continue after yielding"); in lua_yieldk()
723 ci->u2.nyield = 0; /* no results */ in lua_yieldk()
726 if ((ci->u.c.k = k) != NULL) /* is there a continuation? */ in lua_yieldk()
727 ci->u.c.ctx = ctx; /* save context */ in lua_yieldk()
728 ci->u2.nyield = nresults; /* save number of results */ in lua_yieldk()
729 luaD_throw(L, LUA_YIELD); in lua_yieldk()
731 lua_assert(ci->callstatus & CIST_HOOKED); /* must be inside a hook */ in lua_yieldk()
732 lua_unlock(L); in lua_yieldk()
742 int luaD_pcall (lua_State *L, Pfunc func, void *u, in luaD_pcall() argument
745 CallInfo *old_ci = L->ci; in luaD_pcall()
746 lu_byte old_allowhooks = L->allowhook; in luaD_pcall()
747 ptrdiff_t old_errfunc = L->errfunc; in luaD_pcall()
748 L->errfunc = ef; in luaD_pcall()
749 status = luaD_rawrunprotected(L, func, u); in luaD_pcall()
751 StkId oldtop = restorestack(L, old_top); in luaD_pcall()
752 L->ci = old_ci; in luaD_pcall()
753 L->allowhook = old_allowhooks; in luaD_pcall()
754 status = luaF_close(L, oldtop, status); in luaD_pcall()
755 oldtop = restorestack(L, old_top); /* previous call may change stack */ in luaD_pcall()
756 luaD_seterrorobj(L, status, oldtop); in luaD_pcall()
757 luaD_shrinkstack(L); in luaD_pcall()
759 L->errfunc = old_errfunc; in luaD_pcall()
777 static void checkmode (lua_State *L, const char *mode, const char *x) { in checkmode() argument
779 luaO_pushfstring(L, in checkmode()
781 luaD_throw(L, LUA_ERRSYNTAX); in checkmode()
786 static void f_parser (lua_State *L, void *ud) { in f_parser() argument
789 int c = zgetc(p->z); /* read first character */ in f_parser()
791 checkmode(L, p->mode, "binary"); in f_parser()
792 cl = luaU_undump(L, p->z, p->name); in f_parser()
795 checkmode(L, p->mode, "text"); in f_parser()
796 cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c); in f_parser()
798 lua_assert(cl->nupvalues == cl->p->sizeupvalues); in f_parser()
799 luaF_initupvals(L, cl); in f_parser()
803 int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, in luaD_protectedparser() argument
807 incnny(L); /* cannot yield during parsing */ in luaD_protectedparser()
812 luaZ_initbuffer(L, &p.buff); in luaD_protectedparser()
813 status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); in luaD_protectedparser()
814 luaZ_freebuffer(L, &p.buff); in luaD_protectedparser()
815 luaM_freearray(L, p.dyd.actvar.arr, p.dyd.actvar.size); in luaD_protectedparser()
816 luaM_freearray(L, p.dyd.gt.arr, p.dyd.gt.size); in luaD_protectedparser()
817 luaM_freearray(L, p.dyd.label.arr, p.dyd.label.size); in luaD_protectedparser()
818 decnny(L); in luaD_protectedparser()