From d490555ec9d5efb886211f735694d4e7dd0c166d Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 23 Nov 1994 12:32:00 -0200 Subject: garbage collection tag for strings organized in struct TaggedString --- table.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'table.c') diff --git a/table.c b/table.c index cac27add..2a3bb213 100644 --- a/table.c +++ b/table.c @@ -3,7 +3,7 @@ ** Module to control static tables */ -char *rcs_table="$Id: table.c,v 2.21 1994/11/18 19:27:38 roberto Exp roberto $"; +char *rcs_table="$Id: table.c,v 2.22 1994/11/21 21:41:09 roberto Exp roberto $"; #include @@ -17,13 +17,15 @@ char *rcs_table="$Id: table.c,v 2.21 1994/11/18 19:27:38 roberto Exp roberto $"; #include "fallback.h" +#define MAX_WORD 0xFFFD + #define BUFFER_BLOCK 256 Symbol *lua_table; static Word lua_ntable = 0; static Long lua_maxsymbol = 0; -char **lua_constant; +TaggedString **lua_constant; static Word lua_nconstant = 0; static Long lua_maxconstant = 0; @@ -79,7 +81,7 @@ static void lua_initsymbol (void) void lua_initconstant (void) { lua_maxconstant = BUFFER_BLOCK; - lua_constant = newvector(lua_maxconstant, char *); + lua_constant = newvector(lua_maxconstant, TaggedString *); } @@ -92,7 +94,7 @@ int luaI_findsymbol (TreeNode *t) { if (lua_table == NULL) lua_initsymbol(); - if (t->varindex == UNMARKED_STRING) + if (t->varindex == NOT_USED) { if (lua_ntable == lua_maxsymbol) { @@ -124,17 +126,17 @@ int luaI_findconstant (TreeNode *t) { if (lua_constant == NULL) lua_initconstant(); - if (t->constindex == UNMARKED_STRING) + if (t->constindex == NOT_USED) { if (lua_nconstant == lua_maxconstant) { lua_maxconstant *= 2; if (lua_maxconstant > MAX_WORD) lua_error("constant table overflow"); - lua_constant = growvector(lua_constant, lua_maxconstant, char*); + lua_constant = growvector(lua_constant, lua_maxconstant, TaggedString *); } t->constindex = lua_nconstant; - lua_constant[lua_nconstant] = t->str; + lua_constant[lua_nconstant] = &(t->ts); lua_nconstant++; } return t->constindex; @@ -157,10 +159,10 @@ void lua_travsymbol (void (*fn)(Object *)) */ void lua_markobject (Object *o) { - if (tag(o) == LUA_T_STRING && indexstring(svalue(o)) == UNMARKED_STRING) - indexstring(svalue(o)) = MARKED_STRING; + if (tag(o) == LUA_T_STRING && !tsvalue(o)->marked) + tsvalue(o)->marked = 1; else if (tag(o) == LUA_T_ARRAY) - lua_hashmark (avalue(o)); + lua_hashmark (avalue(o)); } @@ -247,7 +249,7 @@ static void lua_nextvar (void) { Object name; tag(&name) = LUA_T_STRING; - svalue(&name) = next->str; + tsvalue(&name) = &(next->ts); luaI_pushobject(&name); luaI_pushobject(&s_object(next->varindex)); } -- cgit v1.2.3-55-g6feb