diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-03-11 15:44:28 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-03-11 15:44:28 -0300 |
commit | b6d91e24e23edfe98ad732660fd456e91658edb9 (patch) | |
tree | a66fb8348758f32df6c5d5ab1af1aece2a63009f | |
parent | a82ab0852eaca43cb56be5134833c97e6bb7ac98 (diff) | |
download | lua-b6d91e24e23edfe98ad732660fd456e91658edb9.tar.gz lua-b6d91e24e23edfe98ad732660fd456e91658edb9.tar.bz2 lua-b6d91e24e23edfe98ad732660fd456e91658edb9.zip |
"tag" changed to "ttype" (since now tag has other meaning)
-rw-r--r-- | fallback.c | 14 | ||||
-rw-r--r-- | func.c | 4 | ||||
-rw-r--r-- | hash.c | 29 | ||||
-rw-r--r-- | inout.c | 6 | ||||
-rw-r--r-- | opcode.c | 149 | ||||
-rw-r--r-- | opcode.h | 8 | ||||
-rw-r--r-- | table.c | 25 |
7 files changed, 119 insertions, 116 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_fallback="$Id: fallback.c,v 1.25 1996/04/25 14:10:00 roberto Exp roberto $"; | 6 | char *rcs_fallback="$Id: fallback.c,v 1.26 1997/02/26 17:38:41 roberto Unstable roberto $"; |
7 | 7 | ||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <string.h> | 9 | #include <string.h> |
@@ -132,7 +132,7 @@ int luaI_ref (Object *object, int lock) | |||
132 | { | 132 | { |
133 | int i; | 133 | int i; |
134 | int oldSize; | 134 | int oldSize; |
135 | if (tag(object) == LUA_T_NIL) | 135 | if (ttype(object) == LUA_T_NIL) |
136 | return -1; /* special ref for nil */ | 136 | return -1; /* special ref for nil */ |
137 | for (i=0; i<refSize; i++) | 137 | for (i=0; i<refSize; i++) |
138 | if (refArray[i].status == FREE) | 138 | if (refArray[i].status == FREE) |
@@ -223,7 +223,7 @@ int lua_newtag (char *t) | |||
223 | else | 223 | else |
224 | lua_error("invalid type for new tag"); | 224 | lua_error("invalid type for new tag"); |
225 | for (i=0; i<FB_N; i++) | 225 | for (i=0; i<FB_N; i++) |
226 | luaI_IMtable[last_tag-BASE_TAG].int_method[i].tag = LUA_T_NIL; | 226 | luaI_IMtable[last_tag-BASE_TAG].int_method[i].ttype = LUA_T_NIL; |
227 | return last_tag; | 227 | return last_tag; |
228 | } | 228 | } |
229 | 229 | ||
@@ -241,9 +241,9 @@ static void checktag (int tag) | |||
241 | void luaI_settag (int tag, Object *o) | 241 | void luaI_settag (int tag, Object *o) |
242 | { | 242 | { |
243 | checktag(tag); | 243 | checktag(tag); |
244 | if (tag(o) != luaI_IMtable[tag-BASE_TAG].tp) | 244 | if (ttype(o) != luaI_IMtable[tag-BASE_TAG].tp) |
245 | lua_error("Tag is not compatible with this type"); | 245 | lua_error("Tag is not compatible with this type"); |
246 | if (o->tag == LUA_T_ARRAY) | 246 | if (o->ttype == LUA_T_ARRAY) |
247 | o->value.a->htag = tag; | 247 | o->value.a->htag = tag; |
248 | else /* must be userdata */ | 248 | else /* must be userdata */ |
249 | o->value.ts->tag = tag; | 249 | o->value.ts->tag = tag; |
@@ -251,7 +251,7 @@ void luaI_settag (int tag, Object *o) | |||
251 | 251 | ||
252 | int luaI_tag (Object *o) | 252 | int luaI_tag (Object *o) |
253 | { | 253 | { |
254 | lua_Type t = tag(o); | 254 | lua_Type t = ttype(o); |
255 | if (t == LUA_T_USERDATA) | 255 | if (t == LUA_T_USERDATA) |
256 | return o->value.ts->tag; | 256 | return o->value.ts->tag; |
257 | else if (t == LUA_T_ARRAY) | 257 | else if (t == LUA_T_ARRAY) |
@@ -265,7 +265,7 @@ Object *luaI_getim (int tag, int event) | |||
265 | return &luaI_fallBacks[event].function; | 265 | return &luaI_fallBacks[event].function; |
266 | else if (validtag(tag)) { | 266 | else if (validtag(tag)) { |
267 | Object *func = &luaI_IMtable[tag-BASE_TAG].int_method[event]; | 267 | Object *func = &luaI_IMtable[tag-BASE_TAG].int_method[event]; |
268 | if (func->tag == LUA_T_NIL) | 268 | if (func->ttype == LUA_T_NIL) |
269 | return NULL; | 269 | return NULL; |
270 | else | 270 | else |
271 | return func; | 271 | return func; |
@@ -84,12 +84,12 @@ Long luaI_funccollector (void) | |||
84 | void lua_funcinfo (lua_Object func, char **filename, int *linedefined) | 84 | void lua_funcinfo (lua_Object func, char **filename, int *linedefined) |
85 | { | 85 | { |
86 | Object *f = luaI_Address(func); | 86 | Object *f = luaI_Address(func); |
87 | if (f->tag == LUA_T_MARK || f->tag == LUA_T_FUNCTION) | 87 | if (f->ttype == LUA_T_MARK || f->ttype == LUA_T_FUNCTION) |
88 | { | 88 | { |
89 | *filename = f->value.tf->fileName; | 89 | *filename = f->value.tf->fileName; |
90 | *linedefined = f->value.tf->lineDefined; | 90 | *linedefined = f->value.tf->lineDefined; |
91 | } | 91 | } |
92 | else if (f->tag == LUA_T_CMARK || f->tag == LUA_T_CFUNCTION) | 92 | else if (f->ttype == LUA_T_CMARK || f->ttype == LUA_T_CFUNCTION) |
93 | { | 93 | { |
94 | *filename = "(C)"; | 94 | *filename = "(C)"; |
95 | *linedefined = -1; | 95 | *linedefined = -1; |
@@ -3,7 +3,7 @@ | |||
3 | ** hash manager for lua | 3 | ** hash manager for lua |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_hash="$Id: hash.c,v 2.33 1997/02/11 11:35:05 roberto Exp roberto $"; | 6 | char *rcs_hash="$Id: hash.c,v 2.34 1997/02/26 17:38:41 roberto Unstable roberto $"; |
7 | 7 | ||
8 | 8 | ||
9 | #include "mem.h" | 9 | #include "mem.h" |
@@ -51,7 +51,7 @@ int luaI_redimension (int nhash) | |||
51 | static int hashindex (Hash *t, Object *ref) /* hash function */ | 51 | static int hashindex (Hash *t, Object *ref) /* hash function */ |
52 | { | 52 | { |
53 | long int h; | 53 | long int h; |
54 | switch (tag(ref)) { | 54 | switch (ttype(ref)) { |
55 | case LUA_T_NUMBER: | 55 | case LUA_T_NUMBER: |
56 | h = (long int)nvalue(ref); break; | 56 | h = (long int)nvalue(ref); break; |
57 | case LUA_T_STRING: case LUA_T_USERDATA: | 57 | case LUA_T_STRING: case LUA_T_USERDATA: |
@@ -72,8 +72,8 @@ static int hashindex (Hash *t, Object *ref) /* hash function */ | |||
72 | 72 | ||
73 | int lua_equalObj (Object *t1, Object *t2) | 73 | int lua_equalObj (Object *t1, Object *t2) |
74 | { | 74 | { |
75 | if (tag(t1) != tag(t2)) return 0; | 75 | if (ttype(t1) != ttype(t2)) return 0; |
76 | switch (tag(t1)) | 76 | switch (ttype(t1)) |
77 | { | 77 | { |
78 | case LUA_T_NIL: return 1; | 78 | case LUA_T_NIL: return 1; |
79 | case LUA_T_NUMBER: return nvalue(t1) == nvalue(t2); | 79 | case LUA_T_NUMBER: return nvalue(t1) == nvalue(t2); |
@@ -90,7 +90,7 @@ int lua_equalObj (Object *t1, Object *t2) | |||
90 | static int present (Hash *t, Object *ref) | 90 | static int present (Hash *t, Object *ref) |
91 | { | 91 | { |
92 | int h = hashindex(t, ref); | 92 | int h = hashindex(t, ref); |
93 | while (tag(ref(node(t, h))) != LUA_T_NIL) | 93 | while (ttype(ref(node(t, h))) != LUA_T_NIL) |
94 | { | 94 | { |
95 | if (lua_equalObj(ref, ref(node(t, h)))) | 95 | if (lua_equalObj(ref, ref(node(t, h)))) |
96 | return h; | 96 | return h; |
@@ -108,7 +108,7 @@ static Node *hashnodecreate (int nhash) | |||
108 | int i; | 108 | int i; |
109 | Node *v = newvector (nhash, Node); | 109 | Node *v = newvector (nhash, Node); |
110 | for (i=0; i<nhash; i++) | 110 | for (i=0; i<nhash; i++) |
111 | tag(ref(&v[i])) = LUA_T_NIL; | 111 | ttype(ref(&v[i])) = LUA_T_NIL; |
112 | return v; | 112 | return v; |
113 | } | 113 | } |
114 | 114 | ||
@@ -149,7 +149,7 @@ void lua_hashmark (Hash *h) | |||
149 | for (i=0; i<nhash(h); i++) | 149 | for (i=0; i<nhash(h); i++) |
150 | { | 150 | { |
151 | Node *n = node(h,i); | 151 | Node *n = node(h,i); |
152 | if (tag(ref(n)) != LUA_T_NIL) | 152 | if (ttype(ref(n)) != LUA_T_NIL) |
153 | { | 153 | { |
154 | lua_markobject(&n->ref); | 154 | lua_markobject(&n->ref); |
155 | lua_markobject(&n->val); | 155 | lua_markobject(&n->val); |
@@ -163,14 +163,14 @@ static void call_fallbacks (void) | |||
163 | { | 163 | { |
164 | Hash *curr_array; | 164 | Hash *curr_array; |
165 | Object t; | 165 | Object t; |
166 | tag(&t) = LUA_T_ARRAY; | 166 | ttype(&t) = LUA_T_ARRAY; |
167 | for (curr_array = listhead; curr_array; curr_array = curr_array->next) | 167 | for (curr_array = listhead; curr_array; curr_array = curr_array->next) |
168 | if (markarray(curr_array) != 1) | 168 | if (markarray(curr_array) != 1) |
169 | { | 169 | { |
170 | avalue(&t) = curr_array; | 170 | avalue(&t) = curr_array; |
171 | luaI_gcFB(&t); | 171 | luaI_gcFB(&t); |
172 | } | 172 | } |
173 | tag(&t) = LUA_T_NIL; | 173 | ttype(&t) = LUA_T_NIL; |
174 | luaI_gcFB(&t); /* end of list */ | 174 | luaI_gcFB(&t); /* end of list */ |
175 | } | 175 | } |
176 | 176 | ||
@@ -235,7 +235,7 @@ static void rehash (Hash *t) | |||
235 | for (i=0; i<nold; i++) | 235 | for (i=0; i<nold; i++) |
236 | { | 236 | { |
237 | Node *n = vold+i; | 237 | Node *n = vold+i; |
238 | if (tag(ref(n)) != LUA_T_NIL && tag(val(n)) != LUA_T_NIL) | 238 | if (ttype(ref(n)) != LUA_T_NIL && ttype(val(n)) != LUA_T_NIL) |
239 | *node(t, present(t, ref(n))) = *n; /* copy old node to new hahs */ | 239 | *node(t, present(t, ref(n))) = *n; /* copy old node to new hahs */ |
240 | } | 240 | } |
241 | luaI_free(vold); | 241 | luaI_free(vold); |
@@ -248,7 +248,7 @@ static void rehash (Hash *t) | |||
248 | Object *lua_hashget (Hash *t, Object *ref) | 248 | Object *lua_hashget (Hash *t, Object *ref) |
249 | { | 249 | { |
250 | int h = present(t, ref); | 250 | int h = present(t, ref); |
251 | if (tag(ref(node(t, h))) != LUA_T_NIL) return val(node(t, h)); | 251 | if (ttype(ref(node(t, h))) != LUA_T_NIL) return val(node(t, h)); |
252 | else return NULL; | 252 | else return NULL; |
253 | } | 253 | } |
254 | 254 | ||
@@ -263,7 +263,7 @@ Object *lua_hashdefine (Hash *t, Object *ref) | |||
263 | Node *n; | 263 | Node *n; |
264 | h = present(t, ref); | 264 | h = present(t, ref); |
265 | n = node(t, h); | 265 | n = node(t, h); |
266 | if (tag(ref(n)) == LUA_T_NIL) | 266 | if (ttype(ref(n)) == LUA_T_NIL) |
267 | { | 267 | { |
268 | nuse(t)++; | 268 | nuse(t)++; |
269 | if ((float)nuse(t) > (float)nhash(t)*REHASH_LIMIT) | 269 | if ((float)nuse(t) > (float)nhash(t)*REHASH_LIMIT) |
@@ -273,7 +273,7 @@ Object *lua_hashdefine (Hash *t, Object *ref) | |||
273 | n = node(t, h); | 273 | n = node(t, h); |
274 | } | 274 | } |
275 | *ref(n) = *ref; | 275 | *ref(n) = *ref; |
276 | tag(val(n)) = LUA_T_NIL; | 276 | ttype(val(n)) = LUA_T_NIL; |
277 | } | 277 | } |
278 | return (val(n)); | 278 | return (val(n)); |
279 | } | 279 | } |
@@ -289,7 +289,8 @@ static void hashnext (Hash *t, int i) | |||
289 | { | 289 | { |
290 | if (i >= nhash(t)) | 290 | if (i >= nhash(t)) |
291 | return; | 291 | return; |
292 | while (tag(ref(node(t,i))) == LUA_T_NIL || tag(val(node(t,i))) == LUA_T_NIL) | 292 | while (ttype(ref(node(t,i))) == LUA_T_NIL || |
293 | ttype(val(node(t,i))) == LUA_T_NIL) | ||
293 | { | 294 | { |
294 | if (++i >= nhash(t)) | 295 | if (++i >= nhash(t)) |
295 | return; | 296 | return; |
@@ -5,7 +5,7 @@ | |||
5 | ** Also provides some predefined lua functions. | 5 | ** Also provides some predefined lua functions. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | char *rcs_inout="$Id: inout.c,v 2.43 1996/09/25 12:57:22 roberto Exp roberto $"; | 8 | char *rcs_inout="$Id: inout.c,v 2.44 1997/02/26 17:38:41 roberto Unstable roberto $"; |
9 | 9 | ||
10 | #include <stdio.h> | 10 | #include <stdio.h> |
11 | #include <string.h> | 11 | #include <string.h> |
@@ -368,10 +368,10 @@ void luaI_predefine (void) | |||
368 | Word n; | 368 | Word n; |
369 | for (i=0; i<INTFUNCSIZE; i++) { | 369 | for (i=0; i<INTFUNCSIZE; i++) { |
370 | n = luaI_findsymbolbyname(int_funcs[i].name); | 370 | n = luaI_findsymbolbyname(int_funcs[i].name); |
371 | s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = int_funcs[i].func; | 371 | s_ttype(n) = LUA_T_CFUNCTION; s_fvalue(n) = int_funcs[i].func; |
372 | } | 372 | } |
373 | n = luaI_findsymbolbyname("_VERSION_"); | 373 | n = luaI_findsymbolbyname("_VERSION_"); |
374 | s_tag(n) = LUA_T_STRING; s_tsvalue(n) = lua_createstring(LUA_VERSION); | 374 | s_ttype(n) = LUA_T_STRING; s_tsvalue(n) = lua_createstring(LUA_VERSION); |
375 | } | 375 | } |
376 | 376 | ||
377 | 377 | ||
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_opcode="$Id: opcode.c,v 3.82 1997/02/26 17:38:41 roberto Unstable roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.83 1997/03/06 17:30:55 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
9 | #include <stdio.h> | 9 | #include <stdio.h> |
@@ -20,8 +20,8 @@ char *rcs_opcode="$Id: opcode.c,v 3.82 1997/02/26 17:38:41 roberto Unstable robe | |||
20 | #include "fallback.h" | 20 | #include "fallback.h" |
21 | #include "undump.h" | 21 | #include "undump.h" |
22 | 22 | ||
23 | #define tonumber(o) ((tag(o) != LUA_T_NUMBER) && (lua_tonumber(o) != 0)) | 23 | #define tonumber(o) ((ttype(o) != LUA_T_NUMBER) && (lua_tonumber(o) != 0)) |
24 | #define tostring(o) ((tag(o) != LUA_T_STRING) && (lua_tostring(o) != 0)) | 24 | #define tostring(o) ((ttype(o) != LUA_T_STRING) && (lua_tostring(o) != 0)) |
25 | 25 | ||
26 | 26 | ||
27 | #define STACK_SIZE 128 | 27 | #define STACK_SIZE 128 |
@@ -138,12 +138,12 @@ static int lua_tonumber (Object *obj) | |||
138 | { | 138 | { |
139 | float t; | 139 | float t; |
140 | char c; | 140 | char c; |
141 | if (tag(obj) != LUA_T_STRING) | 141 | if (ttype(obj) != LUA_T_STRING) |
142 | return 1; | 142 | return 1; |
143 | else if (sscanf(svalue(obj), "%f %c",&t, &c) == 1) | 143 | else if (sscanf(svalue(obj), "%f %c",&t, &c) == 1) |
144 | { | 144 | { |
145 | nvalue(obj) = t; | 145 | nvalue(obj) = t; |
146 | tag(obj) = LUA_T_NUMBER; | 146 | ttype(obj) = LUA_T_NUMBER; |
147 | return 0; | 147 | return 0; |
148 | } | 148 | } |
149 | else | 149 | else |
@@ -152,12 +152,12 @@ static int lua_tonumber (Object *obj) | |||
152 | 152 | ||
153 | 153 | ||
154 | /* | 154 | /* |
155 | ** Convert, if possible, to a string tag | 155 | ** Convert, if possible, to a string ttype |
156 | ** Return 0 in success or not 0 on error. | 156 | ** Return 0 in success or not 0 on error. |
157 | */ | 157 | */ |
158 | static int lua_tostring (Object *obj) | 158 | static int lua_tostring (Object *obj) |
159 | { | 159 | { |
160 | if (tag(obj) != LUA_T_NUMBER) | 160 | if (ttype(obj) != LUA_T_NUMBER) |
161 | return 1; | 161 | return 1; |
162 | else { | 162 | else { |
163 | char s[60]; | 163 | char s[60]; |
@@ -168,7 +168,7 @@ static int lua_tostring (Object *obj) | |||
168 | else | 168 | else |
169 | sprintf (s, "%g", nvalue(obj)); | 169 | sprintf (s, "%g", nvalue(obj)); |
170 | tsvalue(obj) = lua_createstring(s); | 170 | tsvalue(obj) = lua_createstring(s); |
171 | tag(obj) = LUA_T_STRING; | 171 | ttype(obj) = LUA_T_STRING; |
172 | return 0; | 172 | return 0; |
173 | } | 173 | } |
174 | } | 174 | } |
@@ -182,7 +182,7 @@ static void adjust_top (StkId newtop) | |||
182 | Object *nt; | 182 | Object *nt; |
183 | lua_checkstack(stack+newtop); | 183 | lua_checkstack(stack+newtop); |
184 | nt = stack+newtop; /* warning: previous call may change stack */ | 184 | nt = stack+newtop; /* warning: previous call may change stack */ |
185 | while (top < nt) tag(top++) = LUA_T_NIL; | 185 | while (top < nt) ttype(top++) = LUA_T_NIL; |
186 | top = nt; /* top could be bigger than newtop */ | 186 | top = nt; /* top could be bigger than newtop */ |
187 | } | 187 | } |
188 | 188 | ||
@@ -289,14 +289,14 @@ static void do_call (StkId base, int nResults) | |||
289 | StkId firstResult; | 289 | StkId firstResult; |
290 | Object *func = stack+base-1; | 290 | Object *func = stack+base-1; |
291 | int i; | 291 | int i; |
292 | if (tag(func) == LUA_T_CFUNCTION) | 292 | if (ttype(func) == LUA_T_CFUNCTION) |
293 | { | 293 | { |
294 | tag(func) = LUA_T_CMARK; | 294 | ttype(func) = LUA_T_CMARK; |
295 | firstResult = callC(fvalue(func), base); | 295 | firstResult = callC(fvalue(func), base); |
296 | } | 296 | } |
297 | else if (tag(func) == LUA_T_FUNCTION) | 297 | else if (ttype(func) == LUA_T_FUNCTION) |
298 | { | 298 | { |
299 | tag(func) = LUA_T_MARK; | 299 | ttype(func) = LUA_T_MARK; |
300 | firstResult = lua_execute(func->value.tf->code, base); | 300 | firstResult = lua_execute(func->value.tf->code, base); |
301 | } | 301 | } |
302 | else | 302 | else |
@@ -327,9 +327,9 @@ static void pushsubscript (void) | |||
327 | { | 327 | { |
328 | int tg = luaI_tag(top-2); | 328 | int tg = luaI_tag(top-2); |
329 | Object *im = luaI_getim(tg, FB_GETTABLE); | 329 | Object *im = luaI_getim(tg, FB_GETTABLE); |
330 | if (tag(top-2) == LUA_T_ARRAY && im == NULL) { | 330 | if (ttype(top-2) == LUA_T_ARRAY && im == NULL) { |
331 | Object *h = lua_hashget(avalue(top-2), top-1); | 331 | Object *h = lua_hashget(avalue(top-2), top-1); |
332 | if (h != NULL && tag(h) != LUA_T_NIL) { | 332 | if (h != NULL && ttype(h) != LUA_T_NIL) { |
333 | --top; | 333 | --top; |
334 | *(top-1) = *h; | 334 | *(top-1) = *h; |
335 | } | 335 | } |
@@ -338,7 +338,7 @@ static void pushsubscript (void) | |||
338 | callIM(im, 2, 1); | 338 | callIM(im, 2, 1); |
339 | else { | 339 | else { |
340 | --top; | 340 | --top; |
341 | tag(top-1) = LUA_T_NIL; | 341 | ttype(top-1) = LUA_T_NIL; |
342 | } | 342 | } |
343 | } | 343 | } |
344 | else { /* object is not a table, and/or has a specific "gettable" method */ | 344 | else { /* object is not a table, and/or has a specific "gettable" method */ |
@@ -353,7 +353,7 @@ static void pushsubscript (void) | |||
353 | lua_Object lua_basicindex (void) | 353 | lua_Object lua_basicindex (void) |
354 | { | 354 | { |
355 | adjustC(2); | 355 | adjustC(2); |
356 | if (tag(top-2) != LUA_T_ARRAY) | 356 | if (ttype(top-2) != LUA_T_ARRAY) |
357 | lua_error("indexed expression not a table in basic indexing"); | 357 | lua_error("indexed expression not a table in basic indexing"); |
358 | else { | 358 | else { |
359 | Object *h = lua_hashget(avalue(top-2), top-1); | 359 | Object *h = lua_hashget(avalue(top-2), top-1); |
@@ -361,7 +361,7 @@ lua_Object lua_basicindex (void) | |||
361 | if (h != NULL) | 361 | if (h != NULL) |
362 | *(top-1) = *h; | 362 | *(top-1) = *h; |
363 | else | 363 | else |
364 | tag(top-1) = LUA_T_NIL; | 364 | ttype(top-1) = LUA_T_NIL; |
365 | } | 365 | } |
366 | CLS_current.base++; /* incorporate object in the stack */ | 366 | CLS_current.base++; /* incorporate object in the stack */ |
367 | return (Ref(top-1)); | 367 | return (Ref(top-1)); |
@@ -377,7 +377,7 @@ lua_Object lua_basicindex (void) | |||
377 | static void storesubscript (Object *t, int mode) | 377 | static void storesubscript (Object *t, int mode) |
378 | { | 378 | { |
379 | Object *im = (mode == 0) ? NULL : luaI_getim(luaI_tag(t), FB_SETTABLE); | 379 | Object *im = (mode == 0) ? NULL : luaI_getim(luaI_tag(t), FB_SETTABLE); |
380 | if (tag(t) == LUA_T_ARRAY && im == NULL) { | 380 | if (ttype(t) == LUA_T_ARRAY && im == NULL) { |
381 | Object *h = lua_hashdefine(avalue(t), t+1); | 381 | Object *h = lua_hashdefine(avalue(t), t+1); |
382 | *h = *(top-1); | 382 | *h = *(top-1); |
383 | top -= (mode == 2) ? 1 : 3; | 383 | top -= (mode == 2) ? 1 : 3; |
@@ -403,9 +403,9 @@ static void getglobal (Word n) | |||
403 | { | 403 | { |
404 | *top = lua_table[n].object; | 404 | *top = lua_table[n].object; |
405 | incr_top; | 405 | incr_top; |
406 | if (tag(top-1) == LUA_T_NIL) | 406 | if (ttype(top-1) == LUA_T_NIL) |
407 | { /* must call getglobal fallback */ | 407 | { /* must call getglobal fallback */ |
408 | tag(top-1) = LUA_T_STRING; | 408 | ttype(top-1) = LUA_T_STRING; |
409 | tsvalue(top-1) = lua_table[n].varname; | 409 | tsvalue(top-1) = lua_table[n].varname; |
410 | callFB(FB_GETGLOBAL); | 410 | callFB(FB_GETGLOBAL); |
411 | } | 411 | } |
@@ -452,7 +452,7 @@ lua_Function lua_stackedfunction (int level) | |||
452 | { | 452 | { |
453 | StkId i; | 453 | StkId i; |
454 | for (i = (top-1)-stack; i>=0; i--) | 454 | for (i = (top-1)-stack; i>=0; i--) |
455 | if (stack[i].tag == LUA_T_MARK || stack[i].tag == LUA_T_CMARK) | 455 | if (stack[i].ttype == LUA_T_MARK || stack[i].ttype == LUA_T_CMARK) |
456 | if (level-- == 0) | 456 | if (level-- == 0) |
457 | return Ref(stack+i); | 457 | return Ref(stack+i); |
458 | return LUA_NOOBJECT; | 458 | return LUA_NOOBJECT; |
@@ -462,7 +462,7 @@ lua_Function lua_stackedfunction (int level) | |||
462 | int lua_currentline (lua_Function func) | 462 | int lua_currentline (lua_Function func) |
463 | { | 463 | { |
464 | Object *f = Address(func); | 464 | Object *f = Address(func); |
465 | return (f+1 < top && (f+1)->tag == LUA_T_LINE) ? (f+1)->value.i : -1; | 465 | return (f+1 < top && (f+1)->ttype == LUA_T_LINE) ? (f+1)->value.i : -1; |
466 | } | 466 | } |
467 | 467 | ||
468 | 468 | ||
@@ -512,7 +512,7 @@ static void do_unprotectedrun (lua_CFunction f, int nParams, int nResults) | |||
512 | { | 512 | { |
513 | adjustC(nParams); | 513 | adjustC(nParams); |
514 | open_stack((top-stack)-CLS_current.base); | 514 | open_stack((top-stack)-CLS_current.base); |
515 | stack[CLS_current.base].tag = LUA_T_CFUNCTION; | 515 | stack[CLS_current.base].ttype = LUA_T_CFUNCTION; |
516 | stack[CLS_current.base].value.f = f; | 516 | stack[CLS_current.base].value.f = f; |
517 | do_callinc(nResults); | 517 | do_callinc(nResults); |
518 | } | 518 | } |
@@ -546,7 +546,7 @@ int luaI_dorun (TFunc *tf) | |||
546 | { | 546 | { |
547 | int status; | 547 | int status; |
548 | adjustC(1); /* one slot for the pseudo-function */ | 548 | adjustC(1); /* one slot for the pseudo-function */ |
549 | stack[CLS_current.base].tag = LUA_T_FUNCTION; | 549 | stack[CLS_current.base].ttype = LUA_T_FUNCTION; |
550 | stack[CLS_current.base].value.tf = tf; | 550 | stack[CLS_current.base].value.tf = tf; |
551 | status = do_protectedrun(MULT_RET); | 551 | status = do_protectedrun(MULT_RET); |
552 | return status; | 552 | return status; |
@@ -731,7 +731,7 @@ lua_Object lua_createtable (void) | |||
731 | { | 731 | { |
732 | adjustC(0); | 732 | adjustC(0); |
733 | avalue(top) = lua_createarray(0); | 733 | avalue(top) = lua_createarray(0); |
734 | tag(top) = LUA_T_ARRAY; | 734 | ttype(top) = LUA_T_ARRAY; |
735 | incr_top; | 735 | incr_top; |
736 | CLS_current.base++; /* incorporate object in the stack */ | 736 | CLS_current.base++; /* incorporate object in the stack */ |
737 | return Ref(top-1); | 737 | return Ref(top-1); |
@@ -751,17 +751,17 @@ lua_Object lua_getparam (int number) | |||
751 | 751 | ||
752 | int lua_isnil (lua_Object o) | 752 | int lua_isnil (lua_Object o) |
753 | { | 753 | { |
754 | return (o!= LUA_NOOBJECT) && (tag(Address(o)) == LUA_T_NIL); | 754 | return (o!= LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_NIL); |
755 | } | 755 | } |
756 | 756 | ||
757 | int lua_istable (lua_Object o) | 757 | int lua_istable (lua_Object o) |
758 | { | 758 | { |
759 | return (o!= LUA_NOOBJECT) && (tag(Address(o)) == LUA_T_ARRAY); | 759 | return (o!= LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_ARRAY); |
760 | } | 760 | } |
761 | 761 | ||
762 | int lua_isuserdata (lua_Object o) | 762 | int lua_isuserdata (lua_Object o) |
763 | { | 763 | { |
764 | return (o!= LUA_NOOBJECT) && (tag(Address(o)) == LUA_T_USERDATA); | 764 | return (o!= LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_USERDATA); |
765 | } | 765 | } |
766 | 766 | ||
767 | int lua_iscfunction (lua_Object o) | 767 | int lua_iscfunction (lua_Object o) |
@@ -810,14 +810,14 @@ char *lua_getstring (lua_Object object) | |||
810 | 810 | ||
811 | void *lua_getbinarydata (lua_Object object) | 811 | void *lua_getbinarydata (lua_Object object) |
812 | { | 812 | { |
813 | if (object == LUA_NOOBJECT || tag(Address(object)) != LUA_T_USERDATA) | 813 | if (object == LUA_NOOBJECT || ttype(Address(object)) != LUA_T_USERDATA) |
814 | lua_error("getbinarydata: object is not binary data"); | 814 | lua_error("getbinarydata: object is not binary data"); |
815 | return svalue(Address(object)); | 815 | return svalue(Address(object)); |
816 | } | 816 | } |
817 | 817 | ||
818 | int lua_getbindatasize (lua_Object object) | 818 | int lua_getbindatasize (lua_Object object) |
819 | { | 819 | { |
820 | if (object == LUA_NOOBJECT || tag(Address(object)) != LUA_T_USERDATA) | 820 | if (object == LUA_NOOBJECT || ttype(Address(object)) != LUA_T_USERDATA) |
821 | return 0; | 821 | return 0; |
822 | else return (Address(object))->value.ts->size; | 822 | else return (Address(object))->value.ts->size; |
823 | } | 823 | } |
@@ -827,8 +827,8 @@ int lua_getbindatasize (lua_Object object) | |||
827 | */ | 827 | */ |
828 | lua_CFunction lua_getcfunction (lua_Object object) | 828 | lua_CFunction lua_getcfunction (lua_Object object) |
829 | { | 829 | { |
830 | if (object == LUA_NOOBJECT || ((tag(Address(object)) != LUA_T_CFUNCTION) && | 830 | if (object == LUA_NOOBJECT || ((ttype(Address(object)) != LUA_T_CFUNCTION) && |
831 | (tag(Address(object)) != LUA_T_CMARK))) | 831 | (ttype(Address(object)) != LUA_T_CMARK))) |
832 | return NULL; | 832 | return NULL; |
833 | else return (fvalue(Address(object))); | 833 | else return (fvalue(Address(object))); |
834 | } | 834 | } |
@@ -889,30 +889,30 @@ void lua_storeglobal (char *name) | |||
889 | */ | 889 | */ |
890 | void lua_pushnil (void) | 890 | void lua_pushnil (void) |
891 | { | 891 | { |
892 | tag(top) = LUA_T_NIL; | 892 | ttype(top) = LUA_T_NIL; |
893 | incr_top; | 893 | incr_top; |
894 | } | 894 | } |
895 | 895 | ||
896 | /* | 896 | /* |
897 | ** Push an object (tag=number) to stack. | 897 | ** Push an object (ttype=number) to stack. |
898 | */ | 898 | */ |
899 | void lua_pushnumber (real n) | 899 | void lua_pushnumber (real n) |
900 | { | 900 | { |
901 | tag(top) = LUA_T_NUMBER; nvalue(top) = n; | 901 | ttype(top) = LUA_T_NUMBER; nvalue(top) = n; |
902 | incr_top; | 902 | incr_top; |
903 | } | 903 | } |
904 | 904 | ||
905 | /* | 905 | /* |
906 | ** Push an object (tag=string) to stack. | 906 | ** Push an object (ttype=string) to stack. |
907 | */ | 907 | */ |
908 | void lua_pushstring (char *s) | 908 | void lua_pushstring (char *s) |
909 | { | 909 | { |
910 | if (s == NULL) | 910 | if (s == NULL) |
911 | tag(top) = LUA_T_NIL; | 911 | ttype(top) = LUA_T_NIL; |
912 | else | 912 | else |
913 | { | 913 | { |
914 | tsvalue(top) = lua_createstring(s); | 914 | tsvalue(top) = lua_createstring(s); |
915 | tag(top) = LUA_T_STRING; | 915 | ttype(top) = LUA_T_STRING; |
916 | } | 916 | } |
917 | incr_top; | 917 | incr_top; |
918 | } | 918 | } |
@@ -920,27 +920,27 @@ void lua_pushstring (char *s) | |||
920 | void lua_pushliteral(char *s) { lua_pushstring(s); }*/ | 920 | void lua_pushliteral(char *s) { lua_pushstring(s); }*/ |
921 | 921 | ||
922 | /* | 922 | /* |
923 | ** Push an object (tag=cfunction) to stack. | 923 | ** Push an object (ttype=cfunction) to stack. |
924 | */ | 924 | */ |
925 | void lua_pushcfunction (lua_CFunction fn) | 925 | void lua_pushcfunction (lua_CFunction fn) |
926 | { | 926 | { |
927 | tag(top) = LUA_T_CFUNCTION; fvalue(top) = fn; | 927 | ttype(top) = LUA_T_CFUNCTION; fvalue(top) = fn; |
928 | incr_top; | 928 | incr_top; |
929 | } | 929 | } |
930 | 930 | ||
931 | void lua_pushbinarydata (void *buff, int size, int tag) | 931 | void lua_pushbinarydata (void *buff, int size, int tag) |
932 | { | 932 | { |
933 | if (buff == NULL) | 933 | if (buff == NULL) |
934 | tag(top) = LUA_T_NIL; | 934 | ttype(top) = LUA_T_NIL; |
935 | else { | 935 | else { |
936 | tsvalue(top) = luaI_createuserdata(buff, size, tag); | 936 | tsvalue(top) = luaI_createuserdata(buff, size, tag); |
937 | tag(top) = LUA_T_USERDATA; | 937 | ttype(top) = LUA_T_USERDATA; |
938 | } | 938 | } |
939 | incr_top; | 939 | incr_top; |
940 | } | 940 | } |
941 | 941 | ||
942 | /* | 942 | /* |
943 | ** Push an object (tag=userdata) to stack. | 943 | ** Push an object (ttype=userdata) to stack. |
944 | */ | 944 | */ |
945 | void lua_pushusertag (void *u, int tag) | 945 | void lua_pushusertag (void *u, int tag) |
946 | { | 946 | { |
@@ -966,8 +966,8 @@ void lua_pushobject (lua_Object o) | |||
966 | if (o == LUA_NOOBJECT) | 966 | if (o == LUA_NOOBJECT) |
967 | lua_error("attempt to push a NOOBJECT"); | 967 | lua_error("attempt to push a NOOBJECT"); |
968 | *top = *Address(o); | 968 | *top = *Address(o); |
969 | if (tag(top) == LUA_T_MARK) tag(top) = LUA_T_FUNCTION; | 969 | if (ttype(top) == LUA_T_MARK) ttype(top) = LUA_T_FUNCTION; |
970 | else if (tag(top) == LUA_T_CMARK) tag(top) = LUA_T_CFUNCTION; | 970 | else if (ttype(top) == LUA_T_CMARK) ttype(top) = LUA_T_CFUNCTION; |
971 | incr_top; | 971 | incr_top; |
972 | } | 972 | } |
973 | 973 | ||
@@ -991,13 +991,13 @@ static void call_arith (char *op) | |||
991 | callFB(FB_ARITH); | 991 | callFB(FB_ARITH); |
992 | } | 992 | } |
993 | 993 | ||
994 | static void comparison (lua_Type tag_less, lua_Type tag_equal, | 994 | static void comparison (lua_Type ttype_less, lua_Type ttype_equal, |
995 | lua_Type tag_great, char *op) | 995 | lua_Type ttype_great, char *op) |
996 | { | 996 | { |
997 | Object *l = top-2; | 997 | Object *l = top-2; |
998 | Object *r = top-1; | 998 | Object *r = top-1; |
999 | int result; | 999 | int result; |
1000 | if (tag(l) == LUA_T_NUMBER && tag(r) == LUA_T_NUMBER) | 1000 | if (ttype(l) == LUA_T_NUMBER && ttype(r) == LUA_T_NUMBER) |
1001 | result = (nvalue(l) < nvalue(r)) ? -1 : (nvalue(l) == nvalue(r)) ? 0 : 1; | 1001 | result = (nvalue(l) < nvalue(r)) ? -1 : (nvalue(l) == nvalue(r)) ? 0 : 1; |
1002 | else if (tostring(l) || tostring(r)) | 1002 | else if (tostring(l) || tostring(r)) |
1003 | { | 1003 | { |
@@ -1009,7 +1009,8 @@ static void comparison (lua_Type tag_less, lua_Type tag_equal, | |||
1009 | result = strcmp(svalue(l), svalue(r)); | 1009 | result = strcmp(svalue(l), svalue(r)); |
1010 | top--; | 1010 | top--; |
1011 | nvalue(top-1) = 1; | 1011 | nvalue(top-1) = 1; |
1012 | tag(top-1) = (result < 0) ? tag_less : (result == 0) ? tag_equal : tag_great; | 1012 | ttype(top-1) = (result < 0) ? ttype_less : |
1013 | (result == 0) ? ttype_equal : ttype_great; | ||
1013 | } | 1014 | } |
1014 | 1015 | ||
1015 | 1016 | ||
@@ -1021,18 +1022,18 @@ static void adjust_varargs (StkId first_extra_arg) | |||
1021 | int i; | 1022 | int i; |
1022 | if (nvararg < 0) nvararg = 0; | 1023 | if (nvararg < 0) nvararg = 0; |
1023 | avalue(&arg) = lua_createarray(nvararg+1); /* +1 for field 'n' */ | 1024 | avalue(&arg) = lua_createarray(nvararg+1); /* +1 for field 'n' */ |
1024 | tag(&arg) = LUA_T_ARRAY; | 1025 | ttype(&arg) = LUA_T_ARRAY; |
1025 | for (i=0; i<nvararg; i++) { | 1026 | for (i=0; i<nvararg; i++) { |
1026 | Object index; | 1027 | Object index; |
1027 | tag(&index) = LUA_T_NUMBER; | 1028 | ttype(&index) = LUA_T_NUMBER; |
1028 | nvalue(&index) = i+1; | 1029 | nvalue(&index) = i+1; |
1029 | *(lua_hashdefine(avalue(&arg), &index)) = *(firstelem+i); | 1030 | *(lua_hashdefine(avalue(&arg), &index)) = *(firstelem+i); |
1030 | } | 1031 | } |
1031 | /* store counter in field "n" */ { | 1032 | /* store counter in field "n" */ { |
1032 | Object index, extra; | 1033 | Object index, extra; |
1033 | tag(&index) = LUA_T_STRING; | 1034 | ttype(&index) = LUA_T_STRING; |
1034 | tsvalue(&index) = lua_createstring("n"); | 1035 | tsvalue(&index) = lua_createstring("n"); |
1035 | tag(&extra) = LUA_T_NUMBER; | 1036 | ttype(&extra) = LUA_T_NUMBER; |
1036 | nvalue(&extra) = nvararg; | 1037 | nvalue(&extra) = nvararg; |
1037 | *(lua_hashdefine(avalue(&arg), &index)) = extra; | 1038 | *(lua_hashdefine(avalue(&arg), &index)) = extra; |
1038 | } | 1039 | } |
@@ -1056,22 +1057,22 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
1056 | OpCode opcode; | 1057 | OpCode opcode; |
1057 | switch (opcode = (OpCode)*pc++) | 1058 | switch (opcode = (OpCode)*pc++) |
1058 | { | 1059 | { |
1059 | case PUSHNIL: tag(top) = LUA_T_NIL; incr_top; break; | 1060 | case PUSHNIL: ttype(top) = LUA_T_NIL; incr_top; break; |
1060 | 1061 | ||
1061 | case PUSH0: case PUSH1: case PUSH2: | 1062 | case PUSH0: case PUSH1: case PUSH2: |
1062 | tag(top) = LUA_T_NUMBER; | 1063 | ttype(top) = LUA_T_NUMBER; |
1063 | nvalue(top) = opcode-PUSH0; | 1064 | nvalue(top) = opcode-PUSH0; |
1064 | incr_top; | 1065 | incr_top; |
1065 | break; | 1066 | break; |
1066 | 1067 | ||
1067 | case PUSHBYTE: | 1068 | case PUSHBYTE: |
1068 | tag(top) = LUA_T_NUMBER; nvalue(top) = *pc++; incr_top; break; | 1069 | ttype(top) = LUA_T_NUMBER; nvalue(top) = *pc++; incr_top; break; |
1069 | 1070 | ||
1070 | case PUSHWORD: | 1071 | case PUSHWORD: |
1071 | { | 1072 | { |
1072 | Word w; | 1073 | Word w; |
1073 | get_word(w,pc); | 1074 | get_word(w,pc); |
1074 | tag(top) = LUA_T_NUMBER; nvalue(top) = w; | 1075 | ttype(top) = LUA_T_NUMBER; nvalue(top) = w; |
1075 | incr_top; | 1076 | incr_top; |
1076 | } | 1077 | } |
1077 | break; | 1078 | break; |
@@ -1080,7 +1081,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
1080 | { | 1081 | { |
1081 | real num; | 1082 | real num; |
1082 | get_float(num,pc); | 1083 | get_float(num,pc); |
1083 | tag(top) = LUA_T_NUMBER; nvalue(top) = num; | 1084 | ttype(top) = LUA_T_NUMBER; nvalue(top) = num; |
1084 | incr_top; | 1085 | incr_top; |
1085 | } | 1086 | } |
1086 | break; | 1087 | break; |
@@ -1089,7 +1090,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
1089 | { | 1090 | { |
1090 | Word w; | 1091 | Word w; |
1091 | get_word(w,pc); | 1092 | get_word(w,pc); |
1092 | tag(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w]; | 1093 | ttype(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w]; |
1093 | incr_top; | 1094 | incr_top; |
1094 | } | 1095 | } |
1095 | break; | 1096 | break; |
@@ -1099,7 +1100,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
1099 | TFunc *f; | 1100 | TFunc *f; |
1100 | get_code(f,pc); | 1101 | get_code(f,pc); |
1101 | luaI_insertfunction(f); /* may take part in GC */ | 1102 | luaI_insertfunction(f); /* may take part in GC */ |
1102 | top->tag = LUA_T_FUNCTION; | 1103 | top->ttype = LUA_T_FUNCTION; |
1103 | top->value.tf = f; | 1104 | top->value.tf = f; |
1104 | incr_top; | 1105 | incr_top; |
1105 | } | 1106 | } |
@@ -1130,7 +1131,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
1130 | Object receiver = *(top-1); | 1131 | Object receiver = *(top-1); |
1131 | Word w; | 1132 | Word w; |
1132 | get_word(w,pc); | 1133 | get_word(w,pc); |
1133 | tag(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w]; | 1134 | ttype(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w]; |
1134 | incr_top; | 1135 | incr_top; |
1135 | pushsubscript(); | 1136 | pushsubscript(); |
1136 | *top = receiver; | 1137 | *top = receiver; |
@@ -1176,7 +1177,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
1176 | arr = top-n-1; | 1177 | arr = top-n-1; |
1177 | while (n) | 1178 | while (n) |
1178 | { | 1179 | { |
1179 | tag(top) = LUA_T_NUMBER; nvalue(top) = n+m; | 1180 | ttype(top) = LUA_T_NUMBER; nvalue(top) = n+m; |
1180 | *(lua_hashdefine (avalue(arr), top)) = *(top-1); | 1181 | *(lua_hashdefine (avalue(arr), top)) = *(top-1); |
1181 | top--; | 1182 | top--; |
1182 | n--; | 1183 | n--; |
@@ -1192,7 +1193,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
1192 | { | 1193 | { |
1193 | Word w; | 1194 | Word w; |
1194 | get_word(w,pc); | 1195 | get_word(w,pc); |
1195 | tag(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w]; | 1196 | ttype(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w]; |
1196 | *(lua_hashdefine (avalue(arr), top)) = *(top-1); | 1197 | *(lua_hashdefine (avalue(arr), top)) = *(top-1); |
1197 | top--; | 1198 | top--; |
1198 | n--; | 1199 | n--; |
@@ -1227,7 +1228,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
1227 | Word size; | 1228 | Word size; |
1228 | get_word(size,pc); | 1229 | get_word(size,pc); |
1229 | avalue(top) = lua_createarray(size); | 1230 | avalue(top) = lua_createarray(size); |
1230 | tag(top) = LUA_T_ARRAY; | 1231 | ttype(top) = LUA_T_ARRAY; |
1231 | incr_top; | 1232 | incr_top; |
1232 | } | 1233 | } |
1233 | break; | 1234 | break; |
@@ -1236,7 +1237,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
1236 | { | 1237 | { |
1237 | int res = lua_equalObj(top-2, top-1); | 1238 | int res = lua_equalObj(top-2, top-1); |
1238 | --top; | 1239 | --top; |
1239 | tag(top-1) = res ? LUA_T_NUMBER : LUA_T_NIL; | 1240 | ttype(top-1) = res ? LUA_T_NUMBER : LUA_T_NIL; |
1240 | nvalue(top-1) = 1; | 1241 | nvalue(top-1) = 1; |
1241 | } | 1242 | } |
1242 | break; | 1243 | break; |
@@ -1334,7 +1335,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
1334 | case MINUSOP: | 1335 | case MINUSOP: |
1335 | if (tonumber(top-1)) | 1336 | if (tonumber(top-1)) |
1336 | { | 1337 | { |
1337 | tag(top) = LUA_T_NIL; | 1338 | ttype(top) = LUA_T_NIL; |
1338 | incr_top; | 1339 | incr_top; |
1339 | call_arith("unm"); | 1340 | call_arith("unm"); |
1340 | } | 1341 | } |
@@ -1343,7 +1344,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
1343 | break; | 1344 | break; |
1344 | 1345 | ||
1345 | case NOTOP: | 1346 | case NOTOP: |
1346 | tag(top-1) = (tag(top-1) == LUA_T_NIL) ? LUA_T_NUMBER : LUA_T_NIL; | 1347 | ttype(top-1) = (ttype(top-1) == LUA_T_NIL) ? LUA_T_NUMBER : LUA_T_NIL; |
1347 | nvalue(top-1) = 1; | 1348 | nvalue(top-1) = 1; |
1348 | break; | 1349 | break; |
1349 | 1350 | ||
@@ -1351,7 +1352,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
1351 | { | 1352 | { |
1352 | Word w; | 1353 | Word w; |
1353 | get_word(w,pc); | 1354 | get_word(w,pc); |
1354 | if (tag(top-1) != LUA_T_NIL) pc += w; | 1355 | if (ttype(top-1) != LUA_T_NIL) pc += w; |
1355 | } | 1356 | } |
1356 | break; | 1357 | break; |
1357 | 1358 | ||
@@ -1359,7 +1360,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
1359 | { | 1360 | { |
1360 | Word w; | 1361 | Word w; |
1361 | get_word(w,pc); | 1362 | get_word(w,pc); |
1362 | if (tag(top-1) == LUA_T_NIL) pc += w; | 1363 | if (ttype(top-1) == LUA_T_NIL) pc += w; |
1363 | } | 1364 | } |
1364 | break; | 1365 | break; |
1365 | 1366 | ||
@@ -1384,7 +1385,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
1384 | Word w; | 1385 | Word w; |
1385 | get_word(w,pc); | 1386 | get_word(w,pc); |
1386 | top--; | 1387 | top--; |
1387 | if (tag(top) == LUA_T_NIL) pc += w; | 1388 | if (ttype(top) == LUA_T_NIL) pc += w; |
1388 | } | 1389 | } |
1389 | break; | 1390 | break; |
1390 | 1391 | ||
@@ -1393,7 +1394,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
1393 | Word w; | 1394 | Word w; |
1394 | get_word(w,pc); | 1395 | get_word(w,pc); |
1395 | top--; | 1396 | top--; |
1396 | if (tag(top) == LUA_T_NIL) pc -= w; | 1397 | if (ttype(top) == LUA_T_NIL) pc -= w; |
1397 | } | 1398 | } |
1398 | break; | 1399 | break; |
1399 | 1400 | ||
@@ -1418,12 +1419,12 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
1418 | { | 1419 | { |
1419 | Word line; | 1420 | Word line; |
1420 | get_word(line,pc); | 1421 | get_word(line,pc); |
1421 | if ((stack+base-1)->tag != LUA_T_LINE) | 1422 | if ((stack+base-1)->ttype != LUA_T_LINE) |
1422 | { | 1423 | { |
1423 | /* open space for LINE value */ | 1424 | /* open space for LINE value */ |
1424 | open_stack((top-stack)-base); | 1425 | open_stack((top-stack)-base); |
1425 | base++; | 1426 | base++; |
1426 | (stack+base-1)->tag = LUA_T_LINE; | 1427 | (stack+base-1)->ttype = LUA_T_LINE; |
1427 | } | 1428 | } |
1428 | (stack+base-1)->value.i = line; | 1429 | (stack+base-1)->value.i = line; |
1429 | if (lua_linehook) | 1430 | if (lua_linehook) |
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | ** TeCGraf - PUC-Rio | 2 | ** TeCGraf - PUC-Rio |
3 | ** $Id: opcode.h,v 3.26 1997/02/20 15:51:14 roberto Exp roberto $ | 3 | ** $Id: opcode.h,v 3.27 1997/03/06 17:30:55 roberto Exp roberto $ |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #ifndef opcode_h | 6 | #ifndef opcode_h |
@@ -121,13 +121,13 @@ typedef union | |||
121 | 121 | ||
122 | typedef struct Object | 122 | typedef struct Object |
123 | { | 123 | { |
124 | lua_Type tag; | 124 | lua_Type ttype; |
125 | Value value; | 125 | Value value; |
126 | } Object; | 126 | } Object; |
127 | 127 | ||
128 | 128 | ||
129 | /* Macros to access structure members */ | 129 | /* Macros to access structure members */ |
130 | #define tag(o) ((o)->tag) | 130 | #define ttype(o) ((o)->ttype) |
131 | #define nvalue(o) ((o)->value.n) | 131 | #define nvalue(o) ((o)->value.n) |
132 | #define svalue(o) ((o)->value.ts->str) | 132 | #define svalue(o) ((o)->value.ts->str) |
133 | #define tsvalue(o) ((o)->value.ts) | 133 | #define tsvalue(o) ((o)->value.ts) |
@@ -136,7 +136,7 @@ typedef struct Object | |||
136 | 136 | ||
137 | /* Macros to access symbol table */ | 137 | /* Macros to access symbol table */ |
138 | #define s_object(i) (lua_table[i].object) | 138 | #define s_object(i) (lua_table[i].object) |
139 | #define s_tag(i) (tag(&s_object(i))) | 139 | #define s_ttype(i) (ttype(&s_object(i))) |
140 | #define s_nvalue(i) (nvalue(&s_object(i))) | 140 | #define s_nvalue(i) (nvalue(&s_object(i))) |
141 | #define s_svalue(i) (svalue(&s_object(i))) | 141 | #define s_svalue(i) (svalue(&s_object(i))) |
142 | #define s_tsvalue(i) (tsvalue(&s_object(i))) | 142 | #define s_tsvalue(i) (tsvalue(&s_object(i))) |
@@ -3,7 +3,7 @@ | |||
3 | ** Module to control static tables | 3 | ** Module to control static tables |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_table="$Id: table.c,v 2.58 1996/11/01 12:47:45 roberto Exp roberto $"; | 6 | char *rcs_table="$Id: table.c,v 2.59 1997/02/26 17:38:41 roberto Unstable roberto $"; |
7 | 7 | ||
8 | #include "mem.h" | 8 | #include "mem.h" |
9 | #include "opcode.h" | 9 | #include "opcode.h" |
@@ -64,7 +64,7 @@ Word luaI_findsymbol (TaggedString *t) | |||
64 | symbolEM, MAX_WORD); | 64 | symbolEM, MAX_WORD); |
65 | t->varindex = lua_ntable; | 65 | t->varindex = lua_ntable; |
66 | lua_table[lua_ntable].varname = t; | 66 | lua_table[lua_ntable].varname = t; |
67 | s_tag(lua_ntable) = LUA_T_NIL; | 67 | s_ttype(lua_ntable) = LUA_T_NIL; |
68 | lua_ntable++; | 68 | lua_ntable++; |
69 | } | 69 | } |
70 | return t->varindex; | 70 | return t->varindex; |
@@ -128,11 +128,11 @@ static char *lua_travsymbol (int (*fn)(Object *)) | |||
128 | */ | 128 | */ |
129 | int lua_markobject (Object *o) | 129 | int lua_markobject (Object *o) |
130 | {/* if already marked, does not change mark value */ | 130 | {/* if already marked, does not change mark value */ |
131 | if (tag(o) == LUA_T_STRING && !tsvalue(o)->marked) | 131 | if (ttype(o) == LUA_T_STRING && !tsvalue(o)->marked) |
132 | tsvalue(o)->marked = 1; | 132 | tsvalue(o)->marked = 1; |
133 | else if (tag(o) == LUA_T_ARRAY) | 133 | else if (ttype(o) == LUA_T_ARRAY) |
134 | lua_hashmark (avalue(o)); | 134 | lua_hashmark (avalue(o)); |
135 | else if ((o->tag == LUA_T_FUNCTION || o->tag == LUA_T_MARK) | 135 | else if ((o->ttype == LUA_T_FUNCTION || o->ttype == LUA_T_MARK) |
136 | && !o->value.tf->marked) | 136 | && !o->value.tf->marked) |
137 | o->value.tf->marked = 1; | 137 | o->value.tf->marked = 1; |
138 | return 0; | 138 | return 0; |
@@ -143,7 +143,7 @@ int lua_markobject (Object *o) | |||
143 | */ | 143 | */ |
144 | int luaI_ismarked (Object *o) | 144 | int luaI_ismarked (Object *o) |
145 | { | 145 | { |
146 | switch (o->tag) | 146 | switch (o->ttype) |
147 | { | 147 | { |
148 | case LUA_T_STRING: | 148 | case LUA_T_STRING: |
149 | return o->value.ts->marked; | 149 | return o->value.ts->marked; |
@@ -207,7 +207,7 @@ void luaI_nextvar (void) | |||
207 | } | 207 | } |
208 | else | 208 | else |
209 | next = luaI_findsymbolbyname(lua_getstring(o)) + 1; | 209 | next = luaI_findsymbolbyname(lua_getstring(o)) + 1; |
210 | while (next < lua_ntable && s_tag(next) == LUA_T_NIL) next++; | 210 | while (next < lua_ntable && s_ttype(next) == LUA_T_NIL) next++; |
211 | if (next < lua_ntable) | 211 | if (next < lua_ntable) |
212 | { | 212 | { |
213 | lua_pushstring(lua_table[next].varname->str); | 213 | lua_pushstring(lua_table[next].varname->str); |
@@ -219,14 +219,15 @@ void luaI_nextvar (void) | |||
219 | static Object *functofind; | 219 | static Object *functofind; |
220 | static int checkfunc (Object *o) | 220 | static int checkfunc (Object *o) |
221 | { | 221 | { |
222 | if (o->tag == LUA_T_FUNCTION) | 222 | if (o->ttype == LUA_T_FUNCTION) |
223 | return | 223 | return |
224 | ((functofind->tag == LUA_T_FUNCTION || functofind->tag == LUA_T_MARK) | 224 | ((functofind->ttype == LUA_T_FUNCTION || functofind->ttype == LUA_T_MARK) |
225 | && (functofind->value.tf == o->value.tf)); | 225 | && (functofind->value.tf == o->value.tf)); |
226 | if (o->tag == LUA_T_CFUNCTION) | 226 | if (o->ttype == LUA_T_CFUNCTION) |
227 | return | 227 | return |
228 | ((functofind->tag == LUA_T_CFUNCTION || functofind->tag == LUA_T_CMARK) | 228 | ((functofind->ttype == LUA_T_CFUNCTION || |
229 | && (functofind->value.f == o->value.f)); | 229 | functofind->ttype == LUA_T_CMARK) && |
230 | (functofind->value.f == o->value.f)); | ||
230 | return 0; | 231 | return 0; |
231 | } | 232 | } |
232 | 233 | ||