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