object tag keeps variant bits too -> no need for 'isC' field in

Closures + more strick typing for closure variants
This commit is contained in:
Roberto Ierusalimschy
2012-01-20 20:05:50 -02:00
parent 76eab106df
commit fd22ccd6d0
7 changed files with 88 additions and 67 deletions

15
lfunc.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: lfunc.c,v 2.26 2010/06/10 21:27:09 roberto Exp roberto $
** $Id: lfunc.c,v 2.27 2010/06/30 14:11:17 roberto Exp roberto $
** Auxiliary functions to manipulate prototypes and closures
** See Copyright Notice in lua.h
*/
@@ -21,8 +21,7 @@
Closure *luaF_newCclosure (lua_State *L, int n) {
Closure *c = &luaC_newobj(L, LUA_TFUNCTION, sizeCclosure(n), NULL, 0)->cl;
c->c.isC = 1;
Closure *c = &luaC_newobj(L, LUA_TCCL, sizeCclosure(n), NULL, 0)->cl;
c->c.nupvalues = cast_byte(n);
return c;
}
@@ -30,8 +29,7 @@ Closure *luaF_newCclosure (lua_State *L, int n) {
Closure *luaF_newLclosure (lua_State *L, Proto *p) {
int n = p->sizeupvalues;
Closure *c = &luaC_newobj(L, LUA_TFUNCTION, sizeLclosure(n), NULL, 0)->cl;
c->l.isC = 0;
Closure *c = &luaC_newobj(L, LUA_TLCL, sizeLclosure(n), NULL, 0)->cl;
c->l.p = p;
c->l.nupvalues = cast_byte(n);
while (n--) c->l.upvals[n] = NULL;
@@ -146,13 +144,6 @@ void luaF_freeproto (lua_State *L, Proto *f) {
}
void luaF_freeclosure (lua_State *L, Closure *c) {
int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) :
sizeLclosure(c->l.nupvalues);
luaM_freemem(L, c, size);
}
/*
** Look for n-th local variable at line `line' in function `func'.
** Returns NULL if not found.