From a580480b07cdf7201306b246deeb2fe84f2c25a9 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 26 Sep 1997 12:02:26 -0300 Subject: new implementation for globals: Global value is stored in TaggedString --- lglobal.c | 71 --------------------------------------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 lglobal.c (limited to 'lglobal.c') diff --git a/lglobal.c b/lglobal.c deleted file mode 100644 index 9f2b9f90..00000000 --- a/lglobal.c +++ /dev/null @@ -1,71 +0,0 @@ -/* -** $Id: $ -** Global variables -** See Copyright Notice in lua.h -*/ - -#include - -#include "lbuiltin.h" -#include "lglobal.h" -#include "lmem.h" -#include "lobject.h" -#include "lstring.h" - - -Symbol *luaG_global = NULL; -int luaG_nglobal = 0; -static int maxglobal = 0; - - - -Word luaG_findsymbol (TaggedString *t) -{ - if (maxglobal == 0) { /* first time? */ - maxglobal = 50; - luaG_global = luaM_newvector(maxglobal, Symbol); - luaB_predefine(); - } - if (t->u.s.varindex == NOT_USED) { - if (!t->marked) t->marked = 2; /* avoid GC of global variable names */ - if (luaG_nglobal >= maxglobal) - maxglobal = luaM_growvector(&luaG_global, maxglobal, Symbol, - symbolEM, MAX_WORD); - t->u.s.varindex = luaG_nglobal; - luaG_global[luaG_nglobal].varname = t; - s_ttype(luaG_nglobal) = LUA_T_NIL; - luaG_nglobal++; - } - return t->u.s.varindex; -} - - -Word luaG_findsymbolbyname (char *name) -{ - return luaG_findsymbol(luaS_new(name)); -} - - -int luaG_globaldefined (char *name) -{ - return s_ttype(luaG_findsymbolbyname(name)) != LUA_T_NIL; -} - - -int luaG_nextvar (Word next) -{ - while (next < luaG_nglobal && s_ttype(next) == LUA_T_NIL) - next++; - return (next < luaG_nglobal ? next : -1); -} - - -char *luaG_travsymbol (int (*fn)(TObject *)) -{ - int i; - for (i=0; istr; - return NULL; -} - -- cgit v1.2.3-55-g6feb