diff options
Diffstat (limited to 'lvm.c')
| -rw-r--r-- | lvm.c | 10 |
1 files changed, 9 insertions, 1 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 2.97 2009/09/23 20:33:05 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.98 2009/09/28 16:32:50 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 | */ |
| @@ -780,6 +780,14 @@ void luaV_execute (lua_State *L) { | |||
| 780 | int j; | 780 | int j; |
| 781 | ncl->l.p = p; | 781 | ncl->l.p = p; |
| 782 | setclvalue(L, ra, ncl); /* anchor new closure in stack */ | 782 | setclvalue(L, ra, ncl); /* anchor new closure in stack */ |
| 783 | if (p->envreg != NO_REG) { /* lexical environment? */ | ||
| 784 | StkId env = base + p->envreg; | ||
| 785 | if (!ttistable(env)) | ||
| 786 | luaG_runerror(L, "environment is not a table: " | ||
| 787 | "cannot create closure"); | ||
| 788 | else | ||
| 789 | ncl->l.env = hvalue(env); | ||
| 790 | } | ||
| 783 | for (j = 0; j < nup; j++) { /* fill in upvalues */ | 791 | for (j = 0; j < nup; j++) { /* fill in upvalues */ |
| 784 | if (uv[j].instack) /* upvalue refers to local variable? */ | 792 | if (uv[j].instack) /* upvalue refers to local variable? */ |
| 785 | ncl->l.upvals[j] = luaF_findupval(L, base + uv[j].idx); | 793 | ncl->l.upvals[j] = luaF_findupval(L, base + uv[j].idx); |
