summaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-10-02 13:45:03 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-10-02 13:45:03 -0300
commit15462edb0ff86bf1904011b29635420451cab2c5 (patch)
tree9a626d34736b830f83fda3f1b2f3342990a05b1f /lvm.c
parent6f936bc7931662d0460d47ad73eca308ba5fab2f (diff)
downloadlua-15462edb0ff86bf1904011b29635420451cab2c5.tar.gz
lua-15462edb0ff86bf1904011b29635420451cab2c5.tar.bz2
lua-15462edb0ff86bf1904011b29635420451cab2c5.zip
new definitions for closure structures
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c30
1 files changed, 13 insertions, 17 deletions
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) {
64 64
65static void traceexec (lua_State *L, lua_Hook linehook) { 65static void traceexec (lua_State *L, lua_Hook linehook) {
66 CallInfo *ci = L->ci; 66 CallInfo *ci = L->ci;
67 int *lineinfo = ci_func(ci)->u.l.p->lineinfo; 67 int *lineinfo = ci_func(ci)->l.p->lineinfo;
68 int pc = (*ci->pc - ci_func(ci)->u.l.p->code) - 1; 68 int pc = (*ci->pc - ci_func(ci)->l.p->code) - 1;
69 int newline; 69 int newline;
70 if (pc == 0) { /* may be first time? */ 70 if (pc == 0) { /* may be first time? */
71 ci->line = 1; 71 ci->line = 1;
@@ -351,8 +351,8 @@ static void adjust_varargs (lua_State *L, StkId base, int nfixargs) {
351** Executes the given Lua function. Parameters are between [base,top). 351** Executes the given Lua function. Parameters are between [base,top).
352** Returns n such that the the results are between [n,top). 352** Returns n such that the the results are between [n,top).
353*/ 353*/
354StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { 354StkId luaV_execute (lua_State *L, const LClosure *cl, StkId base) {
355 const Proto *const tf = cl->u.l.p; 355 const Proto *const tf = cl->p;
356 const Instruction *pc; 356 const Instruction *pc;
357 lua_Hook linehook; 357 lua_Hook linehook;
358 if (tf->is_vararg) /* varargs? */ 358 if (tf->is_vararg) /* varargs? */
@@ -391,8 +391,8 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
391 } 391 }
392 case OP_GETUPVAL: { 392 case OP_GETUPVAL: {
393 int b = GETARG_B(i); 393 int b = GETARG_B(i);
394 lua_assert(luaF_isclosed(cl, b) || cl->u.l.upvals[b] < base); 394 lua_assert(cl->upvals[b].heap || cl->upvals[b].val < base);
395 setobj(ra, cl->u.l.upvals[b]); 395 setobj(ra, cl->upvals[b].val);
396 break; 396 break;
397 } 397 }
398 case OP_GETGLOBAL: { 398 case OP_GETGLOBAL: {
@@ -411,8 +411,8 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
411 } 411 }
412 case OP_SETUPVAL: { 412 case OP_SETUPVAL: {
413 int b = GETARG_B(i); 413 int b = GETARG_B(i);
414 lua_assert(luaF_isclosed(cl, b) || cl->u.l.upvals[b] < base); 414 lua_assert(cl->upvals[b].heap || cl->upvals[b].val < base);
415 setobj(cl->u.l.upvals[b], ra); 415 setobj(cl->upvals[b].val, ra);
416 break; 416 break;
417 } 417 }
418 case OP_SETTABLE: { 418 case OP_SETTABLE: {
@@ -644,18 +644,14 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
644 p = tf->p[GETARG_Bc(i)]; 644 p = tf->p[GETARG_Bc(i)];
645 nup = p->nupvalues; 645 nup = p->nupvalues;
646 ncl = luaF_newLclosure(L, nup); 646 ncl = luaF_newLclosure(L, nup);
647 ncl->u.l.p = p; 647 ncl->l.p = p;
648 for (j=0; j<nup; j++, pc++) { 648 for (j=0; j<nup; j++, pc++) {
649 if (GET_OPCODE(*pc) == OP_GETUPVAL) { 649 if (GET_OPCODE(*pc) == OP_GETUPVAL)
650 int n = GETARG_B(*pc); 650 ncl->l.upvals[j] = cl->upvals[GETARG_B(*pc)];
651 if (!luaF_isclosed(cl, n))
652 luaF_openentry(ncl, j);
653 ncl->u.l.upvals[j] = cl->u.l.upvals[n];
654 }
655 else { 651 else {
656 lua_assert(GET_OPCODE(*pc) == OP_MOVE); 652 lua_assert(GET_OPCODE(*pc) == OP_MOVE);
657 luaF_openentry(ncl, j); 653 ncl->l.upvals[j].heap = NULL;
658 ncl->u.l.upvals[j] = base + GETARG_B(*pc); 654 ncl->l.upvals[j].val = base + GETARG_B(*pc);
659 } 655 }
660 } 656 }
661 luaF_LConlist(L, ncl); 657 luaF_LConlist(L, ncl);