summaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2012-05-08 10:53:33 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2012-05-08 10:53:33 -0300
commit3cadc37f470df50deb5c920b028125b8bb6c316b (patch)
treea2a448ef80bddb0ddef2581d0692ccec3de5b159 /ldo.c
parentbb1146dc3986c6f123ed6d85a26694ca8d56f94a (diff)
downloadlua-3cadc37f470df50deb5c920b028125b8bb6c316b.tar.gz
lua-3cadc37f470df50deb5c920b028125b8bb6c316b.tar.bz2
lua-3cadc37f470df50deb5c920b028125b8bb6c316b.zip
no more 'Proto' objects on the stack. Protos are anchored on outer
Protos or on a Closure, which must be created before the Proto.
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/ldo.c b/ldo.c
index 79a27678..f3121fd0 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 2.102 2011/11/29 15:55:08 roberto Exp roberto $ 2** $Id: ldo.c,v 2.103 2012/04/26 20:41:18 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*/
@@ -626,24 +626,23 @@ static void checkmode (lua_State *L, const char *mode, const char *x) {
626 626
627static void f_parser (lua_State *L, void *ud) { 627static void f_parser (lua_State *L, void *ud) {
628 int i; 628 int i;
629 Proto *tf;
630 Closure *cl; 629 Closure *cl;
631 struct SParser *p = cast(struct SParser *, ud); 630 struct SParser *p = cast(struct SParser *, ud);
632 int c = zgetc(p->z); /* read first character */ 631 int c = zgetc(p->z); /* read first character */
633 if (c == LUA_SIGNATURE[0]) { 632 if (c == LUA_SIGNATURE[0]) {
634 checkmode(L, p->mode, "binary"); 633 checkmode(L, p->mode, "binary");
635 tf = luaU_undump(L, p->z, &p->buff, p->name); 634 cl = luaU_undump(L, p->z, &p->buff, p->name);
636 } 635 }
637 else { 636 else {
638 checkmode(L, p->mode, "text"); 637 checkmode(L, p->mode, "text");
639 tf = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c); 638 cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c);
639 }
640 lua_assert(cl->l.nupvalues == cl->l.p->sizeupvalues);
641 for (i = 0; i < cl->l.nupvalues; i++) { /* initialize upvalues */
642 UpVal *up = luaF_newupval(L);
643 cl->l.upvals[i] = up;
644 luaC_objbarrier(L, cl, up);
640 } 645 }
641 setptvalue2s(L, L->top, tf);
642 incr_top(L);
643 cl = luaF_newLclosure(L, tf);
644 setclLvalue(L, L->top - 1, cl);
645 for (i = 0; i < tf->sizeupvalues; i++) /* initialize upvalues */
646 cl->l.upvals[i] = luaF_newupval(L);
647} 646}
648 647
649 648