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 /lfunc.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 'lfunc.c')
| -rw-r--r-- | lfunc.c | 9 |
1 files changed, 5 insertions, 4 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lfunc.c,v 2.7 2005/01/19 15:54:26 roberto Exp roberto $ | 2 | ** $Id: lfunc.c,v 2.8 2005/02/10 13:25:02 roberto Exp roberto $ |
| 3 | ** Auxiliary functions to manipulate prototypes and closures | 3 | ** Auxiliary functions to manipulate prototypes and closures |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -20,20 +20,21 @@ | |||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | Closure *luaF_newCclosure (lua_State *L, int nelems) { | 23 | Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) { |
| 24 | Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems))); | 24 | Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems))); |
| 25 | luaC_link(L, obj2gco(c), LUA_TFUNCTION); | 25 | luaC_link(L, obj2gco(c), LUA_TFUNCTION); |
| 26 | c->c.isC = 1; | 26 | c->c.isC = 1; |
| 27 | c->c.env = e; | ||
| 27 | c->c.nupvalues = cast(lu_byte, nelems); | 28 | c->c.nupvalues = cast(lu_byte, nelems); |
| 28 | return c; | 29 | return c; |
| 29 | } | 30 | } |
| 30 | 31 | ||
| 31 | 32 | ||
| 32 | Closure *luaF_newLclosure (lua_State *L, int nelems, TValue *e) { | 33 | Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) { |
| 33 | Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems))); | 34 | Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems))); |
| 34 | luaC_link(L, obj2gco(c), LUA_TFUNCTION); | 35 | luaC_link(L, obj2gco(c), LUA_TFUNCTION); |
| 35 | c->l.isC = 0; | 36 | c->l.isC = 0; |
| 36 | c->l.g = *e; | 37 | c->l.env = e; |
| 37 | c->l.nupvalues = cast(lu_byte, nelems); | 38 | c->l.nupvalues = cast(lu_byte, nelems); |
| 38 | while (nelems--) c->l.upvals[nelems] = NULL; | 39 | while (nelems--) c->l.upvals[nelems] = NULL; |
| 39 | return c; | 40 | return c; |
