diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-06-02 16:31:40 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-06-02 16:31:40 -0300 |
| commit | 3b44821334a1aa387c13eaf3cd23a2344091cbc7 (patch) | |
| tree | 7070ed226b6db26ae82f99d94138465a95b0d7fc /lvm.c | |
| parent | 0214dab989396de05567f293e6aa909ee2ffbac1 (diff) | |
| download | lua-3b44821334a1aa387c13eaf3cd23a2344091cbc7.tar.gz lua-3b44821334a1aa387c13eaf3cd23a2344091cbc7.tar.bz2 lua-3b44821334a1aa387c13eaf3cd23a2344091cbc7.zip | |
stricter control (using tag variants) over closure kinds (Lua x C)
Diffstat (limited to 'lvm.c')
| -rw-r--r-- | lvm.c | 13 |
1 files changed, 6 insertions, 7 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 2.138 2011/05/31 18:24:36 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.139 2011/05/31 18:27:56 roberto Exp roberto $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -65,7 +65,7 @@ static void traceexec (lua_State *L) { | |||
| 65 | luaD_hook(L, LUA_HOOKCOUNT, -1); | 65 | luaD_hook(L, LUA_HOOKCOUNT, -1); |
| 66 | } | 66 | } |
| 67 | if (mask & LUA_MASKLINE) { | 67 | if (mask & LUA_MASKLINE) { |
| 68 | Proto *p = ci_func(ci)->l.p; | 68 | Proto *p = ci_func(ci)->p; |
| 69 | int npc = pcRel(ci->u.l.savedpc, p); | 69 | int npc = pcRel(ci->u.l.savedpc, p); |
| 70 | int newline = getfuncline(p, npc); | 70 | int newline = getfuncline(p, npc); |
| 71 | if (npc == 0 || /* call linehook when enter a new function, */ | 71 | if (npc == 0 || /* call linehook when enter a new function, */ |
| @@ -315,7 +315,7 @@ void luaV_concat (lua_State *L, int total) { | |||
| 315 | 315 | ||
| 316 | void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) { | 316 | void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) { |
| 317 | const TValue *tm; | 317 | const TValue *tm; |
| 318 | switch (ttype(rb)) { | 318 | switch (ttypenv(rb)) { |
| 319 | case LUA_TTABLE: { | 319 | case LUA_TTABLE: { |
| 320 | Table *h = hvalue(rb); | 320 | Table *h = hvalue(rb); |
| 321 | tm = fasttm(L, h->metatable, TM_LEN); | 321 | tm = fasttm(L, h->metatable, TM_LEN); |
| @@ -385,7 +385,7 @@ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, | |||
| 385 | Upvaldesc *uv = p->upvalues; | 385 | Upvaldesc *uv = p->upvalues; |
| 386 | int i; | 386 | int i; |
| 387 | Closure *ncl = luaF_newLclosure(L, p); | 387 | Closure *ncl = luaF_newLclosure(L, p); |
| 388 | setclvalue(L, ra, ncl); /* anchor new closure in stack */ | 388 | setclLvalue(L, ra, ncl); /* anchor new closure in stack */ |
| 389 | for (i = 0; i < nup; i++) { /* fill in its upvalues */ | 389 | for (i = 0; i < nup; i++) { /* fill in its upvalues */ |
| 390 | if (uv[i].instack) /* upvalue refers to local variable? */ | 390 | if (uv[i].instack) /* upvalue refers to local variable? */ |
| 391 | ncl->l.upvals[i] = luaF_findupval(L, base + uv[i].idx); | 391 | ncl->l.upvals[i] = luaF_findupval(L, base + uv[i].idx); |
| @@ -512,9 +512,8 @@ void luaV_execute (lua_State *L) { | |||
| 512 | TValue *k; | 512 | TValue *k; |
| 513 | StkId base; | 513 | StkId base; |
| 514 | newframe: /* reentry point when frame changes (call/return) */ | 514 | newframe: /* reentry point when frame changes (call/return) */ |
| 515 | lua_assert(isLua(ci)); | ||
| 516 | lua_assert(ci == L->ci); | 515 | lua_assert(ci == L->ci); |
| 517 | cl = &clvalue(ci->func)->l; | 516 | cl = clLvalue(ci->func); |
| 518 | k = cl->p->k; | 517 | k = cl->p->k; |
| 519 | base = ci->u.l.base; | 518 | base = ci->u.l.base; |
| 520 | /* main loop of interpreter */ | 519 | /* main loop of interpreter */ |
| @@ -819,7 +818,7 @@ void luaV_execute (lua_State *L) { | |||
| 819 | if (ncl == NULL) /* no match? */ | 818 | if (ncl == NULL) /* no match? */ |
| 820 | pushclosure(L, p, cl->upvals, base, ra); /* create a new one */ | 819 | pushclosure(L, p, cl->upvals, base, ra); /* create a new one */ |
| 821 | else | 820 | else |
| 822 | setclvalue(L, ra, ncl); /* push cashed closure */ | 821 | setclLvalue(L, ra, ncl); /* push cashed closure */ |
| 823 | checkGC(L, | 822 | checkGC(L, |
| 824 | L->top = ra + 1; /* limit of live values */ | 823 | L->top = ra + 1; /* limit of live values */ |
| 825 | luaC_step(L); | 824 | luaC_step(L); |
