From 45ccb0e881064492a3f422b15b50dad71eed36fa Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 16 Oct 1997 08:59:34 -0200 Subject: "nupvalues" is kept in Closure, not in prototype (as a preparation for C closures...) --- lua.stx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lua.stx') diff --git a/lua.stx b/lua.stx index 112a6b40..12d06bc4 100644 --- a/lua.stx +++ b/lua.stx @@ -1,6 +1,6 @@ %{ /* -** $Id: lua.stx,v 1.9 1997/10/13 22:12:04 roberto Exp roberto $ +** $Id: lua.stx,v 1.10 1997/10/15 20:16:00 roberto Exp roberto $ ** Syntax analizer and code generator ** See Copyright Notice in lua.h */ @@ -57,6 +57,7 @@ typedef struct State { int stacksize; /* number of values on activation register */ int maxstacksize; /* maximum number of values on activation register */ int nlocalvar; /* number of active local variables */ + int nupvalues; /* number of upvalues */ int nvars; /* number of entries in f->locvars */ int maxcode; /* size of f->code */ int maxvars; /* size of f->locvars (-1 if no debug information) */ @@ -347,14 +348,14 @@ static int indexupvalue (TaggedString *n) { vardesc v = singlevar(n, currState-1); int i; - for (i=0; if->nupvalues; i++) { + for (i=0; inupvalues; i++) { if (currState->upvalues[i] == v) return i; } /* new one */ - if (++currState->f->nupvalues > MAXUPVALUES) + if (++currState->nupvalues > MAXUPVALUES) luaY_error("too many upvalues in a single function"); - currState->upvalues[i] = v; /* i = currState->f->nupvalues - 1 */ + currState->upvalues[i] = v; /* i = currState->nupvalues - 1 */ return i; } @@ -515,13 +516,14 @@ static void codereturn (void) static void func_onstack (TProtoFunc *f) { int i; - int nupvalues = (currState+1)->f->nupvalues; + int nupvalues = (currState+1)->nupvalues; int c = next_constant(currState); ttype(&currState->f->consts[c]) = LUA_T_PROTO; currState->f->consts[c].value.tf = (currState+1)->f; + code_constant(c); for (i=0; iupvalues[i]); - code_oparg(CLOSURE, 0, c, 1-nupvalues); + code_oparg(CLOSURE, 2, nupvalues, -nupvalues); } @@ -531,6 +533,7 @@ static void init_state (TaggedString *filename) currState->stacksize = 0; currState->maxstacksize = 0; currState->nlocalvar = 0; + currState->nupvalues = 0; currState->f = f; f->fileName = filename; currState->pc = 0; -- cgit v1.2.3-55-g6feb