aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-10-11 17:02:19 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-10-11 17:02:19 -0300
commit916587508c117decb2f4d70677fa06be18803874 (patch)
tree24f930dcb544c9ddb5a15394537b5d7d8e64169e /ldo.c
parenta5382b763c2faa4c47e55ee0e49889b4c47daac4 (diff)
downloadlua-916587508c117decb2f4d70677fa06be18803874.tar.gz
lua-916587508c117decb2f4d70677fa06be18803874.tar.bz2
lua-916587508c117decb2f4d70677fa06be18803874.zip
parser keeps list of active local variables in a single dynamic array,
therefore saving C stack space
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/ldo.c b/ldo.c
index d3c9906d..6affe61f 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 2.67 2009/09/14 14:30:39 roberto Exp roberto $ 2** $Id: ldo.c,v 2.68 2009/09/28 16:32:50 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*/
@@ -563,6 +563,7 @@ int luaD_pcall (lua_State *L, Pfunc func, void *u,
563struct SParser { /* data to `f_parser' */ 563struct SParser { /* data to `f_parser' */
564 ZIO *z; 564 ZIO *z;
565 Mbuffer buff; /* buffer to be used by the scanner */ 565 Mbuffer buff; /* buffer to be used by the scanner */
566 Varlist varl; /* list of local variables (to be used by the parser) */
566 const char *name; 567 const char *name;
567}; 568};
568 569
@@ -573,8 +574,9 @@ static void f_parser (lua_State *L, void *ud) {
573 struct SParser *p = cast(struct SParser *, ud); 574 struct SParser *p = cast(struct SParser *, ud);
574 int c = luaZ_lookahead(p->z); 575 int c = luaZ_lookahead(p->z);
575 luaC_checkGC(L); 576 luaC_checkGC(L);
576 tf = (c == LUA_SIGNATURE[0]) ? luaU_undump(L, p->z, &p->buff, p->name) 577 tf = (c == LUA_SIGNATURE[0])
577 : luaY_parser(L, p->z, &p->buff, p->name); 578 ? luaU_undump(L, p->z, &p->buff, p->name)
579 : luaY_parser(L, p->z, &p->buff, &p->varl, p->name);
578 setptvalue2s(L, L->top, tf); 580 setptvalue2s(L, L->top, tf);
579 incr_top(L); 581 incr_top(L);
580 cl = luaF_newLclosure(L, tf->sizeupvalues, hvalue(gt(L))); 582 cl = luaF_newLclosure(L, tf->sizeupvalues, hvalue(gt(L)));
@@ -589,9 +591,11 @@ int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) {
589 struct SParser p; 591 struct SParser p;
590 int status; 592 int status;
591 p.z = z; p.name = name; 593 p.z = z; p.name = name;
594 p.varl.actvar = NULL; p.varl.nactvar = p.varl.actvarsize = 0;
592 luaZ_initbuffer(L, &p.buff); 595 luaZ_initbuffer(L, &p.buff);
593 status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); 596 status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc);
594 luaZ_freebuffer(L, &p.buff); 597 luaZ_freebuffer(L, &p.buff);
598 luaM_freearray(L, p.varl.actvar, p.varl.actvarsize);
595 return status; 599 return status;
596} 600}
597 601