ldo.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. /*
  2. ** $Id: ldo.c,v 2.51 2008/11/06 12:43:51 roberto Exp roberto $
  3. ** Stack and Call structure of Lua
  4. ** See Copyright Notice in lua.h
  5. */
  6. #include <setjmp.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #define ldo_c
  10. #define LUA_CORE
  11. #include "lua.h"
  12. #include "ldebug.h"
  13. #include "ldo.h"
  14. #include "lfunc.h"
  15. #include "lgc.h"
  16. #include "lmem.h"
  17. #include "lobject.h"
  18. #include "lopcodes.h"
  19. #include "lparser.h"
  20. #include "lstate.h"
  21. #include "lstring.h"
  22. #include "ltable.h"
  23. #include "ltm.h"
  24. #include "lundump.h"
  25. #include "lvm.h"
  26. #include "lzio.h"
  27. /*
  28. ** {======================================================
  29. ** Error-recovery functions
  30. ** =======================================================
  31. */
  32. /* chain list of long jump buffers */
  33. struct lua_longjmp {
  34. struct lua_longjmp *previous;
  35. luai_jmpbuf b;
  36. volatile int status; /* error code */
  37. };
  38. void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) {
  39. switch (errcode) {
  40. case LUA_ERRMEM: {
  41. setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG));
  42. break;
  43. }
  44. case LUA_ERRERR: {
  45. setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling"));
  46. break;
  47. }
  48. case LUA_ERRSYNTAX:
  49. case LUA_ERRRUN: {
  50. setobjs2s(L, oldtop, L->top - 1); /* error message on current top */
  51. break;
  52. }
  53. }
  54. L->top = oldtop + 1;
  55. }
  56. static void restore_stack_limit (lua_State *L) {
  57. lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
  58. if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */
  59. int inuse = cast_int(L->ci - L->base_ci);
  60. if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */
  61. luaD_reallocCI(L, LUAI_MAXCALLS);
  62. }
  63. }
  64. void luaD_throw (lua_State *L, int errcode) {
  65. if (L->errorJmp) {
  66. L->errorJmp->status = errcode;
  67. LUAI_THROW(L, L->errorJmp);
  68. }
  69. else {
  70. L->status = cast_byte(errcode);
  71. if (G(L)->panic) {
  72. lua_unlock(L);
  73. G(L)->panic(L);
  74. }
  75. exit(EXIT_FAILURE);
  76. }
  77. }
  78. int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
  79. unsigned short oldnCcalls = G(L)->nCcalls;
  80. struct lua_longjmp lj;
  81. lj.status = LUA_OK;
  82. lj.previous = L->errorJmp; /* chain new error handler */
  83. L->errorJmp = &lj;
  84. LUAI_TRY(L, &lj,
  85. (*f)(L, ud);
  86. );
  87. L->errorJmp = lj.previous; /* restore old error handler */
  88. G(L)->nCcalls = oldnCcalls;
  89. return lj.status;
  90. }
  91. /* }====================================================== */
  92. static void correctstack (lua_State *L, TValue *oldstack) {
  93. CallInfo *ci;
  94. GCObject *up;
  95. L->top = (L->top - oldstack) + L->stack;
  96. for (up = L->openupval; up != NULL; up = up->gch.next)
  97. gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack;
  98. for (ci = L->base_ci; ci <= L->ci; ci++) {
  99. ci->top = (ci->top - oldstack) + L->stack;
  100. ci->base = (ci->base - oldstack) + L->stack;
  101. ci->func = (ci->func - oldstack) + L->stack;
  102. }
  103. L->base = (L->base - oldstack) + L->stack;
  104. }
  105. void luaD_reallocstack (lua_State *L, int newsize) {
  106. TValue *oldstack = L->stack;
  107. int realsize = newsize + 1 + EXTRA_STACK;
  108. lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
  109. luaM_reallocvector(L, L->stack, L->stacksize, realsize, TValue);
  110. L->stacksize = realsize;
  111. L->stack_last = L->stack+newsize;
  112. correctstack(L, oldstack);
  113. }
  114. void luaD_reallocCI (lua_State *L, int newsize) {
  115. CallInfo *oldci = L->base_ci;
  116. luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo);
  117. L->size_ci = newsize;
  118. L->ci = (L->ci - oldci) + L->base_ci;
  119. L->end_ci = L->base_ci + L->size_ci - 1;
  120. }
  121. void luaD_growstack (lua_State *L, int n) {
  122. if (n <= L->stacksize) /* double size is enough? */
  123. luaD_reallocstack(L, 2*L->stacksize);
  124. else
  125. luaD_reallocstack(L, L->stacksize + n);
  126. }
  127. static CallInfo *growCI (lua_State *L) {
  128. if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */
  129. luaD_throw(L, LUA_ERRERR);
  130. else {
  131. luaD_reallocCI(L, 2*L->size_ci);
  132. if (L->size_ci > LUAI_MAXCALLS)
  133. luaG_runerror(L, "stack overflow");
  134. }
  135. return ++L->ci;
  136. }
  137. void luaD_callhook (lua_State *L, int event, int line) {
  138. lua_Hook hook = L->hook;
  139. if (hook && L->allowhook) {
  140. ptrdiff_t top = savestack(L, L->top);
  141. ptrdiff_t ci_top = savestack(L, L->ci->top);
  142. lua_Debug ar;
  143. ar.event = event;
  144. ar.currentline = line;
  145. if (event == LUA_HOOKTAILRET)
  146. ar.i_ci = 0; /* tail call; no debug information about it */
  147. else
  148. ar.i_ci = cast_int(L->ci - L->base_ci);
  149. luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
  150. L->ci->top = L->top + LUA_MINSTACK;
  151. lua_assert(L->ci->top <= L->stack_last);
  152. L->allowhook = 0; /* cannot call hooks inside a hook */
  153. L->ci->callstatus |= CIST_HOOKED;
  154. lua_unlock(L);
  155. (*hook)(L, &ar);
  156. lua_lock(L);
  157. lua_assert(!L->allowhook);
  158. L->allowhook = 1;
  159. L->ci->top = restorestack(L, ci_top);
  160. L->top = restorestack(L, top);
  161. L->ci->callstatus &= ~CIST_HOOKED;
  162. }
  163. }
  164. static StkId adjust_varargs (lua_State *L, Proto *p, int actual) {
  165. int i;
  166. int nfixargs = p->numparams;
  167. Table *htab = NULL;
  168. StkId base, fixed;
  169. for (; actual < nfixargs; ++actual)
  170. setnilvalue(L->top++);
  171. #if defined(LUA_COMPAT_VARARG)
  172. if (p->is_vararg & VARARG_NEEDSARG) { /* compat. with old-style vararg? */
  173. int nvar = actual - nfixargs; /* number of extra arguments */
  174. lua_assert(p->is_vararg & VARARG_HASARG);
  175. luaC_checkGC(L);
  176. htab = luaH_new(L); /* create `arg' table */
  177. sethvalue(L, L->top++, htab);
  178. for (i=0; i<nvar; i++) /* put extra arguments into `arg' table */
  179. setobj2n(L, luaH_setnum(L, htab, i+1), L->top - nvar + i - 1);
  180. /* store counter in field `n' */
  181. setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar));
  182. L->top--;
  183. }
  184. #endif
  185. /* move fixed parameters to final position */
  186. fixed = L->top - actual; /* first fixed argument */
  187. base = L->top; /* final position of first argument */
  188. for (i=0; i<nfixargs; i++) {
  189. setobjs2s(L, L->top++, fixed+i);
  190. setnilvalue(fixed+i);
  191. }
  192. /* add `arg' parameter */
  193. if (htab) {
  194. sethvalue(L, L->top++, htab);
  195. lua_assert(iswhite(obj2gco(htab)));
  196. }
  197. return base;
  198. }
  199. static StkId tryfuncTM (lua_State *L, StkId func) {
  200. const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL);
  201. StkId p;
  202. ptrdiff_t funcr = savestack(L, func);
  203. if (!ttisfunction(tm))
  204. luaG_typeerror(L, func, "call");
  205. /* Open a hole inside the stack at `func' */
  206. for (p = L->top; p > func; p--) setobjs2s(L, p, p-1);
  207. incr_top(L);
  208. func = restorestack(L, funcr); /* previous call may change stack */
  209. setobj2s(L, func, tm); /* tag method is the new function to be called */
  210. return func;
  211. }
  212. #define inc_ci(L) \
  213. ((L->ci == L->end_ci) ? growCI(L) : \
  214. (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci))
  215. /*
  216. ** returns true if function has been executed (C function)
  217. */
  218. int luaD_precall (lua_State *L, StkId func, int nresults) {
  219. LClosure *cl;
  220. ptrdiff_t funcr;
  221. if (!ttisfunction(func)) /* `func' is not a function? */
  222. func = tryfuncTM(L, func); /* check the `function' tag method */
  223. funcr = savestack(L, func);
  224. cl = &clvalue(func)->l;
  225. L->ci->savedpc = L->savedpc;
  226. if (!cl->isC) { /* Lua function? prepare its call */
  227. CallInfo *ci;
  228. StkId st, base;
  229. Proto *p = cl->p;
  230. luaD_checkstack(L, p->maxstacksize);
  231. func = restorestack(L, funcr);
  232. if (!p->is_vararg) /* no varargs? */
  233. base = func + 1;
  234. else { /* vararg function */
  235. int nargs = cast_int(L->top - func) - 1;
  236. base = adjust_varargs(L, p, nargs);
  237. func = restorestack(L, funcr); /* previous call may change the stack */
  238. }
  239. ci = inc_ci(L); /* now `enter' new function */
  240. ci->func = func;
  241. L->base = ci->base = base;
  242. ci->top = L->base + p->maxstacksize;
  243. lua_assert(ci->top <= L->stack_last);
  244. L->savedpc = p->code; /* starting point */
  245. ci->tailcalls = 0;
  246. ci->callstatus = CIST_LUA;
  247. ci->nresults = nresults;
  248. for (st = L->top; st < ci->top; st++)
  249. setnilvalue(st);
  250. L->top = ci->top;
  251. if (L->hookmask & LUA_MASKCALL) {
  252. L->savedpc++; /* hooks assume 'pc' is already incremented */
  253. luaD_callhook(L, LUA_HOOKCALL, -1);
  254. L->savedpc--; /* correct 'pc' */
  255. }
  256. return 0;
  257. }
  258. else { /* if is a C function, call it */
  259. CallInfo *ci;
  260. int n;
  261. luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
  262. ci = inc_ci(L); /* now `enter' new function */
  263. ci->func = restorestack(L, funcr);
  264. L->base = ci->base = ci->func + 1;
  265. ci->top = L->top + LUA_MINSTACK;
  266. lua_assert(ci->top <= L->stack_last);
  267. ci->nresults = nresults;
  268. ci->callstatus = 0;
  269. if (L->hookmask & LUA_MASKCALL)
  270. luaD_callhook(L, LUA_HOOKCALL, -1);
  271. lua_unlock(L);
  272. n = (*curr_func(L)->c.f)(L); /* do the actual call */
  273. lua_lock(L);
  274. luaD_poscall(L, L->top - n);
  275. return 1;
  276. }
  277. }
  278. static StkId callrethooks (lua_State *L, StkId firstResult) {
  279. ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */
  280. luaD_callhook(L, LUA_HOOKRET, -1);
  281. if (isLua(L->ci)) { /* Lua function? */
  282. while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */
  283. luaD_callhook(L, LUA_HOOKTAILRET, -1);
  284. }
  285. return restorestack(L, fr);
  286. }
  287. int luaD_poscall (lua_State *L, StkId firstResult) {
  288. StkId res;
  289. int wanted, i;
  290. CallInfo *ci;
  291. if (L->hookmask & (LUA_MASKRET | LUA_MASKLINE)) {
  292. if (L->hookmask & LUA_MASKRET)
  293. firstResult = callrethooks(L, firstResult);
  294. L->oldpc = (L->ci - 1)->savedpc; /* set 'oldpc' for returning function */
  295. }
  296. ci = L->ci--;
  297. res = ci->func; /* res == final position of 1st result */
  298. wanted = ci->nresults;
  299. L->base = (ci - 1)->base; /* restore base */
  300. L->savedpc = (ci - 1)->savedpc; /* restore savedpc */
  301. /* move results to correct place */
  302. for (i = wanted; i != 0 && firstResult < L->top; i--)
  303. setobjs2s(L, res++, firstResult++);
  304. while (i-- > 0)
  305. setnilvalue(res++);
  306. L->top = res;
  307. return (wanted - LUA_MULTRET); /* 0 iff wanted == LUA_MULTRET */
  308. }
  309. /*
  310. ** Call a function (C or Lua). The function to be called is at *func.
  311. ** The arguments are on the stack, right after the function.
  312. ** When returns, all the results are on the stack, starting at the original
  313. ** function position.
  314. */
  315. void luaD_call (lua_State *L, StkId func, int nResults) {
  316. global_State *g = G(L);
  317. if (++g->nCcalls >= LUAI_MAXCCALLS) {
  318. if (g->nCcalls == LUAI_MAXCCALLS)
  319. luaG_runerror(L, "C stack overflow");
  320. else if (g->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3)))
  321. luaD_throw(L, LUA_ERRERR); /* error while handing stack error */
  322. }
  323. if (!luaD_precall(L, func, nResults)) /* is a Lua function? */
  324. luaV_execute(L); /* call it */
  325. g->nCcalls--;
  326. luaC_checkGC(L);
  327. }
  328. static void unroll (lua_State *L) {
  329. for (;;) {
  330. Instruction inst;
  331. luaV_execute(L); /* execute down to higher C 'boundary' */
  332. if (L->ci == L->base_ci) { /* stack is empty? */
  333. lua_assert(L->baseCcalls == G(L)->nCcalls);
  334. return; /* coroutine finished normally */
  335. }
  336. L->baseCcalls--; /* undo increment that allows yields */
  337. inst = *(L->savedpc - 1); /* interrupted instruction */
  338. switch (GET_OPCODE(inst)) { /* finish its execution */
  339. case OP_ADD: case OP_SUB: case OP_MUL: case OP_DIV:
  340. case OP_MOD: case OP_POW: case OP_UNM: case OP_LEN:
  341. case OP_GETGLOBAL: case OP_GETTABLE: case OP_SELF: {
  342. setobjs2s(L, L->base + GETARG_A(inst), --L->top);
  343. break;
  344. }
  345. case OP_LE: case OP_LT: case OP_EQ: {
  346. int res = !l_isfalse(L->top - 1);
  347. L->top--;
  348. /* metamethod should not be called when operand is K */
  349. lua_assert(!ISK(GETARG_B(inst)));
  350. if (GET_OPCODE(inst) == OP_LE && /* "<=" using "<" instead? */
  351. ttisnil(luaT_gettmbyobj(L, L->base + GETARG_B(inst), TM_LE)))
  352. res = !res; /* invert result */
  353. lua_assert(GET_OPCODE(*L->savedpc) == OP_JMP);
  354. if (res != GETARG_A(inst)) /* condition failed? */
  355. L->savedpc++; /* skip jump instruction */
  356. break;
  357. }
  358. case OP_CONCAT: {
  359. StkId top = L->top - 1; /* top when __concat was called */
  360. int last = cast_int(top - L->base) - 2; /* last element and ... */
  361. int b = GETARG_B(inst); /* ... first element to concatenate */
  362. int total = last - b + 1; /* number of elements to concatenate */
  363. setobj2s(L, top - 2, top); /* put TM result in proper position */
  364. L->top = L->ci->top; /* correct top */
  365. if (total > 1) /* are there elements to concat? */
  366. luaV_concat(L, total, last); /* concat them (may yield again) */
  367. /* move final result to final position */
  368. setobj2s(L, L->base + GETARG_A(inst), L->base + b);
  369. continue;
  370. }
  371. case OP_TFORCALL: {
  372. lua_assert(GET_OPCODE(*L->savedpc) == OP_TFORLOOP);
  373. L->top = L->ci->top; /* correct top */
  374. break;
  375. }
  376. case OP_SETGLOBAL: case OP_SETTABLE:
  377. break; /* nothing to be done */
  378. default: lua_assert(0);
  379. }
  380. }
  381. }
  382. static void resume (lua_State *L, void *ud) {
  383. StkId firstArg = cast(StkId, ud);
  384. CallInfo *ci = L->ci;
  385. if (L->status == LUA_OK) { /* start coroutine? */
  386. lua_assert(ci == L->base_ci && firstArg > L->base);
  387. if (luaD_precall(L, firstArg - 1, LUA_MULTRET)) /* C function? */
  388. return; /* done */
  389. }
  390. else { /* resuming from previous yield */
  391. lua_assert(L->status == LUA_YIELD);
  392. L->status = LUA_OK;
  393. if (isLua(ci)) /* yielded inside a hook? */
  394. L->base = L->ci->base; /* just continue its execution */
  395. else { /* 'common' yield */
  396. /* finish interrupted execution of `OP_CALL' */
  397. lua_assert(GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_CALL ||
  398. GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_TAILCALL);
  399. if (luaD_poscall(L, firstArg)) /* complete it... */
  400. L->top = L->ci->top; /* and correct top if not multiple results */
  401. }
  402. }
  403. unroll(L);
  404. }
  405. static int resume_error (lua_State *L, const char *msg) {
  406. L->top = L->ci->base;
  407. setsvalue2s(L, L->top, luaS_new(L, msg));
  408. incr_top(L);
  409. lua_unlock(L);
  410. return LUA_ERRRUN;
  411. }
  412. LUA_API int lua_resume (lua_State *L, int nargs) {
  413. int status;
  414. lua_lock(L);
  415. if (L->status != LUA_YIELD) {
  416. if (L->status != LUA_OK)
  417. return resume_error(L, "cannot resume dead coroutine");
  418. else if (L->ci != L->base_ci)
  419. return resume_error(L, "cannot resume non-suspended coroutine");
  420. }
  421. luai_userstateresume(L, nargs);
  422. lua_assert(L->errfunc == 0);
  423. if (G(L)->nCcalls >= LUAI_MAXCCALLS)
  424. return resume_error(L, "C stack overflow");
  425. ++G(L)->nCcalls; /* count resume */
  426. L->baseCcalls += G(L)->nCcalls;
  427. status = luaD_rawrunprotected(L, resume, L->top - nargs);
  428. if (status != LUA_OK && status != LUA_YIELD) { /* error? */
  429. L->status = cast_byte(status); /* mark thread as `dead' */
  430. luaD_seterrorobj(L, status, L->top);
  431. L->ci->top = L->top;
  432. }
  433. else {
  434. lua_assert(status == L->status);
  435. }
  436. L->baseCcalls -= G(L)->nCcalls;
  437. --G(L)->nCcalls;
  438. lua_unlock(L);
  439. return status;
  440. }
  441. LUA_API int lua_yield (lua_State *L, int nresults) {
  442. luai_userstateyield(L, nresults);
  443. lua_lock(L);
  444. if (G(L)->nCcalls > L->baseCcalls)
  445. luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
  446. L->base = L->top - nresults; /* protect stack slots below */
  447. L->status = LUA_YIELD;
  448. if (!isLua(L->ci)) /* not inside a hook? */
  449. luaD_throw(L, LUA_YIELD);
  450. lua_assert(L->ci->callstatus & CIST_HOOKED); /* must be inside a hook */
  451. lua_unlock(L);
  452. return 0; /* otherwise, return to 'luaD_callhook' */
  453. }
  454. int luaD_pcall (lua_State *L, Pfunc func, void *u,
  455. ptrdiff_t old_top, ptrdiff_t ef) {
  456. int status;
  457. ptrdiff_t old_ci = saveci(L, L->ci);
  458. lu_byte old_allowhooks = L->allowhook;
  459. ptrdiff_t old_errfunc = L->errfunc;
  460. L->errfunc = ef;
  461. status = luaD_rawrunprotected(L, func, u);
  462. if (status != LUA_OK) { /* an error occurred? */
  463. StkId oldtop = restorestack(L, old_top);
  464. luaF_close(L, oldtop); /* close possible pending closures */
  465. luaD_seterrorobj(L, status, oldtop);
  466. L->ci = restoreci(L, old_ci);
  467. L->base = L->ci->base;
  468. L->savedpc = L->ci->savedpc;
  469. L->allowhook = old_allowhooks;
  470. restore_stack_limit(L);
  471. }
  472. L->errfunc = old_errfunc;
  473. return status;
  474. }
  475. /*
  476. ** Execute a protected parser.
  477. */
  478. struct SParser { /* data to `f_parser' */
  479. ZIO *z;
  480. Mbuffer buff; /* buffer to be used by the scanner */
  481. const char *name;
  482. };
  483. static void f_parser (lua_State *L, void *ud) {
  484. int i;
  485. Proto *tf;
  486. Closure *cl;
  487. struct SParser *p = cast(struct SParser *, ud);
  488. int c = luaZ_lookahead(p->z);
  489. luaC_checkGC(L);
  490. tf = (c == LUA_SIGNATURE[0]) ? luaU_undump(L, p->z, &p->buff, p->name)
  491. : luaY_parser(L, p->z, &p->buff, p->name);
  492. setptvalue2s(L, L->top, tf);
  493. incr_top(L);
  494. cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L)));
  495. cl->l.p = tf;
  496. setclvalue(L, L->top - 1, cl);
  497. for (i = 0; i < tf->nups; i++) /* initialize upvalues */
  498. cl->l.upvals[i] = luaF_newupval(L);
  499. }
  500. int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) {
  501. struct SParser p;
  502. int status;
  503. p.z = z; p.name = name;
  504. luaZ_initbuffer(L, &p.buff);
  505. status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc);
  506. luaZ_freebuffer(L, &p.buff);
  507. return status;
  508. }