mirror of
https://github.com/lua/lua
synced 2025-02-23 00:24:04 +03:00
"global" version of a nil object.
This commit is contained in:
parent
b7567b6673
commit
7135803cc8
15
lgc.c
15
lgc.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lgc.c,v 1.5 1997/10/23 16:26:37 roberto Exp roberto $
|
||||
** $Id: lgc.c,v 1.6 1997/10/24 17:17:24 roberto Exp roberto $
|
||||
** Garbage Collector
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -66,9 +66,8 @@ void lua_unref (int ref)
|
||||
|
||||
TObject* luaC_getref (int ref)
|
||||
{
|
||||
static TObject nul = {LUA_T_NIL, {0}};
|
||||
if (ref == -1)
|
||||
return &nul;
|
||||
return &luaO_nilobject;
|
||||
if (ref >= 0 && ref < refSize &&
|
||||
(refArray[ref].status == LOCK || refArray[ref].status == HOLD))
|
||||
return &refArray[ref].o;
|
||||
@ -240,14 +239,6 @@ static int markobject (TObject *o)
|
||||
}
|
||||
|
||||
|
||||
static void call_nilIM (void)
|
||||
{ /* signals end of garbage collection */
|
||||
TObject t;
|
||||
ttype(&t) = LUA_T_NIL;
|
||||
luaD_gcIM(&t); /* end of list */
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define GARBAGE_BLOCK 150
|
||||
|
||||
@ -279,7 +270,7 @@ long lua_collectgarbage (long limit)
|
||||
luaC_threshold *= 4; /* to avoid GC during GC */
|
||||
hashcallIM(freetable); /* GC tag methods for tables */
|
||||
strcallIM(freestr); /* GC tag methods for userdata */
|
||||
call_nilIM(); /* GC tag method for nil (signal end of GC) */
|
||||
luaD_gcIM(&luaO_nilobject); /* GC tag method for nil (signal end of GC) */
|
||||
luaH_free(freetable);
|
||||
luaS_free(freestr);
|
||||
luaF_freeproto(freefunc);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lobject.c,v 1.4 1997/10/23 16:26:37 roberto Exp roberto $
|
||||
** $Id: lobject.c,v 1.5 1997/10/24 17:17:24 roberto Exp roberto $
|
||||
** Some generic functions over Lua objects
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -17,6 +17,10 @@ char *luaO_typenames[] = { /* ORDER LUA_T */
|
||||
};
|
||||
|
||||
|
||||
TObject luaO_nilobject = {LUA_T_NIL, {NULL}};
|
||||
|
||||
|
||||
|
||||
unsigned long luaO_nblocks = 0;
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lobject.h,v 1.6 1997/10/23 16:26:37 roberto Exp roberto $
|
||||
** $Id: lobject.h,v 1.7 1997/10/24 17:17:24 roberto Exp roberto $
|
||||
** Type definitions for Lua objects
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -166,6 +166,8 @@ extern unsigned long luaO_nblocks;
|
||||
|
||||
extern char *luaO_typenames[];
|
||||
|
||||
extern TObject luaO_nilobject;
|
||||
|
||||
int luaO_equalObj (TObject *t1, TObject *t2);
|
||||
int luaO_redimension (int oldsize);
|
||||
int luaO_findstring (char *name, char *list[]);
|
||||
|
4
ltm.c
4
ltm.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ltm.c,v 1.3 1997/10/16 20:07:40 roberto Exp roberto $
|
||||
** $Id: ltm.c,v 1.4 1997/10/24 17:17:24 roberto Exp roberto $
|
||||
** Tag methods
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -168,7 +168,7 @@ TObject *luaT_gettagmethod (int t, char *event)
|
||||
if (validevent(t, e))
|
||||
return luaT_getim(t,e);
|
||||
else
|
||||
return luaT_getim(LUA_T_NUMBER, IM_ADD); /* always nil */
|
||||
return &luaO_nilobject;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user