diff options
Diffstat (limited to 'lfunc.c')
| -rw-r--r-- | lfunc.c | 15 |
1 files changed, 3 insertions, 12 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lfunc.c,v 2.26 2010/06/10 21:27:09 roberto Exp roberto $ | 2 | ** $Id: lfunc.c,v 2.27 2010/06/30 14:11:17 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 | */ |
| @@ -21,8 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | Closure *luaF_newCclosure (lua_State *L, int n) { | 23 | Closure *luaF_newCclosure (lua_State *L, int n) { |
| 24 | Closure *c = &luaC_newobj(L, LUA_TFUNCTION, sizeCclosure(n), NULL, 0)->cl; | 24 | Closure *c = &luaC_newobj(L, LUA_TCCL, sizeCclosure(n), NULL, 0)->cl; |
| 25 | c->c.isC = 1; | ||
| 26 | c->c.nupvalues = cast_byte(n); | 25 | c->c.nupvalues = cast_byte(n); |
| 27 | return c; | 26 | return c; |
| 28 | } | 27 | } |
| @@ -30,8 +29,7 @@ Closure *luaF_newCclosure (lua_State *L, int n) { | |||
| 30 | 29 | ||
| 31 | Closure *luaF_newLclosure (lua_State *L, Proto *p) { | 30 | Closure *luaF_newLclosure (lua_State *L, Proto *p) { |
| 32 | int n = p->sizeupvalues; | 31 | int n = p->sizeupvalues; |
| 33 | Closure *c = &luaC_newobj(L, LUA_TFUNCTION, sizeLclosure(n), NULL, 0)->cl; | 32 | Closure *c = &luaC_newobj(L, LUA_TLCL, sizeLclosure(n), NULL, 0)->cl; |
| 34 | c->l.isC = 0; | ||
| 35 | c->l.p = p; | 33 | c->l.p = p; |
| 36 | c->l.nupvalues = cast_byte(n); | 34 | c->l.nupvalues = cast_byte(n); |
| 37 | while (n--) c->l.upvals[n] = NULL; | 35 | while (n--) c->l.upvals[n] = NULL; |
| @@ -146,13 +144,6 @@ void luaF_freeproto (lua_State *L, Proto *f) { | |||
| 146 | } | 144 | } |
| 147 | 145 | ||
| 148 | 146 | ||
| 149 | void luaF_freeclosure (lua_State *L, Closure *c) { | ||
| 150 | int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) : | ||
| 151 | sizeLclosure(c->l.nupvalues); | ||
| 152 | luaM_freemem(L, c, size); | ||
| 153 | } | ||
| 154 | |||
| 155 | |||
| 156 | /* | 147 | /* |
| 157 | ** Look for n-th local variable at line `line' in function `func'. | 148 | ** Look for n-th local variable at line `line' in function `func'. |
| 158 | ** Returns NULL if not found. | 149 | ** Returns NULL if not found. |
