store "functofind" in stack top, so doesn't need this field in

global state.
This commit is contained in:
Roberto Ierusalimschy
1997-11-28 14:56:05 -02:00
parent b42cc6a4d2
commit 03160920cf
2 changed files with 7 additions and 8 deletions

12
lapi.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lapi.c,v 1.9 1997/11/27 15:59:25 roberto Exp roberto $ ** $Id: lapi.c,v 1.10 1997/11/27 18:25:14 roberto Exp roberto $
** Lua API ** Lua API
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -463,16 +463,16 @@ void lua_funcinfo (lua_Object func, char **filename, int *linedefined)
static int checkfunc (TObject *o) static int checkfunc (TObject *o)
{ {
return (o->ttype == LUA_T_FUNCTION) && return o->ttype == LUA_T_FUNCTION &&
((L->functofind->ttype == LUA_T_FUNCTION) || (ttype(L->stack.top) == LUA_T_FUNCTION ||
(L->functofind->ttype == LUA_T_MARK)) && ttype(L->stack.top) == LUA_T_MARK) &&
(L->functofind->value.cl == o->value.cl); clvalue(L->stack.top) == o->value.cl;
} }
char *lua_getobjname (lua_Object o, char **name) char *lua_getobjname (lua_Object o, char **name)
{ /* try to find a name for given function */ { /* try to find a name for given function */
L->functofind = Address(o); *(L->stack.top) = *Address(o); /* to be accessed by "checkfunc */
if ((*name = luaT_travtagmethods(checkfunc)) != NULL) if ((*name = luaT_travtagmethods(checkfunc)) != NULL)
return "tag-method"; return "tag-method";
else if ((*name = luaS_travsymbol(checkfunc)) != NULL) else if ((*name = luaS_travsymbol(checkfunc)) != NULL)

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lstate.h,v 1.3 1997/11/26 20:28:22 roberto Exp roberto $ ** $Id: lstate.h,v 1.4 1997/11/27 15:59:25 roberto Exp roberto $
** Global State ** Global State
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -51,7 +51,6 @@ typedef struct LState {
TObject errorim; /* error tag method */ TObject errorim; /* error tag method */
struct C_Lua_Stack Cblocks[MAX_C_BLOCKS]; struct C_Lua_Stack Cblocks[MAX_C_BLOCKS];
int numCblocks; /* number of nested Cblocks */ int numCblocks; /* number of nested Cblocks */
TObject *functofind; /* auxiliar */
GCnode rootproto; /* list of all prototypes */ GCnode rootproto; /* list of all prototypes */
GCnode rootcl; /* list of all closures */ GCnode rootcl; /* list of all closures */
GCnode roottable; /* list of all tables */ GCnode roottable; /* list of all tables */