diff options
Diffstat (limited to 'ldo.c')
| -rw-r--r-- | ldo.c | 22 |
1 files changed, 8 insertions, 14 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldo.c,v 1.222 2003/08/25 19:51:54 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.223 2003/08/26 12:04:13 roberto Exp roberto $ |
| 3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -429,18 +429,17 @@ int luaD_pcall (lua_State *L, Pfunc func, void *u, | |||
| 429 | struct SParser { /* data to `f_parser' */ | 429 | struct SParser { /* data to `f_parser' */ |
| 430 | ZIO *z; | 430 | ZIO *z; |
| 431 | Mbuffer buff; /* buffer to be used by the scanner */ | 431 | Mbuffer buff; /* buffer to be used by the scanner */ |
| 432 | int bin; | ||
| 433 | const char *name; | 432 | const char *name; |
| 434 | }; | 433 | }; |
| 435 | 434 | ||
| 436 | static void f_parser (lua_State *L, void *ud) { | 435 | static void f_parser (lua_State *L, void *ud) { |
| 437 | struct SParser *p; | ||
| 438 | Proto *tf; | 436 | Proto *tf; |
| 439 | Closure *cl; | 437 | Closure *cl; |
| 438 | struct SParser *p = cast(struct SParser *, ud); | ||
| 439 | int c = luaZ_lookahead(p->z); | ||
| 440 | luaC_checkGC(L); | 440 | luaC_checkGC(L); |
| 441 | p = cast(struct SParser *, ud); | 441 | tf = (c == LUA_SIGNATURE[0]) ? luaU_undump(L, p->z, &p->buff, p->name) : |
| 442 | tf = p->bin ? luaU_undump(L, p->z, &p->buff, p->name) : | 442 | luaY_parser(L, p->z, &p->buff, p->name); |
| 443 | luaY_parser(L, p->z, &p->buff, p->name); | ||
| 444 | cl = luaF_newLclosure(L, 0, gt(L)); | 443 | cl = luaF_newLclosure(L, 0, gt(L)); |
| 445 | cl->l.p = tf; | 444 | cl->l.p = tf; |
| 446 | setclvalue(L->top, cl); | 445 | setclvalue(L->top, cl); |
| @@ -448,18 +447,13 @@ static void f_parser (lua_State *L, void *ud) { | |||
| 448 | } | 447 | } |
| 449 | 448 | ||
| 450 | 449 | ||
| 451 | int luaD_protectedparser (lua_State *L, ZIO *z, int bin, const char *name) { | 450 | int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) { |
| 452 | struct SParser p; | 451 | struct SParser p; |
| 453 | int status; | 452 | int status; |
| 454 | ptrdiff_t oldtopr = savestack(L, L->top); /* save current top */ | 453 | p.z = z; p.name = name; |
| 455 | p.z = z; p.bin = bin; p.name = name; | ||
| 456 | luaZ_initbuffer(L, &p.buff); | 454 | luaZ_initbuffer(L, &p.buff); |
| 457 | status = luaD_rawrunprotected(L, f_parser, &p); | 455 | status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); |
| 458 | luaZ_freebuffer(L, &p.buff); | 456 | luaZ_freebuffer(L, &p.buff); |
| 459 | if (status != 0) { /* error? */ | ||
| 460 | StkId oldtop = restorestack(L, oldtopr); | ||
| 461 | seterrorobj(L, status, oldtop); | ||
| 462 | } | ||
| 463 | return status; | 457 | return status; |
| 464 | } | 458 | } |
| 465 | 459 | ||
