diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-02-18 10:40:02 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-02-18 10:40:02 -0200 |
| commit | 7d45a5f48ff32a4e09a1734de23823943d6a6b28 (patch) | |
| tree | de7bef1faf37d9b639928e5269e89d7112b5b6fa /lvm.c | |
| parent | 73d764024451c24bc43b8e5102fe90974a86b7f4 (diff) | |
| download | lua-7d45a5f48ff32a4e09a1734de23823943d6a6b28.tar.gz lua-7d45a5f48ff32a4e09a1734de23823943d6a6b28.tar.bz2 lua-7d45a5f48ff32a4e09a1734de23823943d6a6b28.zip | |
C functions and userdata also have environments
Diffstat (limited to 'lvm.c')
| -rw-r--r-- | lvm.c | 16 |
1 files changed, 10 insertions, 6 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 2.22 2005/01/10 18:17:39 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.23 2005/01/10 18:33:37 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 | */ |
| @@ -428,9 +428,11 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
| 428 | continue; | 428 | continue; |
| 429 | } | 429 | } |
| 430 | case OP_GETGLOBAL: { | 430 | case OP_GETGLOBAL: { |
| 431 | TValue g; | ||
| 431 | TValue *rb = KBx(i); | 432 | TValue *rb = KBx(i); |
| 432 | lua_assert(ttisstring(rb) && ttistable(&cl->g)); | 433 | sethvalue(L, &g, cl->env); |
| 433 | base = luaV_gettable(L, &cl->g, rb, ra, pc); /***/ | 434 | lua_assert(ttisstring(rb)); |
| 435 | base = luaV_gettable(L, &g, rb, ra, pc); /***/ | ||
| 434 | continue; | 436 | continue; |
| 435 | } | 437 | } |
| 436 | case OP_GETTABLE: { | 438 | case OP_GETTABLE: { |
| @@ -438,8 +440,10 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
| 438 | continue; | 440 | continue; |
| 439 | } | 441 | } |
| 440 | case OP_SETGLOBAL: { | 442 | case OP_SETGLOBAL: { |
| 441 | lua_assert(ttisstring(KBx(i)) && ttistable(&cl->g)); | 443 | TValue g; |
| 442 | base = luaV_settable(L, &cl->g, KBx(i), ra, pc); /***/ | 444 | sethvalue(L, &g, cl->env); |
| 445 | lua_assert(ttisstring(KBx(i))); | ||
| 446 | base = luaV_settable(L, &g, KBx(i), ra, pc); /***/ | ||
| 443 | continue; | 447 | continue; |
| 444 | } | 448 | } |
| 445 | case OP_SETUPVAL: { | 449 | case OP_SETUPVAL: { |
| @@ -740,7 +744,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
| 740 | int nup, j; | 744 | int nup, j; |
| 741 | p = cl->p->p[GETARG_Bx(i)]; | 745 | p = cl->p->p[GETARG_Bx(i)]; |
| 742 | nup = p->nups; | 746 | nup = p->nups; |
| 743 | ncl = luaF_newLclosure(L, nup, &cl->g); | 747 | ncl = luaF_newLclosure(L, nup, cl->env); |
| 744 | ncl->l.p = p; | 748 | ncl->l.p = p; |
| 745 | for (j=0; j<nup; j++, pc++) { | 749 | for (j=0; j<nup; j++, pc++) { |
| 746 | if (GET_OPCODE(*pc) == OP_GETUPVAL) | 750 | if (GET_OPCODE(*pc) == OP_GETUPVAL) |
