From d6e4c29733b43130c5222c49b3c4b9dfcd8bb893 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 26 Feb 1996 18:00:27 -0300 Subject: [PATCH] fixed strings (not collectable) don't need to be inserted in the constant table. --- inout.c | 6 +++--- lua.stx | 4 ++-- table.c | 36 +++++++++++++++++------------------- table.h | 4 ++-- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/inout.c b/inout.c index 7959068f..fe799e93 100644 --- a/inout.c +++ b/inout.c @@ -5,7 +5,7 @@ ** Also provides some predefined lua functions. */ -char *rcs_inout="$Id: inout.c,v 2.31 1996/02/13 17:30:39 roberto Exp roberto $"; +char *rcs_inout="$Id: inout.c,v 2.32 1996/02/14 18:25:04 roberto Exp roberto $"; #include #include @@ -66,7 +66,7 @@ int lua_openfile (char *fn) if (fp == NULL) return 1; lua_linenumber = 1; - lua_parsedfile = lua_constcreate(fn)->str; + lua_parsedfile = luaI_createfixedstring(fn)->str; return 0; } @@ -90,7 +90,7 @@ void lua_openstring (char *s) lua_setinput (stringinput); st = s; lua_linenumber = 1; - lua_parsedfile = lua_constcreate("(string)")->str; + lua_parsedfile = luaI_createfixedstring("(string)")->str; } /* diff --git a/lua.stx b/lua.stx index 878a691e..b201d6e3 100644 --- a/lua.stx +++ b/lua.stx @@ -1,6 +1,6 @@ %{ -char *rcs_luastx = "$Id: lua.stx,v 3.32 1996/02/14 18:25:04 roberto Exp roberto $"; +char *rcs_luastx = "$Id: lua.stx,v 3.33 1996/02/26 17:07:20 roberto Exp roberto $"; #include #include @@ -487,7 +487,7 @@ funcname : var { $$ =$1; init_func(); } code_word(luaI_findconstant($3)); $$ = 0; /* indexed variable */ init_func(); - add_localvar(lua_constcreate("self")); + add_localvar(luaI_createfixedstring("self")); } ; diff --git a/table.c b/table.c index 722f8b17..bd6e805b 100644 --- a/table.c +++ b/table.c @@ -3,7 +3,7 @@ ** Module to control static tables */ -char *rcs_table="$Id: table.c,v 2.46 1996/02/14 13:35:51 roberto Exp roberto $"; +char *rcs_table="$Id: table.c,v 2.47 1996/02/14 18:25:04 roberto Exp roberto $"; #include "mem.h" #include "opcode.h" @@ -39,19 +39,19 @@ static struct { char *name; lua_CFunction func; } int_funcs[] = { - {"nextvar", lua_nextvar}, + {"assert", luaI_assert}, + {"dofile", lua_internaldofile}, + {"dostring", lua_internaldostring}, {"error", luaI_error}, - {"tonumber", lua_obj2number}, - {"setfallback", luaI_setfallback}, + {"getglobal", luaI_getglobal}, {"next", lua_next}, - {"dofile", lua_internaldofile}, + {"nextvar", lua_nextvar}, + {"print", luaI_print}, + {"setfallback", luaI_setfallback}, {"setglobal", luaI_setglobal}, - {"getglobal", luaI_getglobal}, - {"type", luaI_type}, + {"tonumber", lua_obj2number}, {"tostring", luaI_tostring}, - {"print", luaI_print}, - {"dostring", lua_internaldostring}, - {"assert", luaI_assert} + {"type", luaI_type} }; #define INTFUNCSIZE (sizeof(int_funcs)/sizeof(int_funcs[0])) @@ -100,8 +100,6 @@ Word luaI_findsymbol (TaggedString *t) lua_table[lua_ntable].varname = t; s_tag(lua_ntable) = LUA_T_NIL; lua_ntable++; - if (!t->marked) - t->marked = 2; /* avoid GC */ } return t->varindex; } @@ -109,7 +107,7 @@ Word luaI_findsymbol (TaggedString *t) Word luaI_findsymbolbyname (char *name) { - return luaI_findsymbol(lua_createstring(name)); + return luaI_findsymbol(luaI_createfixedstring(name)); } @@ -133,8 +131,6 @@ Word luaI_findconstant (TaggedString *t) t->constindex = lua_nconstant; lua_constant[lua_nconstant] = t; lua_nconstant++; - if (!t->marked) - t->marked = 2; /* avoid GC */ } return t->constindex; } @@ -142,13 +138,15 @@ Word luaI_findconstant (TaggedString *t) Word luaI_findconstantbyname (char *name) { - return luaI_findconstant(lua_createstring(name)); + return luaI_findconstant(luaI_createfixedstring(name)); } -TaggedString *lua_constcreate(char *name) +TaggedString *luaI_createfixedstring (char *name) { - int i = luaI_findconstantbyname(name); - return lua_constant[i]; + TaggedString *ts = lua_createstring(name); + if (!ts->marked) + ts->marked = 2; /* avoid GC */ + return ts; } diff --git a/table.h b/table.h index 6b4b9d3d..6360f102 100644 --- a/table.h +++ b/table.h @@ -1,7 +1,7 @@ /* ** Module to control static tables ** TeCGraf - PUC-Rio -** $Id: table.h,v 2.17 1996/02/12 18:32:40 roberto Exp roberto $ +** $Id: table.h,v 2.18 1996/02/14 13:35:51 roberto Exp roberto $ */ #ifndef table_h @@ -26,7 +26,7 @@ Word luaI_findsymbolbyname (char *name); Word luaI_findsymbol (TaggedString *t); Word luaI_findconstant (TaggedString *t); Word luaI_findconstantbyname (char *name); -TaggedString *lua_constcreate (char *str); +TaggedString *luaI_createfixedstring (char *str); int lua_markobject (Object *o); Long luaI_collectgarbage (void); void lua_pack (void);