aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldebug.c7
-rw-r--r--lfunc.c3
-rw-r--r--lgc.c6
-rw-r--r--lobject.h3
-rw-r--r--lparser.c17
-rw-r--r--lparser.h3
6 files changed, 21 insertions, 18 deletions
diff --git a/ldebug.c b/ldebug.c
index f99dfd75..c9b045bc 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 1.64 2001/02/16 17:58:27 roberto Exp roberto $ 2** $Id: ldebug.c,v 1.65 2001/02/20 18:15:33 roberto Exp roberto $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -433,7 +433,7 @@ static Instruction luaG_symbexec (lua_State *L, const Proto *pt,
433 break; 433 break;
434 } 434 }
435 case OP_PUSHUPVALUE: { 435 case OP_PUSHUPVALUE: {
436 /* ?? */ 436 check(arg1 < pt->nupvalues);
437 break; 437 break;
438 } 438 }
439 case OP_GETLOCAL: 439 case OP_GETLOCAL:
@@ -462,7 +462,8 @@ static Instruction luaG_symbexec (lua_State *L, const Proto *pt,
462 break; 462 break;
463 } 463 }
464 case OP_CLOSURE: { 464 case OP_CLOSURE: {
465 /* ?? */ 465 check(arg1 < pt->sizekproto);
466 check(arg2 == pt->kproto[arg1]->nupvalues);
466 pop = arg2; 467 pop = arg2;
467 break; 468 break;
468 } 469 }
diff --git a/lfunc.c b/lfunc.c
index e42bb64e..3b8dfd21 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lfunc.c,v 1.39 2001/02/01 17:40:48 roberto Exp roberto $ 2** $Id: lfunc.c,v 1.40 2001/02/09 20:22:29 roberto Exp roberto $
3** Auxiliary functions to manipulate prototypes and closures 3** Auxiliary functions to manipulate prototypes and closures
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -37,6 +37,7 @@ Proto *luaF_newproto (lua_State *L) {
37 f->sizekproto = 0; 37 f->sizekproto = 0;
38 f->code = NULL; 38 f->code = NULL;
39 f->sizecode = 0; 39 f->sizecode = 0;
40 f->nupvalues = 0;
40 f->numparams = 0; 41 f->numparams = 0;
41 f->is_vararg = 0; 42 f->is_vararg = 0;
42 f->maxstacksize = 0; 43 f->maxstacksize = 0;
diff --git a/lgc.c b/lgc.c
index d500549a..9b4c4eaa 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 1.88 2001/02/07 18:13:49 roberto Exp roberto $ 2** $Id: lgc.c,v 1.89 2001/02/20 18:15:33 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -62,8 +62,10 @@ static void protomark (Proto *f) {
62 62
63static void markclosure (GCState *st, Closure *cl) { 63static void markclosure (GCState *st, Closure *cl) {
64 if (!ismarked(cl)) { 64 if (!ismarked(cl)) {
65 if (!cl->isC) 65 if (!cl->isC) {
66 lua_assert(cl->nupvalues == cl->f.l->nupvalues);
66 protomark(cl->f.l); 67 protomark(cl->f.l);
68 }
67 cl->mark = st->cmark; /* chain it for later traversal */ 69 cl->mark = st->cmark; /* chain it for later traversal */
68 st->cmark = cl; 70 st->cmark = cl;
69 } 71 }
diff --git a/lobject.h b/lobject.h
index 5fb142a2..74f3c616 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.95 2001/02/09 20:22:29 roberto Exp roberto $ 2** $Id: lobject.h,v 1.96 2001/02/20 18:15:33 roberto Exp roberto $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -133,6 +133,7 @@ typedef struct Proto {
133 int sizekproto; /* size of `kproto' */ 133 int sizekproto; /* size of `kproto' */
134 Instruction *code; 134 Instruction *code;
135 int sizecode; 135 int sizecode;
136 short nupvalues;
136 short numparams; 137 short numparams;
137 short is_vararg; 138 short is_vararg;
138 short maxstacksize; 139 short maxstacksize;
diff --git a/lparser.c b/lparser.c
index be917924..aea4b621 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.134 2001/02/14 17:38:45 roberto Exp roberto $ 2** $Id: lparser.c,v 1.135 2001/02/20 18:15:33 roberto Exp roberto $
3** LL(1) Parser and code generator for Lua 3** LL(1) Parser and code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -219,14 +219,14 @@ static void singlevar (LexState *ls, TString *n, expdesc *var) {
219static int indexupvalue (LexState *ls, expdesc *v) { 219static int indexupvalue (LexState *ls, expdesc *v) {
220 FuncState *fs = ls->fs; 220 FuncState *fs = ls->fs;
221 int i; 221 int i;
222 for (i=0; i<fs->nupvalues; i++) { 222 for (i=0; i<fs->f->nupvalues; i++) {
223 if (fs->upvalues[i].k == v->k && fs->upvalues[i].u.index == v->u.index) 223 if (fs->upvalues[i].k == v->k && fs->upvalues[i].u.index == v->u.index)
224 return i; 224 return i;
225 } 225 }
226 /* new one */ 226 /* new one */
227 luaX_checklimit(ls, fs->nupvalues+1, MAXUPVALUES, "upvalues"); 227 luaX_checklimit(ls, fs->f->nupvalues+1, MAXUPVALUES, "upvalues");
228 fs->upvalues[fs->nupvalues] = *v; 228 fs->upvalues[fs->f->nupvalues] = *v;
229 return fs->nupvalues++; 229 return fs->f->nupvalues++;
230} 230}
231 231
232 232
@@ -297,12 +297,12 @@ static void pushclosure (LexState *ls, FuncState *func) {
297 FuncState *fs = ls->fs; 297 FuncState *fs = ls->fs;
298 Proto *f = fs->f; 298 Proto *f = fs->f;
299 int i; 299 int i;
300 for (i=0; i<func->nupvalues; i++) 300 for (i=0; i<func->f->nupvalues; i++)
301 luaK_tostack(ls, &func->upvalues[i], 1); 301 luaK_tostack(ls, &func->upvalues[i], 1);
302 luaM_growvector(ls->L, f->kproto, fs->nkproto, f->sizekproto, Proto *, 302 luaM_growvector(ls->L, f->kproto, fs->nkproto, f->sizekproto, Proto *,
303 MAXARG_A, "constant table overflow"); 303 MAXARG_A, "constant table overflow");
304 f->kproto[fs->nkproto++] = func->f; 304 f->kproto[fs->nkproto++] = func->f;
305 luaK_code2(fs, OP_CLOSURE, fs->nkproto-1, func->nupvalues); 305 luaK_code2(fs, OP_CLOSURE, fs->nkproto-1, func->f->nupvalues);
306} 306}
307 307
308 308
@@ -323,7 +323,6 @@ static void open_func (LexState *ls, FuncState *fs) {
323 fs->nlineinfo = 0; 323 fs->nlineinfo = 0;
324 fs->nlocvars = 0; 324 fs->nlocvars = 0;
325 fs->nactloc = 0; 325 fs->nactloc = 0;
326 fs->nupvalues = 0;
327 fs->lastline = 0; 326 fs->lastline = 0;
328 fs->bl = NULL; 327 fs->bl = NULL;
329 f->code = NULL; 328 f->code = NULL;
@@ -370,7 +369,7 @@ Proto *luaY_parser (lua_State *L, ZIO *z) {
370 check_condition(&lexstate, (lexstate.t.token == TK_EOS), "<eof> expected"); 369 check_condition(&lexstate, (lexstate.t.token == TK_EOS), "<eof> expected");
371 close_func(&lexstate); 370 close_func(&lexstate);
372 lua_assert(funcstate.prev == NULL); 371 lua_assert(funcstate.prev == NULL);
373 lua_assert(funcstate.nupvalues == 0); 372 lua_assert(funcstate.f->nupvalues == 0);
374 return funcstate.f; 373 return funcstate.f;
375} 374}
376 375
diff --git a/lparser.h b/lparser.h
index 933934c9..a754b3be 100644
--- a/lparser.h
+++ b/lparser.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.h,v 1.28 2000/12/26 18:46:09 roberto Exp roberto $ 2** $Id: lparser.h,v 1.29 2000/12/28 12:55:41 roberto Exp roberto $
3** LL(1) Parser and code generator for Lua 3** LL(1) Parser and code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -51,7 +51,6 @@ typedef struct FuncState {
51 int nlineinfo; /* number of elements in `lineinfo' */ 51 int nlineinfo; /* number of elements in `lineinfo' */
52 int nlocvars; /* number of elements in `locvars' */ 52 int nlocvars; /* number of elements in `locvars' */
53 int nactloc; /* number of active local variables */ 53 int nactloc; /* number of active local variables */
54 int nupvalues; /* number of upvalues */
55 int lastline; /* line where last `lineinfo' was generated */ 54 int lastline; /* line where last `lineinfo' was generated */
56 struct Breaklabel *bl; /* chain of breakable blocks */ 55 struct Breaklabel *bl; /* chain of breakable blocks */
57 expdesc upvalues[MAXUPVALUES]; /* upvalues */ 56 expdesc upvalues[MAXUPVALUES]; /* upvalues */