diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-02-07 15:14:50 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-02-07 15:14:50 -0200 |
| commit | f0797492875dec5bf7a23b9172809bc92c0c04cd (patch) | |
| tree | 712c44cd08fc8ee3a12c11029dc50f1988f8628f /ldo.c | |
| parent | f8d677f94c3b4309be94698d33aeb0590a51eabc (diff) | |
| download | lua-f0797492875dec5bf7a23b9172809bc92c0c04cd.tar.gz lua-f0797492875dec5bf7a23b9172809bc92c0c04cd.tar.bz2 lua-f0797492875dec5bf7a23b9172809bc92c0c04cd.zip | |
some reorganization of dynamic data structures used by the parser
Diffstat (limited to 'ldo.c')
| -rw-r--r-- | ldo.c | 23 |
1 files changed, 10 insertions, 13 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldo.c,v 2.90 2010/10/25 19:01:37 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.91 2011/02/04 17:34:43 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 | */ |
| @@ -615,10 +615,8 @@ int luaD_pcall (lua_State *L, Pfunc func, void *u, | |||
| 615 | */ | 615 | */ |
| 616 | struct SParser { /* data to `f_parser' */ | 616 | struct SParser { /* data to `f_parser' */ |
| 617 | ZIO *z; | 617 | ZIO *z; |
| 618 | Mbuffer buff; /* buffer to be used by the scanner */ | 618 | Mbuffer buff; /* dynamic structure used by the scanner */ |
| 619 | Varlist varl; /* list of local variables (to be used by the parser) */ | 619 | Dyndata dyd; /* dynamic structures used by the parser */ |
| 620 | Gotolist gtl; /* list of pending gotos (") */ | ||
| 621 | Labellist labell; /* list of active labels (") */ | ||
| 622 | const char *name; | 620 | const char *name; |
| 623 | }; | 621 | }; |
| 624 | 622 | ||
| @@ -630,8 +628,7 @@ static void f_parser (lua_State *L, void *ud) { | |||
| 630 | int c = luaZ_lookahead(p->z); | 628 | int c = luaZ_lookahead(p->z); |
| 631 | tf = (c == LUA_SIGNATURE[0]) | 629 | tf = (c == LUA_SIGNATURE[0]) |
| 632 | ? luaU_undump(L, p->z, &p->buff, p->name) | 630 | ? luaU_undump(L, p->z, &p->buff, p->name) |
| 633 | : luaY_parser(L, p->z, &p->buff, &p->varl, | 631 | : luaY_parser(L, p->z, &p->buff, &p->dyd, p->name); |
| 634 | &p->gtl, &p->labell, p->name); | ||
| 635 | setptvalue2s(L, L->top, tf); | 632 | setptvalue2s(L, L->top, tf); |
| 636 | incr_top(L); | 633 | incr_top(L); |
| 637 | cl = luaF_newLclosure(L, tf); | 634 | cl = luaF_newLclosure(L, tf); |
| @@ -646,15 +643,15 @@ int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) { | |||
| 646 | int status; | 643 | int status; |
| 647 | L->nny++; /* cannot yield during parsing */ | 644 | L->nny++; /* cannot yield during parsing */ |
| 648 | p.z = z; p.name = name; | 645 | p.z = z; p.name = name; |
| 649 | p.varl.actvar = NULL; p.varl.nactvar = p.varl.actvarsize = 0; | 646 | p.dyd.actvar.arr = NULL; p.dyd.actvar.size = 0; |
| 650 | p.gtl.gt = NULL; p.gtl.ngt = p.gtl.gtsize = 0; | 647 | p.dyd.gt.arr = NULL; p.dyd.gt.size = 0; |
| 651 | p.labell.label = NULL; p.labell.nlabel = p.labell.labelsize = 0; | 648 | p.dyd.label.arr = NULL; p.dyd.label.size = 0; |
| 652 | luaZ_initbuffer(L, &p.buff); | 649 | luaZ_initbuffer(L, &p.buff); |
| 653 | status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); | 650 | status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); |
| 654 | luaZ_freebuffer(L, &p.buff); | 651 | luaZ_freebuffer(L, &p.buff); |
| 655 | luaM_freearray(L, p.varl.actvar, p.varl.actvarsize); | 652 | luaM_freearray(L, p.dyd.actvar.arr, p.dyd.actvar.size); |
| 656 | luaM_freearray(L, p.gtl.gt, p.gtl.gtsize); | 653 | luaM_freearray(L, p.dyd.gt.arr, p.dyd.gt.size); |
| 657 | luaM_freearray(L, p.labell.label, p.labell.labelsize); | 654 | luaM_freearray(L, p.dyd.label.arr, p.dyd.label.size); |
| 658 | L->nny--; | 655 | L->nny--; |
| 659 | return status; | 656 | return status; |
| 660 | } | 657 | } |
