diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-10-05 09:14:08 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-10-05 09:14:08 -0300 |
commit | 001f2bdd0e2f8803889c1b5164b57a51e44aef5b (patch) | |
tree | d200cf4d708be3c61e64640c45b47050c9c6a375 /lvm.c | |
parent | cd2ddaded97f7f2b2af02cecfd165cf70e6f83f4 (diff) | |
download | lua-001f2bdd0e2f8803889c1b5164b57a51e44aef5b.tar.gz lua-001f2bdd0e2f8803889c1b5164b57a51e44aef5b.tar.bz2 lua-001f2bdd0e2f8803889c1b5164b57a51e44aef5b.zip |
new definition for types-tags
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 112 |
1 files changed, 57 insertions, 55 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.141 2000/10/03 14:27:44 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.142 2000/10/04 12:16:08 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -40,25 +40,25 @@ | |||
40 | 40 | ||
41 | 41 | ||
42 | int luaV_tonumber (TObject *obj) { | 42 | int luaV_tonumber (TObject *obj) { |
43 | if (ttype(obj) != TAG_STRING) | 43 | if (ttype(obj) != LUA_TSTRING) |
44 | return 1; | 44 | return 1; |
45 | else { | 45 | else { |
46 | if (!luaO_str2d(svalue(obj), &nvalue(obj))) | 46 | if (!luaO_str2d(svalue(obj), &nvalue(obj))) |
47 | return 2; | 47 | return 2; |
48 | ttype(obj) = TAG_NUMBER; | 48 | ttype(obj) = LUA_TNUMBER; |
49 | return 0; | 49 | return 0; |
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | 53 | ||
54 | int luaV_tostring (lua_State *L, TObject *obj) { /* LUA_NUMBER */ | 54 | int luaV_tostring (lua_State *L, TObject *obj) { /* LUA_NUMBER */ |
55 | if (ttype(obj) != TAG_NUMBER) | 55 | if (ttype(obj) != LUA_TNUMBER) |
56 | return 1; | 56 | return 1; |
57 | else { | 57 | else { |
58 | char s[32]; /* 16 digits, sign, point and \0 (+ some extra...) */ | 58 | char s[32]; /* 16 digits, sign, point and \0 (+ some extra...) */ |
59 | lua_number2str(s, nvalue(obj)); /* convert `s' to number */ | 59 | lua_number2str(s, nvalue(obj)); /* convert `s' to number */ |
60 | tsvalue(obj) = luaS_new(L, s); | 60 | tsvalue(obj) = luaS_new(L, s); |
61 | ttype(obj) = TAG_STRING; | 61 | ttype(obj) = LUA_TSTRING; |
62 | return 0; | 62 | return 0; |
63 | } | 63 | } |
64 | } | 64 | } |
@@ -85,27 +85,29 @@ static void traceexec (lua_State *L, StkId base, StkId top, lua_Hook linehook) { | |||
85 | } | 85 | } |
86 | 86 | ||
87 | 87 | ||
88 | static Closure *luaV_closure (lua_State *L, lua_Tag t, int nelems) { | 88 | static Closure *luaV_closure (lua_State *L, int nelems) { |
89 | Closure *c = luaF_newclosure(L, nelems); | 89 | Closure *c = luaF_newclosure(L, nelems); |
90 | L->top -= nelems; | 90 | L->top -= nelems; |
91 | while (nelems--) | 91 | while (nelems--) |
92 | c->upvalue[nelems] = *(L->top+nelems); | 92 | c->upvalue[nelems] = *(L->top+nelems); |
93 | ttype(L->top) = t; | ||
94 | clvalue(L->top) = c; | 93 | clvalue(L->top) = c; |
94 | ttype(L->top) = LUA_TFUNCTION; | ||
95 | incr_top; | 95 | incr_top; |
96 | return c; | 96 | return c; |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | void luaV_Cclosure (lua_State *L, lua_CFunction c, int nelems) { | 100 | void luaV_Cclosure (lua_State *L, lua_CFunction c, int nelems) { |
101 | Closure *cl = luaV_closure(L, TAG_CCLOSURE, nelems); | 101 | Closure *cl = luaV_closure(L, nelems); |
102 | cl->f.c = c; | 102 | cl->f.c = c; |
103 | cl->isC = 1; | ||
103 | } | 104 | } |
104 | 105 | ||
105 | 106 | ||
106 | void luaV_Lclosure (lua_State *L, Proto *l, int nelems) { | 107 | void luaV_Lclosure (lua_State *L, Proto *l, int nelems) { |
107 | Closure *cl = luaV_closure(L, TAG_LCLOSURE, nelems); | 108 | Closure *cl = luaV_closure(L, nelems); |
108 | cl->f.l = l; | 109 | cl->f.l = l; |
110 | cl->isC = 0; | ||
109 | } | 111 | } |
110 | 112 | ||
111 | 113 | ||
@@ -116,21 +118,21 @@ void luaV_Lclosure (lua_State *L, Proto *l, int nelems) { | |||
116 | const TObject *luaV_gettable (lua_State *L, StkId t) { | 118 | const TObject *luaV_gettable (lua_State *L, StkId t) { |
117 | const TObject *im; | 119 | const TObject *im; |
118 | int tg; | 120 | int tg; |
119 | if (ttype(t) == TAG_TABLE && /* `t' is a table? */ | 121 | if (ttype(t) == LUA_TTABLE && /* `t' is a table? */ |
120 | ((tg = hvalue(t)->htag) == TAG_TABLE || /* with default tag? */ | 122 | ((tg = hvalue(t)->htag) == LUA_TTABLE || /* with default tag? */ |
121 | ttype(luaT_getim(L, tg, IM_GETTABLE)) == TAG_NIL)) { /* or no TM? */ | 123 | ttype(luaT_getim(L, tg, IM_GETTABLE)) == LUA_TNIL)) { /* or no TM? */ |
122 | /* do a primitive get */ | 124 | /* do a primitive get */ |
123 | const TObject *h = luaH_get(L, hvalue(t), L->top-1); | 125 | const TObject *h = luaH_get(L, hvalue(t), L->top-1); |
124 | /* result is no nil or there is no `index' tag method? */ | 126 | /* result is no nil or there is no `index' tag method? */ |
125 | if (ttype(h) != TAG_NIL || | 127 | if (ttype(h) != LUA_TNIL || |
126 | (ttype(im=luaT_getim(L, tg, IM_INDEX)) == TAG_NIL)) | 128 | (ttype(im=luaT_getim(L, tg, IM_INDEX)) == LUA_TNIL)) |
127 | return h; /* return result */ | 129 | return h; /* return result */ |
128 | /* else call `index' tag method */ | 130 | /* else call `index' tag method */ |
129 | } | 131 | } |
130 | else { /* try a 'gettable' TM */ | 132 | else { /* try a `gettable' tag method */ |
131 | im = luaT_getimbyObj(L, t, IM_GETTABLE); | 133 | im = luaT_getimbyObj(L, t, IM_GETTABLE); |
132 | } | 134 | } |
133 | if (ttype(im) != TAG_NIL) { /* is there a tag method? */ | 135 | if (ttype(im) != LUA_TNIL) { /* is there a tag method? */ |
134 | luaD_checkstack(L, 2); | 136 | luaD_checkstack(L, 2); |
135 | *(L->top+1) = *(L->top-1); /* key */ | 137 | *(L->top+1) = *(L->top-1); /* key */ |
136 | *L->top = *t; /* table */ | 138 | *L->top = *t; /* table */ |
@@ -151,13 +153,13 @@ const TObject *luaV_gettable (lua_State *L, StkId t) { | |||
151 | */ | 153 | */ |
152 | void luaV_settable (lua_State *L, StkId t, StkId key) { | 154 | void luaV_settable (lua_State *L, StkId t, StkId key) { |
153 | int tg; | 155 | int tg; |
154 | if (ttype(t) == TAG_TABLE && /* `t' is a table? */ | 156 | if (ttype(t) == LUA_TTABLE && /* `t' is a table? */ |
155 | ((tg = hvalue(t)->htag) == TAG_TABLE || /* with default tag? */ | 157 | ((tg = hvalue(t)->htag) == LUA_TTABLE || /* with default tag? */ |
156 | ttype(luaT_getim(L, tg, IM_SETTABLE)) == TAG_NIL)) /* or no TM? */ | 158 | ttype(luaT_getim(L, tg, IM_SETTABLE)) == LUA_TNIL)) /* or no TM? */ |
157 | *luaH_set(L, hvalue(t), key) = *(L->top-1); /* do a primitive set */ | 159 | *luaH_set(L, hvalue(t), key) = *(L->top-1); /* do a primitive set */ |
158 | else { /* try a `settable' tag method */ | 160 | else { /* try a `settable' tag method */ |
159 | const TObject *im = luaT_getimbyObj(L, t, IM_SETTABLE); | 161 | const TObject *im = luaT_getimbyObj(L, t, IM_SETTABLE); |
160 | if (ttype(im) != TAG_NIL) { | 162 | if (ttype(im) != LUA_TNIL) { |
161 | luaD_checkstack(L, 3); | 163 | luaD_checkstack(L, 3); |
162 | *(L->top+2) = *(L->top-1); | 164 | *(L->top+2) = *(L->top-1); |
163 | *(L->top+1) = *key; | 165 | *(L->top+1) = *key; |
@@ -175,12 +177,12 @@ void luaV_settable (lua_State *L, StkId t, StkId key) { | |||
175 | const TObject *luaV_getglobal (lua_State *L, TString *s) { | 177 | const TObject *luaV_getglobal (lua_State *L, TString *s) { |
176 | const TObject *value = luaH_getstr(L->gt, s); | 178 | const TObject *value = luaH_getstr(L->gt, s); |
177 | const TObject *im = luaT_getimbyObj(L, value, IM_GETGLOBAL); | 179 | const TObject *im = luaT_getimbyObj(L, value, IM_GETGLOBAL); |
178 | if (ttype(im) == TAG_NIL) /* is there a tag method? */ | 180 | if (ttype(im) == LUA_TNIL) /* is there a tag method? */ |
179 | return value; /* default behavior */ | 181 | return value; /* default behavior */ |
180 | else { /* tag method */ | 182 | else { /* tag method */ |
181 | luaD_checkstack(L, 3); | 183 | luaD_checkstack(L, 3); |
182 | *L->top = *im; | 184 | *L->top = *im; |
183 | ttype(L->top+1) = TAG_STRING; | 185 | ttype(L->top+1) = LUA_TSTRING; |
184 | tsvalue(L->top+1) = s; /* global name */ | 186 | tsvalue(L->top+1) = s; /* global name */ |
185 | *(L->top+2) = *value; | 187 | *(L->top+2) = *value; |
186 | L->top += 3; | 188 | L->top += 3; |
@@ -193,14 +195,14 @@ const TObject *luaV_getglobal (lua_State *L, TString *s) { | |||
193 | void luaV_setglobal (lua_State *L, TString *s) { | 195 | void luaV_setglobal (lua_State *L, TString *s) { |
194 | const TObject *oldvalue = luaH_getstr(L->gt, s); | 196 | const TObject *oldvalue = luaH_getstr(L->gt, s); |
195 | const TObject *im = luaT_getimbyObj(L, oldvalue, IM_SETGLOBAL); | 197 | const TObject *im = luaT_getimbyObj(L, oldvalue, IM_SETGLOBAL); |
196 | if (ttype(im) == TAG_NIL) { /* is there a tag method? */ | 198 | if (ttype(im) == LUA_TNIL) { /* is there a tag method? */ |
197 | if (oldvalue != &luaO_nilobject) { | 199 | if (oldvalue != &luaO_nilobject) { |
198 | /* cast to remove `const' is OK, because `oldvalue' != luaO_nilobject */ | 200 | /* cast to remove `const' is OK, because `oldvalue' != luaO_nilobject */ |
199 | *(TObject *)oldvalue = *(L->top - 1); | 201 | *(TObject *)oldvalue = *(L->top - 1); |
200 | } | 202 | } |
201 | else { | 203 | else { |
202 | TObject key; | 204 | TObject key; |
203 | ttype(&key) = TAG_STRING; | 205 | ttype(&key) = LUA_TSTRING; |
204 | tsvalue(&key) = s; | 206 | tsvalue(&key) = s; |
205 | *luaH_set(L, L->gt, &key) = *(L->top - 1); | 207 | *luaH_set(L, L->gt, &key) = *(L->top - 1); |
206 | } | 208 | } |
@@ -209,7 +211,7 @@ void luaV_setglobal (lua_State *L, TString *s) { | |||
209 | luaD_checkstack(L, 3); | 211 | luaD_checkstack(L, 3); |
210 | *(L->top+2) = *(L->top-1); /* new value */ | 212 | *(L->top+2) = *(L->top-1); /* new value */ |
211 | *(L->top+1) = *oldvalue; | 213 | *(L->top+1) = *oldvalue; |
212 | ttype(L->top) = TAG_STRING; | 214 | ttype(L->top) = LUA_TSTRING; |
213 | tsvalue(L->top) = s; | 215 | tsvalue(L->top) = s; |
214 | *(L->top-1) = *im; | 216 | *(L->top-1) = *im; |
215 | L->top += 3; | 217 | L->top += 3; |
@@ -222,11 +224,11 @@ static int call_binTM (lua_State *L, StkId top, IMS event) { | |||
222 | /* try first operand */ | 224 | /* try first operand */ |
223 | const TObject *im = luaT_getimbyObj(L, top-2, event); | 225 | const TObject *im = luaT_getimbyObj(L, top-2, event); |
224 | L->top = top; | 226 | L->top = top; |
225 | if (ttype(im) == TAG_NIL) { | 227 | if (ttype(im) == LUA_TNIL) { |
226 | im = luaT_getimbyObj(L, top-1, event); /* try second operand */ | 228 | im = luaT_getimbyObj(L, top-1, event); /* try second operand */ |
227 | if (ttype(im) == TAG_NIL) { | 229 | if (ttype(im) == LUA_TNIL) { |
228 | im = luaT_getim(L, 0, event); /* try a `global' method */ | 230 | im = luaT_getim(L, 0, event); /* try a `global' method */ |
229 | if (ttype(im) == TAG_NIL) | 231 | if (ttype(im) == LUA_TNIL) |
230 | return 0; /* error */ | 232 | return 0; /* error */ |
231 | } | 233 | } |
232 | } | 234 | } |
@@ -238,7 +240,7 @@ static int call_binTM (lua_State *L, StkId top, IMS event) { | |||
238 | 240 | ||
239 | static void call_arith (lua_State *L, StkId top, IMS event) { | 241 | static void call_arith (lua_State *L, StkId top, IMS event) { |
240 | if (!call_binTM(L, top, event)) | 242 | if (!call_binTM(L, top, event)) |
241 | luaG_binerror(L, top-2, TAG_NUMBER, "perform arithmetic on"); | 243 | luaG_binerror(L, top-2, LUA_TNUMBER, "perform arithmetic on"); |
242 | } | 244 | } |
243 | 245 | ||
244 | 246 | ||
@@ -265,9 +267,9 @@ static int luaV_strcomp (const TString *ls, const TString *rs) { | |||
265 | 267 | ||
266 | 268 | ||
267 | int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r, StkId top) { | 269 | int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r, StkId top) { |
268 | if (ttype(l) == TAG_NUMBER && ttype(r) == TAG_NUMBER) | 270 | if (ttype(l) == LUA_TNUMBER && ttype(r) == LUA_TNUMBER) |
269 | return (nvalue(l) < nvalue(r)); | 271 | return (nvalue(l) < nvalue(r)); |
270 | else if (ttype(l) == TAG_STRING && ttype(r) == TAG_STRING) | 272 | else if (ttype(l) == LUA_TSTRING && ttype(r) == LUA_TSTRING) |
271 | return (luaV_strcomp(tsvalue(l), tsvalue(r)) < 0); | 273 | return (luaV_strcomp(tsvalue(l), tsvalue(r)) < 0); |
272 | else { /* call TM */ | 274 | else { /* call TM */ |
273 | luaD_checkstack(L, 2); | 275 | luaD_checkstack(L, 2); |
@@ -276,7 +278,7 @@ int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r, StkId top) | |||
276 | if (!call_binTM(L, top, IM_LT)) | 278 | if (!call_binTM(L, top, IM_LT)) |
277 | luaG_ordererror(L, top-2); | 279 | luaG_ordererror(L, top-2); |
278 | L->top--; | 280 | L->top--; |
279 | return (ttype(L->top) != TAG_NIL); | 281 | return (ttype(L->top) != LUA_TNIL); |
280 | } | 282 | } |
281 | } | 283 | } |
282 | 284 | ||
@@ -286,7 +288,7 @@ void luaV_strconc (lua_State *L, int total, StkId top) { | |||
286 | int n = 2; /* number of elements handled in this pass (at least 2) */ | 288 | int n = 2; /* number of elements handled in this pass (at least 2) */ |
287 | if (tostring(L, top-2) || tostring(L, top-1)) { | 289 | if (tostring(L, top-2) || tostring(L, top-1)) { |
288 | if (!call_binTM(L, top, IM_CONCAT)) | 290 | if (!call_binTM(L, top, IM_CONCAT)) |
289 | luaG_binerror(L, top-2, TAG_STRING, "concat"); | 291 | luaG_binerror(L, top-2, LUA_TSTRING, "concat"); |
290 | } | 292 | } |
291 | else if (tsvalue(top-1)->u.s.len > 0) { /* if len=0, do nothing */ | 293 | else if (tsvalue(top-1)->u.s.len > 0) { /* if len=0, do nothing */ |
292 | /* at least two string values; get as many as possible */ | 294 | /* at least two string values; get as many as possible */ |
@@ -322,7 +324,7 @@ static void luaV_pack (lua_State *L, StkId firstelem) { | |||
322 | /* store counter in field `n' */ | 324 | /* store counter in field `n' */ |
323 | luaH_setstrnum(L, htab, luaS_new(L, "n"), i); | 325 | luaH_setstrnum(L, htab, luaS_new(L, "n"), i); |
324 | L->top = firstelem; /* remove elements from the stack */ | 326 | L->top = firstelem; /* remove elements from the stack */ |
325 | ttype(L->top) = TAG_TABLE; | 327 | ttype(L->top) = LUA_TTABLE; |
326 | hvalue(L->top) = htab; | 328 | hvalue(L->top) = htab; |
327 | incr_top; | 329 | incr_top; |
328 | } | 330 | } |
@@ -393,7 +395,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
393 | int n = GETARG_U(i); | 395 | int n = GETARG_U(i); |
394 | LUA_ASSERT(n>0, "invalid argument"); | 396 | LUA_ASSERT(n>0, "invalid argument"); |
395 | do { | 397 | do { |
396 | ttype(top++) = TAG_NIL; | 398 | ttype(top++) = LUA_TNIL; |
397 | } while (--n > 0); | 399 | } while (--n > 0); |
398 | break; | 400 | break; |
399 | } | 401 | } |
@@ -402,25 +404,25 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
402 | break; | 404 | break; |
403 | } | 405 | } |
404 | case OP_PUSHINT: { | 406 | case OP_PUSHINT: { |
405 | ttype(top) = TAG_NUMBER; | 407 | ttype(top) = LUA_TNUMBER; |
406 | nvalue(top) = (Number)GETARG_S(i); | 408 | nvalue(top) = (Number)GETARG_S(i); |
407 | top++; | 409 | top++; |
408 | break; | 410 | break; |
409 | } | 411 | } |
410 | case OP_PUSHSTRING: { | 412 | case OP_PUSHSTRING: { |
411 | ttype(top) = TAG_STRING; | 413 | ttype(top) = LUA_TSTRING; |
412 | tsvalue(top) = kstr[GETARG_U(i)]; | 414 | tsvalue(top) = kstr[GETARG_U(i)]; |
413 | top++; | 415 | top++; |
414 | break; | 416 | break; |
415 | } | 417 | } |
416 | case OP_PUSHNUM: { | 418 | case OP_PUSHNUM: { |
417 | ttype(top) = TAG_NUMBER; | 419 | ttype(top) = LUA_TNUMBER; |
418 | nvalue(top) = tf->knum[GETARG_U(i)]; | 420 | nvalue(top) = tf->knum[GETARG_U(i)]; |
419 | top++; | 421 | top++; |
420 | break; | 422 | break; |
421 | } | 423 | } |
422 | case OP_PUSHNEGNUM: { | 424 | case OP_PUSHNEGNUM: { |
423 | ttype(top) = TAG_NUMBER; | 425 | ttype(top) = LUA_TNUMBER; |
424 | nvalue(top) = -tf->knum[GETARG_U(i)]; | 426 | nvalue(top) = -tf->knum[GETARG_U(i)]; |
425 | top++; | 427 | top++; |
426 | break; | 428 | break; |
@@ -446,7 +448,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
446 | break; | 448 | break; |
447 | } | 449 | } |
448 | case OP_GETDOTTED: { | 450 | case OP_GETDOTTED: { |
449 | ttype(top) = TAG_STRING; | 451 | ttype(top) = LUA_TSTRING; |
450 | tsvalue(top) = kstr[GETARG_U(i)]; | 452 | tsvalue(top) = kstr[GETARG_U(i)]; |
451 | L->top = top+1; | 453 | L->top = top+1; |
452 | *(top-1) = *luaV_gettable(L, top-1); | 454 | *(top-1) = *luaV_gettable(L, top-1); |
@@ -461,7 +463,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
461 | case OP_PUSHSELF: { | 463 | case OP_PUSHSELF: { |
462 | TObject receiver; | 464 | TObject receiver; |
463 | receiver = *(top-1); | 465 | receiver = *(top-1); |
464 | ttype(top) = TAG_STRING; | 466 | ttype(top) = LUA_TSTRING; |
465 | tsvalue(top++) = kstr[GETARG_U(i)]; | 467 | tsvalue(top++) = kstr[GETARG_U(i)]; |
466 | L->top = top; | 468 | L->top = top; |
467 | *(top-2) = *luaV_gettable(L, top-2); | 469 | *(top-2) = *luaV_gettable(L, top-2); |
@@ -472,7 +474,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
472 | L->top = top; | 474 | L->top = top; |
473 | luaC_checkGC(L); | 475 | luaC_checkGC(L); |
474 | hvalue(top) = luaH_new(L, GETARG_U(i)); | 476 | hvalue(top) = luaH_new(L, GETARG_U(i)); |
475 | ttype(top) = TAG_TABLE; | 477 | ttype(top) = LUA_TTABLE; |
476 | top++; | 478 | top++; |
477 | break; | 479 | break; |
478 | } | 480 | } |
@@ -523,7 +525,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
523 | } | 525 | } |
524 | case OP_ADDI: { | 526 | case OP_ADDI: { |
525 | if (tonumber(top-1)) { | 527 | if (tonumber(top-1)) { |
526 | ttype(top) = TAG_NUMBER; | 528 | ttype(top) = LUA_TNUMBER; |
527 | nvalue(top) = (Number)GETARG_S(i); | 529 | nvalue(top) = (Number)GETARG_S(i); |
528 | call_arith(L, top+1, IM_ADD); | 530 | call_arith(L, top+1, IM_ADD); |
529 | } | 531 | } |
@@ -571,7 +573,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
571 | } | 573 | } |
572 | case OP_MINUS: { | 574 | case OP_MINUS: { |
573 | if (tonumber(top-1)) { | 575 | if (tonumber(top-1)) { |
574 | ttype(top) = TAG_NIL; | 576 | ttype(top) = LUA_TNIL; |
575 | call_arith(L, top+1, IM_UNM); | 577 | call_arith(L, top+1, IM_UNM); |
576 | } | 578 | } |
577 | else | 579 | else |
@@ -580,7 +582,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
580 | } | 582 | } |
581 | case OP_NOT: { | 583 | case OP_NOT: { |
582 | ttype(top-1) = | 584 | ttype(top-1) = |
583 | (ttype(top-1) == TAG_NIL) ? TAG_NUMBER : TAG_NIL; | 585 | (ttype(top-1) == LUA_TNIL) ? LUA_TNUMBER : LUA_TNIL; |
584 | nvalue(top-1) = 1; | 586 | nvalue(top-1) = 1; |
585 | break; | 587 | break; |
586 | } | 588 | } |
@@ -615,20 +617,20 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
615 | break; | 617 | break; |
616 | } | 618 | } |
617 | case OP_JMPT: { | 619 | case OP_JMPT: { |
618 | if (ttype(--top) != TAG_NIL) dojump(pc, i); | 620 | if (ttype(--top) != LUA_TNIL) dojump(pc, i); |
619 | break; | 621 | break; |
620 | } | 622 | } |
621 | case OP_JMPF: { | 623 | case OP_JMPF: { |
622 | if (ttype(--top) == TAG_NIL) dojump(pc, i); | 624 | if (ttype(--top) == LUA_TNIL) dojump(pc, i); |
623 | break; | 625 | break; |
624 | } | 626 | } |
625 | case OP_JMPONT: { | 627 | case OP_JMPONT: { |
626 | if (ttype(top-1) == TAG_NIL) top--; | 628 | if (ttype(top-1) == LUA_TNIL) top--; |
627 | else dojump(pc, i); | 629 | else dojump(pc, i); |
628 | break; | 630 | break; |
629 | } | 631 | } |
630 | case OP_JMPONF: { | 632 | case OP_JMPONF: { |
631 | if (ttype(top-1) != TAG_NIL) top--; | 633 | if (ttype(top-1) != LUA_TNIL) top--; |
632 | else dojump(pc, i); | 634 | else dojump(pc, i); |
633 | break; | 635 | break; |
634 | } | 636 | } |
@@ -637,7 +639,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
637 | break; | 639 | break; |
638 | } | 640 | } |
639 | case OP_PUSHNILJMP: { | 641 | case OP_PUSHNILJMP: { |
640 | ttype(top++) = TAG_NIL; | 642 | ttype(top++) = LUA_TNIL; |
641 | pc++; | 643 | pc++; |
642 | break; | 644 | break; |
643 | } | 645 | } |
@@ -657,9 +659,9 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
657 | break; | 659 | break; |
658 | } | 660 | } |
659 | case OP_FORLOOP: { | 661 | case OP_FORLOOP: { |
660 | LUA_ASSERT(ttype(top-1) == TAG_NUMBER, "invalid step"); | 662 | LUA_ASSERT(ttype(top-1) == LUA_TNUMBER, "invalid step"); |
661 | LUA_ASSERT(ttype(top-2) == TAG_NUMBER, "invalid limit"); | 663 | LUA_ASSERT(ttype(top-2) == LUA_TNUMBER, "invalid limit"); |
662 | if (ttype(top-3) != TAG_NUMBER) | 664 | if (ttype(top-3) != LUA_TNUMBER) |
663 | lua_error(L, "`for' index must be a number"); | 665 | lua_error(L, "`for' index must be a number"); |
664 | nvalue(top-3) += nvalue(top-1); /* increment index */ | 666 | nvalue(top-3) += nvalue(top-1); /* increment index */ |
665 | if (nvalue(top-1) > 0 ? | 667 | if (nvalue(top-1) > 0 ? |
@@ -672,7 +674,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
672 | } | 674 | } |
673 | case OP_LFORPREP: { | 675 | case OP_LFORPREP: { |
674 | Node *node; | 676 | Node *node; |
675 | if (ttype(top-1) != TAG_TABLE) | 677 | if (ttype(top-1) != LUA_TTABLE) |
676 | lua_error(L, "`for' table must be a table"); | 678 | lua_error(L, "`for' table must be a table"); |
677 | node = luaH_next(L, hvalue(top-1), &luaO_nilobject); | 679 | node = luaH_next(L, hvalue(top-1), &luaO_nilobject); |
678 | if (node == NULL) { /* `empty' loop? */ | 680 | if (node == NULL) { /* `empty' loop? */ |
@@ -688,7 +690,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
688 | } | 690 | } |
689 | case OP_LFORLOOP: { | 691 | case OP_LFORLOOP: { |
690 | Node *node; | 692 | Node *node; |
691 | LUA_ASSERT(ttype(top-3) == TAG_TABLE, "invalid table"); | 693 | LUA_ASSERT(ttype(top-3) == LUA_TTABLE, "invalid table"); |
692 | node = luaH_next(L, hvalue(top-3), top-2); | 694 | node = luaH_next(L, hvalue(top-3), top-2); |
693 | if (node == NULL) /* end loop? */ | 695 | if (node == NULL) /* end loop? */ |
694 | top -= 3; /* remove table, key, and value */ | 696 | top -= 3; /* remove table, key, and value */ |