From 15462edb0ff86bf1904011b29635420451cab2c5 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 2 Oct 2001 13:45:03 -0300 Subject: new definitions for closure structures --- lvm.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'lvm.c') diff --git a/lvm.c b/lvm.c index 1fe4aad5..980ed113 100644 --- a/lvm.c +++ b/lvm.c @@ -64,8 +64,8 @@ int luaV_tostring (lua_State *L, TObject *obj) { static void traceexec (lua_State *L, lua_Hook linehook) { CallInfo *ci = L->ci; - int *lineinfo = ci_func(ci)->u.l.p->lineinfo; - int pc = (*ci->pc - ci_func(ci)->u.l.p->code) - 1; + int *lineinfo = ci_func(ci)->l.p->lineinfo; + int pc = (*ci->pc - ci_func(ci)->l.p->code) - 1; int newline; if (pc == 0) { /* may be first time? */ ci->line = 1; @@ -351,8 +351,8 @@ static void adjust_varargs (lua_State *L, StkId base, int nfixargs) { ** Executes the given Lua function. Parameters are between [base,top). ** Returns n such that the the results are between [n,top). */ -StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { - const Proto *const tf = cl->u.l.p; +StkId luaV_execute (lua_State *L, const LClosure *cl, StkId base) { + const Proto *const tf = cl->p; const Instruction *pc; lua_Hook linehook; if (tf->is_vararg) /* varargs? */ @@ -391,8 +391,8 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { } case OP_GETUPVAL: { int b = GETARG_B(i); - lua_assert(luaF_isclosed(cl, b) || cl->u.l.upvals[b] < base); - setobj(ra, cl->u.l.upvals[b]); + lua_assert(cl->upvals[b].heap || cl->upvals[b].val < base); + setobj(ra, cl->upvals[b].val); break; } case OP_GETGLOBAL: { @@ -411,8 +411,8 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { } case OP_SETUPVAL: { int b = GETARG_B(i); - lua_assert(luaF_isclosed(cl, b) || cl->u.l.upvals[b] < base); - setobj(cl->u.l.upvals[b], ra); + lua_assert(cl->upvals[b].heap || cl->upvals[b].val < base); + setobj(cl->upvals[b].val, ra); break; } case OP_SETTABLE: { @@ -644,18 +644,14 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { p = tf->p[GETARG_Bc(i)]; nup = p->nupvalues; ncl = luaF_newLclosure(L, nup); - ncl->u.l.p = p; + ncl->l.p = p; for (j=0; ju.l.upvals[j] = cl->u.l.upvals[n]; - } + if (GET_OPCODE(*pc) == OP_GETUPVAL) + ncl->l.upvals[j] = cl->upvals[GETARG_B(*pc)]; else { lua_assert(GET_OPCODE(*pc) == OP_MOVE); - luaF_openentry(ncl, j); - ncl->u.l.upvals[j] = base + GETARG_B(*pc); + ncl->l.upvals[j].heap = NULL; + ncl->l.upvals[j].val = base + GETARG_B(*pc); } } luaF_LConlist(L, ncl); -- cgit v1.2.3-55-g6feb