aboutsummaryrefslogtreecommitdiff
path: root/table.c
diff options
context:
space:
mode:
Diffstat (limited to 'table.c')
-rw-r--r--table.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/table.c b/table.c
index 587d582d..29d877c2 100644
--- a/table.c
+++ b/table.c
@@ -3,7 +3,7 @@
3** Module to control static tables 3** Module to control static tables
4*/ 4*/
5 5
6char *rcs_table="$Id: table.c,v 2.43 1996/01/26 14:04:32 roberto Exp roberto $"; 6char *rcs_table="$Id: table.c,v 2.44 1996/01/26 18:03:19 roberto Exp $";
7 7
8/*#include <string.h>*/ 8/*#include <string.h>*/
9 9
@@ -85,7 +85,7 @@ void lua_initconstant (void)
85** Given a name, search it at symbol table and return its index. If not 85** Given a name, search it at symbol table and return its index. If not
86** found, allocate it. 86** found, allocate it.
87*/ 87*/
88Word luaI_findsymbol (TreeNode *t) 88Word luaI_findsymbol (TaggedString *t)
89{ 89{
90 if (lua_table == NULL) 90 if (lua_table == NULL)
91 lua_initsymbol(); 91 lua_initsymbol();
@@ -111,7 +111,7 @@ Word luaI_findsymbol (TreeNode *t)
111 111
112Word luaI_findsymbolbyname (char *name) 112Word luaI_findsymbolbyname (char *name)
113{ 113{
114 return luaI_findsymbol(lua_constcreate(name)); 114 return luaI_findsymbol(luaI_createfixedstring(name));
115} 115}
116 116
117 117
@@ -119,7 +119,7 @@ Word luaI_findsymbolbyname (char *name)
119** Given a tree node, check it is has a correspondent constant index. If not, 119** Given a tree node, check it is has a correspondent constant index. If not,
120** allocate it. 120** allocate it.
121*/ 121*/
122Word luaI_findconstant (TreeNode *t) 122Word luaI_findconstant (TaggedString *t)
123{ 123{
124 if (lua_constant == NULL) 124 if (lua_constant == NULL)
125 lua_initconstant(); 125 lua_initconstant();
@@ -135,7 +135,7 @@ Word luaI_findconstant (TreeNode *t)
135 lua_constant = growvector(lua_constant, lua_maxconstant, TaggedString *); 135 lua_constant = growvector(lua_constant, lua_maxconstant, TaggedString *);
136 } 136 }
137 t->constindex = lua_nconstant; 137 t->constindex = lua_nconstant;
138 lua_constant[lua_nconstant] = &(t->ts); 138 lua_constant[lua_nconstant] = t;
139 lua_nconstant++; 139 lua_nconstant++;
140 } 140 }
141 return t->constindex; 141 return t->constindex;
@@ -144,7 +144,13 @@ Word luaI_findconstant (TreeNode *t)
144 144
145Word luaI_findconstantbyname (char *name) 145Word luaI_findconstantbyname (char *name)
146{ 146{
147 return luaI_findconstant(lua_constcreate(name)); 147 return luaI_findconstant(luaI_createfixedstring(name));
148}
149
150TaggedString *lua_constcreate(char *name)
151{
152 int i = luaI_findconstantbyname(name);
153 return lua_constant[i];
148} 154}
149 155
150 156
@@ -156,7 +162,7 @@ static char *lua_travsymbol (int (*fn)(Object *))
156 Word i; 162 Word i;
157 for (i=0; i<lua_ntable; i++) 163 for (i=0; i<lua_ntable; i++)
158 if (fn(&s_object(i))) 164 if (fn(&s_object(i)))
159 return lua_table[i].varname->ts.str; 165 return lua_table[i].varname->str;
160 return NULL; 166 return NULL;
161} 167}
162 168
@@ -165,7 +171,7 @@ static char *lua_travsymbol (int (*fn)(Object *))
165** Mark an object if it is a string or a unmarked array. 171** Mark an object if it is a string or a unmarked array.
166*/ 172*/
167int lua_markobject (Object *o) 173int lua_markobject (Object *o)
168{ 174{/* if already marked, does not change mark value */
169 if (tag(o) == LUA_T_STRING && !tsvalue(o)->marked) 175 if (tag(o) == LUA_T_STRING && !tsvalue(o)->marked)
170 tsvalue(o)->marked = 1; 176 tsvalue(o)->marked = 1;
171 else if (tag(o) == LUA_T_ARRAY) 177 else if (tag(o) == LUA_T_ARRAY)
@@ -235,10 +241,10 @@ static void lua_nextvar (void)
235 } 241 }
236 else 242 else
237 { 243 {
238 TreeNode *t = lua_table[next].varname; 244 TaggedString *t = lua_table[next].varname;
239 Object name; 245 Object name;
240 tag(&name) = LUA_T_STRING; 246 tag(&name) = LUA_T_STRING;
241 tsvalue(&name) = &(t->ts); 247 tsvalue(&name) = t;
242 luaI_pushobject(&name); 248 luaI_pushobject(&name);
243 luaI_pushobject(&s_object(next)); 249 luaI_pushobject(&s_object(next));
244 } 250 }