From 7d45a5f48ff32a4e09a1734de23823943d6a6b28 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 18 Feb 2005 10:40:02 -0200 Subject: C functions and userdata also have environments --- lfunc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lfunc.c') diff --git a/lfunc.c b/lfunc.c index d69f75dd..9631f5dc 100644 --- a/lfunc.c +++ b/lfunc.c @@ -1,5 +1,5 @@ /* -** $Id: lfunc.c,v 2.7 2005/01/19 15:54:26 roberto Exp roberto $ +** $Id: lfunc.c,v 2.8 2005/02/10 13:25:02 roberto Exp roberto $ ** Auxiliary functions to manipulate prototypes and closures ** See Copyright Notice in lua.h */ @@ -20,20 +20,21 @@ -Closure *luaF_newCclosure (lua_State *L, int nelems) { +Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) { Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems))); luaC_link(L, obj2gco(c), LUA_TFUNCTION); c->c.isC = 1; + c->c.env = e; c->c.nupvalues = cast(lu_byte, nelems); return c; } -Closure *luaF_newLclosure (lua_State *L, int nelems, TValue *e) { +Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) { Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems))); luaC_link(L, obj2gco(c), LUA_TFUNCTION); c->l.isC = 0; - c->l.g = *e; + c->l.env = e; c->l.nupvalues = cast(lu_byte, nelems); while (nelems--) c->l.upvals[nelems] = NULL; return c; -- cgit v1.2.3-55-g6feb