aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-09-30 12:38:37 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-09-30 12:38:37 -0300
commit0ac3d07ea64ce4bcb8b935fb80fbb2b72d6b8f43 (patch)
tree2463af169272845741337a44f03afd476a600609 /lvm.c
parent5938212748636d21d6f4b372481ab3b6dd6c7538 (diff)
downloadlua-0ac3d07ea64ce4bcb8b935fb80fbb2b72d6b8f43.tar.gz
lua-0ac3d07ea64ce4bcb8b935fb80fbb2b72d6b8f43.tar.bz2
lua-0ac3d07ea64ce4bcb8b935fb80fbb2b72d6b8f43.zip
first implementation of lexical environments
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lvm.c b/lvm.c
index 7473d73b..004e112c 100644
--- a/lvm.c
+++ b/lvm.c
@@ -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);