浏览代码

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

Roberto Ierusalimschy 28 年之前
父节点
当前提交
03160920cf
共有 2 个文件被更改,包括 7 次插入8 次删除
  1. 6 6
      lapi.c
  2. 1 2
      lstate.h

+ 6 - 6
lapi.c

@@ -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
 ** 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)
 {
-    return (o->ttype == LUA_T_FUNCTION) &&
-           ((L->functofind->ttype == LUA_T_FUNCTION) ||
-            (L->functofind->ttype == LUA_T_MARK)) &&
-           (L->functofind->value.cl == o->value.cl);
+  return o->ttype == LUA_T_FUNCTION &&
+         (ttype(L->stack.top) == LUA_T_FUNCTION ||
+          ttype(L->stack.top) == LUA_T_MARK) &&
+         clvalue(L->stack.top) == o->value.cl;
 }
 
 
 char *lua_getobjname (lua_Object o, char **name)
 { /* 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)
     return "tag-method";
   else if ((*name = luaS_travsymbol(checkfunc)) != NULL)

+ 1 - 2
lstate.h

@@ -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
 ** See Copyright Notice in lua.h
 */
@@ -51,7 +51,6 @@ typedef struct LState {
   TObject errorim;  /* error tag method */
   struct C_Lua_Stack Cblocks[MAX_C_BLOCKS];
   int numCblocks;  /* number of nested Cblocks */
-  TObject *functofind;  /* auxiliar */
   GCnode rootproto;  /* list of all prototypes */
   GCnode rootcl;  /* list of all closures */
   GCnode roottable;  /* list of all tables */