aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-03-10 15:37:44 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-03-10 15:37:44 -0300
commit73aa465a8ed8dee6c6a27a6f8b2f51227b70789d (patch)
tree496a63ffffe0312f1d0b9882d97944fa38ed7801 /lvm.c
parent3d0577f4b98908be3f2d697ab75c5fbbd3f6999b (diff)
downloadlua-73aa465a8ed8dee6c6a27a6f8b2f51227b70789d.tar.gz
lua-73aa465a8ed8dee6c6a27a6f8b2f51227b70789d.tar.bz2
lua-73aa465a8ed8dee6c6a27a6f8b2f51227b70789d.zip
some name changes
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c206
1 files changed, 103 insertions, 103 deletions
diff --git a/lvm.c b/lvm.c
index 71a97d83..62a24064 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.93 2000/03/09 13:57:37 roberto Exp roberto $ 2** $Id: lvm.c,v 1.94 2000/03/10 14:38:10 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*/
@@ -33,32 +33,32 @@
33 33
34/* 34/*
35** Extra stack size to run a function: 35** Extra stack size to run a function:
36** LUA_T_LINE(1), NAME(1), TM calls(3) (plus some extra...) 36** TAG_LINE(1), NAME(1), TM calls(3) (plus some extra...)
37*/ 37*/
38#define EXTRA_STACK 8 38#define EXTRA_STACK 8
39 39
40 40
41 41
42int luaV_tonumber (TObject *obj) { /* LUA_NUMBER */ 42int luaV_tonumber (TObject *obj) { /* LUA_NUMBER */
43 if (ttype(obj) != LUA_T_STRING) 43 if (ttype(obj) != TAG_STRING)
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) = LUA_T_NUMBER; 48 ttype(obj) = TAG_NUMBER;
49 return 0; 49 return 0;
50 } 50 }
51} 51}
52 52
53 53
54int luaV_tostring (lua_State *L, TObject *obj) { /* LUA_NUMBER */ 54int luaV_tostring (lua_State *L, TObject *obj) { /* LUA_NUMBER */
55 if (ttype(obj) != LUA_T_NUMBER) 55 if (ttype(obj) != TAG_NUMBER)
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 sprintf(s, "%.16g", (double)nvalue(obj)); 59 sprintf(s, "%.16g", (double)nvalue(obj));
60 tsvalue(obj) = luaS_new(L, s); 60 tsvalue(obj) = luaS_new(L, s);
61 ttype(obj) = LUA_T_STRING; 61 ttype(obj) = TAG_STRING;
62 return 0; 62 return 0;
63 } 63 }
64} 64}
@@ -66,8 +66,8 @@ int luaV_tostring (lua_State *L, TObject *obj) { /* LUA_NUMBER */
66 66
67void luaV_setn (lua_State *L, Hash *t, int val) { 67void luaV_setn (lua_State *L, Hash *t, int val) {
68 TObject index, value; 68 TObject index, value;
69 ttype(&index) = LUA_T_STRING; tsvalue(&index) = luaS_new(L, "n"); 69 ttype(&index) = TAG_STRING; tsvalue(&index) = luaS_new(L, "n");
70 ttype(&value) = LUA_T_NUMBER; nvalue(&value) = val; 70 ttype(&value) = TAG_NUMBER; nvalue(&value) = val;
71 luaH_set(L, t, &index, &value); 71 luaH_set(L, t, &index, &value);
72} 72}
73 73
@@ -79,8 +79,8 @@ void luaV_closure (lua_State *L, int nelems) {
79 L->top -= nelems; 79 L->top -= nelems;
80 while (nelems--) 80 while (nelems--)
81 c->consts[nelems+1] = *(L->top-1+nelems); 81 c->consts[nelems+1] = *(L->top-1+nelems);
82 ttype(L->top-1) = (ttype(&c->consts[0]) == LUA_T_CPROTO) ? 82 ttype(L->top-1) = (ttype(&c->consts[0]) == TAG_CPROTO) ?
83 LUA_T_CCLOSURE : LUA_T_LCLOSURE; 83 TAG_CCLOSURE : TAG_LCLOSURE;
84 (L->top-1)->value.cl = c; 84 (L->top-1)->value.cl = c;
85 } 85 }
86} 86}
@@ -93,9 +93,9 @@ void luaV_closure (lua_State *L, int nelems) {
93void luaV_gettable (lua_State *L, StkId top) { 93void luaV_gettable (lua_State *L, StkId top) {
94 TObject *table = top-2; 94 TObject *table = top-2;
95 const TObject *im; 95 const TObject *im;
96 if (ttype(table) != LUA_T_ARRAY) { /* not a table, get gettable TM */ 96 if (ttype(table) != TAG_ARRAY) { /* not a table, get gettable TM */
97 im = luaT_getimbyObj(L, table, IM_GETTABLE); 97 im = luaT_getimbyObj(L, table, IM_GETTABLE);
98 if (ttype(im) == LUA_T_NIL) { 98 if (ttype(im) == TAG_NIL) {
99 L->top = top; 99 L->top = top;
100 luaG_indexerror(L, table); 100 luaG_indexerror(L, table);
101 } 101 }
@@ -103,10 +103,10 @@ void luaV_gettable (lua_State *L, StkId top) {
103 else { /* object is a table... */ 103 else { /* object is a table... */
104 int tg = table->value.a->htag; 104 int tg = table->value.a->htag;
105 im = luaT_getim(L, tg, IM_GETTABLE); 105 im = luaT_getim(L, tg, IM_GETTABLE);
106 if (ttype(im) == LUA_T_NIL) { /* and does not have a `gettable' TM */ 106 if (ttype(im) == TAG_NIL) { /* and does not have a `gettable' TM */
107 const TObject *h = luaH_get(L, avalue(table), table+1); 107 const TObject *h = luaH_get(L, avalue(table), table+1);
108 if (ttype(h) == LUA_T_NIL && 108 if (ttype(h) == TAG_NIL &&
109 (ttype(im=luaT_getim(L, tg, IM_INDEX)) != LUA_T_NIL)) { 109 (ttype(im=luaT_getim(L, tg, IM_INDEX)) != TAG_NIL)) {
110 /* result is nil and there is an `index' tag method */ 110 /* result is nil and there is an `index' tag method */
111 L->top = top; 111 L->top = top;
112 luaD_callTM(L, im, 2, 1); /* calls it */ 112 luaD_callTM(L, im, 2, 1); /* calls it */
@@ -128,15 +128,15 @@ void luaV_gettable (lua_State *L, StkId top) {
128*/ 128*/
129void luaV_settable (lua_State *L, StkId t, StkId top) { 129void luaV_settable (lua_State *L, StkId t, StkId top) {
130 const TObject *im; 130 const TObject *im;
131 if (ttype(t) != LUA_T_ARRAY) { /* not a table, get `settable' method */ 131 if (ttype(t) != TAG_ARRAY) { /* not a table, get `settable' method */
132 L->top = top; 132 L->top = top;
133 im = luaT_getimbyObj(L, t, IM_SETTABLE); 133 im = luaT_getimbyObj(L, t, IM_SETTABLE);
134 if (ttype(im) == LUA_T_NIL) 134 if (ttype(im) == TAG_NIL)
135 luaG_indexerror(L, t); 135 luaG_indexerror(L, t);
136 } 136 }
137 else { /* object is a table... */ 137 else { /* object is a table... */
138 im = luaT_getim(L, avalue(t)->htag, IM_SETTABLE); 138 im = luaT_getim(L, avalue(t)->htag, IM_SETTABLE);
139 if (ttype(im) == LUA_T_NIL) { /* and does not have a `settable' method */ 139 if (ttype(im) == TAG_NIL) { /* and does not have a `settable' method */
140 luaH_set(L, avalue(t), t+1, top-1); 140 luaH_set(L, avalue(t), t+1, top-1);
141 return; 141 return;
142 } 142 }
@@ -155,7 +155,7 @@ void luaV_settable (lua_State *L, StkId t, StkId top) {
155 155
156 156
157void luaV_rawsettable (lua_State *L, StkId t) { 157void luaV_rawsettable (lua_State *L, StkId t) {
158 if (ttype(t) != LUA_T_ARRAY) 158 if (ttype(t) != TAG_ARRAY)
159 lua_error(L, "indexed expression not a table"); 159 lua_error(L, "indexed expression not a table");
160 else { 160 else {
161 luaH_set(L, avalue(t), t+1, L->top-1); 161 luaH_set(L, avalue(t), t+1, L->top-1);
@@ -167,12 +167,12 @@ void luaV_rawsettable (lua_State *L, StkId t) {
167void luaV_getglobal (lua_State *L, GlobalVar *gv, StkId top) { 167void luaV_getglobal (lua_State *L, GlobalVar *gv, StkId top) {
168 const TObject *value = &gv->value; 168 const TObject *value = &gv->value;
169 TObject *im = luaT_getimbyObj(L, value, IM_GETGLOBAL); 169 TObject *im = luaT_getimbyObj(L, value, IM_GETGLOBAL);
170 if (ttype(im) == LUA_T_NIL) /* is there a tag method? */ 170 if (ttype(im) == TAG_NIL) /* is there a tag method? */
171 *top = *value; /* default behavior */ 171 *top = *value; /* default behavior */
172 else { /* tag method */ 172 else { /* tag method */
173 luaD_checkstack(L, 3); 173 luaD_checkstack(L, 3);
174 *top = *im; 174 *top = *im;
175 ttype(top+1) = LUA_T_STRING; 175 ttype(top+1) = TAG_STRING;
176 tsvalue(top+1) = gv->name; /* global name */ 176 tsvalue(top+1) = gv->name; /* global name */
177 *(top+2) = *value; 177 *(top+2) = *value;
178 L->top = top+3; 178 L->top = top+3;
@@ -184,13 +184,13 @@ void luaV_getglobal (lua_State *L, GlobalVar *gv, StkId top) {
184void luaV_setglobal (lua_State *L, GlobalVar *gv, StkId top) { 184void luaV_setglobal (lua_State *L, GlobalVar *gv, StkId top) {
185 const TObject *oldvalue = &gv->value; 185 const TObject *oldvalue = &gv->value;
186 const TObject *im = luaT_getimbyObj(L, oldvalue, IM_SETGLOBAL); 186 const TObject *im = luaT_getimbyObj(L, oldvalue, IM_SETGLOBAL);
187 if (ttype(im) == LUA_T_NIL) /* is there a tag method? */ 187 if (ttype(im) == TAG_NIL) /* is there a tag method? */
188 gv->value = *(top-1); 188 gv->value = *(top-1);
189 else { 189 else {
190 luaD_checkstack(L, 3); 190 luaD_checkstack(L, 3);
191 *(top+2) = *(top-1); /* new value */ 191 *(top+2) = *(top-1); /* new value */
192 *(top+1) = *oldvalue; 192 *(top+1) = *oldvalue;
193 ttype(top) = LUA_T_STRING; 193 ttype(top) = TAG_STRING;
194 tsvalue(top) = gv->name; 194 tsvalue(top) = gv->name;
195 *(top-1) = *im; 195 *(top-1) = *im;
196 L->top = top+3; 196 L->top = top+3;
@@ -203,11 +203,11 @@ static void call_binTM (lua_State *L, StkId top, IMS event, const char *msg) {
203 /* try first operand */ 203 /* try first operand */
204 const TObject *im = luaT_getimbyObj(L, top-2, event); 204 const TObject *im = luaT_getimbyObj(L, top-2, event);
205 L->top = top; 205 L->top = top;
206 if (ttype(im) == LUA_T_NIL) { 206 if (ttype(im) == TAG_NIL) {
207 im = luaT_getimbyObj(L, top-1, event); /* try second operand */ 207 im = luaT_getimbyObj(L, top-1, event); /* try second operand */
208 if (ttype(im) == LUA_T_NIL) { 208 if (ttype(im) == TAG_NIL) {
209 im = luaT_getim(L, 0, event); /* try a `global' method */ 209 im = luaT_getim(L, 0, event); /* try a `global' method */
210 if (ttype(im) == LUA_T_NIL) 210 if (ttype(im) == TAG_NIL)
211 lua_error(L, msg); 211 lua_error(L, msg);
212 } 212 }
213 } 213 }
@@ -221,7 +221,7 @@ static void call_arith (lua_State *L, StkId top, IMS event) {
221} 221}
222 222
223 223
224static int luaV_strcomp (const TaggedString *ls, const TaggedString *rs) { 224static int luaV_strcomp (const TString *ls, const TString *rs) {
225 const char *l = ls->str; 225 const char *l = ls->str;
226 long ll = ls->u.s.len; 226 long ll = ls->u.s.len;
227 const char *r = rs->str; 227 const char *r = rs->str;
@@ -243,9 +243,9 @@ static int luaV_strcomp (const TaggedString *ls, const TaggedString *rs) {
243 243
244 244
245int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r, StkId top) { 245int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r, StkId top) {
246 if (ttype(l) == LUA_T_NUMBER && ttype(r) == LUA_T_NUMBER) 246 if (ttype(l) == TAG_NUMBER && ttype(r) == TAG_NUMBER)
247 return (nvalue(l) < nvalue(r)); 247 return (nvalue(l) < nvalue(r));
248 else if (ttype(l) == LUA_T_STRING && ttype(r) == LUA_T_STRING) 248 else if (ttype(l) == TAG_STRING && ttype(r) == TAG_STRING)
249 return (luaV_strcomp(tsvalue(l), tsvalue(r)) < 0); 249 return (luaV_strcomp(tsvalue(l), tsvalue(r)) < 0);
250 else { /* call TM */ 250 else { /* call TM */
251 luaD_checkstack(L, 2); 251 luaD_checkstack(L, 2);
@@ -253,14 +253,14 @@ int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r, StkId top)
253 *top++ = *r; 253 *top++ = *r;
254 call_binTM(L, top, IM_LT, "unexpected type in comparison"); 254 call_binTM(L, top, IM_LT, "unexpected type in comparison");
255 L->top--; 255 L->top--;
256 return (ttype(L->top) != LUA_T_NIL); 256 return (ttype(L->top) != TAG_NIL);
257 } 257 }
258} 258}
259 259
260 260
261#define setbool(o,cond) if (cond) { \ 261#define setbool(o,cond) if (cond) { \
262 ttype(o) = LUA_T_NUMBER; nvalue(o) = 1.0; } \ 262 ttype(o) = TAG_NUMBER; nvalue(o) = 1.0; } \
263 else ttype(o) = LUA_T_NIL 263 else ttype(o) = TAG_NIL
264 264
265 265
266static void strconc (lua_State *L, int total, StkId top) { 266static void strconc (lua_State *L, int total, StkId top) {
@@ -295,7 +295,7 @@ void luaV_pack (lua_State *L, StkId firstelem, int nvararg, TObject *tab) {
295 int i; 295 int i;
296 Hash *htab; 296 Hash *htab;
297 htab = avalue(tab) = luaH_new(L, nvararg+1); /* +1 for field `n' */ 297 htab = avalue(tab) = luaH_new(L, nvararg+1); /* +1 for field `n' */
298 ttype(tab) = LUA_T_ARRAY; 298 ttype(tab) = TAG_ARRAY;
299 for (i=0; i<nvararg; i++) 299 for (i=0; i<nvararg; i++)
300 luaH_setint(L, htab, i+1, firstelem+i); 300 luaH_setint(L, htab, i+1, firstelem+i);
301 luaV_setn(L, htab, nvararg); /* store counter in field `n' */ 301 luaV_setn(L, htab, nvararg); /* store counter in field `n' */
@@ -321,11 +321,11 @@ static void adjust_varargs (lua_State *L, StkId base, int nfixargs) {
321** Executes the given Lua function. Parameters are between [base,top). 321** Executes the given Lua function. Parameters are between [base,top).
322** Returns n such that the the results are between [n,top). 322** Returns n such that the the results are between [n,top).
323*/ 323*/
324StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, 324StkId luaV_execute (lua_State *L, const Closure *cl, const Proto *tf,
325 register StkId base) { 325 register StkId base) {
326 register StkId top; /* keep top local, for performance */ 326 register StkId top; /* keep top local, for performance */
327 register const Instruction *pc = tf->code; 327 register const Instruction *pc = tf->code;
328 TaggedString **kstr = tf->kstr; 328 TString **kstr = tf->kstr;
329 if (L->callhook) 329 if (L->callhook)
330 luaD_callHook(L, base-1, L->callhook, "call"); 330 luaD_callHook(L, base-1, L->callhook, "call");
331 luaD_checkstack(L, tf->maxstacksize+EXTRA_STACK); 331 luaD_checkstack(L, tf->maxstacksize+EXTRA_STACK);
@@ -340,124 +340,124 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
340 register Instruction i = *pc++; 340 register Instruction i = *pc++;
341 switch (GET_OPCODE(i)) { 341 switch (GET_OPCODE(i)) {
342 342
343 case ENDCODE: 343 case OP_END:
344 return L->top; /* no results */ 344 return L->top; /* no results */
345 345
346 case RETCODE: 346 case OP_RETURN:
347 L->top = top; 347 L->top = top;
348 return base+GETARG_U(i); 348 return base+GETARG_U(i);
349 349
350 case CALL: 350 case OP_CALL:
351 L->top = top; 351 L->top = top;
352 luaD_call(L, base+GETARG_A(i), GETARG_B(i)); 352 luaD_call(L, base+GETARG_A(i), GETARG_B(i));
353 top = L->top; 353 top = L->top;
354 break; 354 break;
355 355
356 case TAILCALL: 356 case OP_TAILCALL:
357 L->top = top; 357 L->top = top;
358 luaD_call(L, base+GETARG_A(i), MULT_RET); 358 luaD_call(L, base+GETARG_A(i), MULT_RET);
359 return base+GETARG_B(i); 359 return base+GETARG_B(i);
360 360
361 case PUSHNIL: { 361 case OP_PUSHNIL: {
362 int n = GETARG_U(i); 362 int n = GETARG_U(i);
363 LUA_ASSERT(L, n>0, "invalid argument"); 363 LUA_ASSERT(L, n>0, "invalid argument");
364 do { 364 do {
365 ttype(top++) = LUA_T_NIL; 365 ttype(top++) = TAG_NIL;
366 } while (--n > 0); 366 } while (--n > 0);
367 break; 367 break;
368 } 368 }
369 369
370 case POP: 370 case OP_POP:
371 top -= GETARG_U(i); 371 top -= GETARG_U(i);
372 break; 372 break;
373 373
374 case PUSHINT: 374 case OP_PUSHINT:
375 ttype(top) = LUA_T_NUMBER; 375 ttype(top) = TAG_NUMBER;
376 nvalue(top) = (real)GETARG_S(i); 376 nvalue(top) = (Number)GETARG_S(i);
377 top++; 377 top++;
378 break; 378 break;
379 379
380 case PUSHSTRING: 380 case OP_PUSHSTRING:
381 ttype(top) = LUA_T_STRING; 381 ttype(top) = TAG_STRING;
382 tsvalue(top) = kstr[GETARG_U(i)]; 382 tsvalue(top) = kstr[GETARG_U(i)];
383 top++; 383 top++;
384 break; 384 break;
385 385
386 case PUSHNUM: 386 case OP_PUSHNUM:
387 ttype(top) = LUA_T_NUMBER; 387 ttype(top) = TAG_NUMBER;
388 nvalue(top) = tf->knum[GETARG_U(i)]; 388 nvalue(top) = tf->knum[GETARG_U(i)];
389 top++; 389 top++;
390 break; 390 break;
391 391
392 case PUSHNEGNUM: 392 case OP_PUSHNEGNUM:
393 ttype(top) = LUA_T_NUMBER; 393 ttype(top) = TAG_NUMBER;
394 nvalue(top) = -tf->knum[GETARG_U(i)]; 394 nvalue(top) = -tf->knum[GETARG_U(i)];
395 top++; 395 top++;
396 break; 396 break;
397 397
398 case PUSHUPVALUE: 398 case OP_PUSHUPVALUE:
399 *top++ = cl->consts[GETARG_U(i)+1]; 399 *top++ = cl->consts[GETARG_U(i)+1];
400 break; 400 break;
401 401
402 case PUSHLOCAL: 402 case OP_PUSHLOCAL:
403 *top++ = *(base+GETARG_U(i)); 403 *top++ = *(base+GETARG_U(i));
404 break; 404 break;
405 405
406 case GETGLOBAL: 406 case OP_GETGLOBAL:
407 luaV_getglobal(L, kstr[GETARG_U(i)]->u.s.gv, top); 407 luaV_getglobal(L, kstr[GETARG_U(i)]->u.s.gv, top);
408 top++; 408 top++;
409 break; 409 break;
410 410
411 case GETTABLE: 411 case OP_GETTABLE:
412 luaV_gettable(L, top); 412 luaV_gettable(L, top);
413 top--; 413 top--;
414 break; 414 break;
415 415
416 case GETDOTTED: 416 case OP_GETDOTTED:
417 ttype(top) = LUA_T_STRING; 417 ttype(top) = TAG_STRING;
418 tsvalue(top++) = kstr[GETARG_U(i)]; 418 tsvalue(top++) = kstr[GETARG_U(i)];
419 luaV_gettable(L, top); 419 luaV_gettable(L, top);
420 top--; 420 top--;
421 break; 421 break;
422 422
423 case PUSHSELF: { 423 case OP_PUSHSELF: {
424 TObject receiver; 424 TObject receiver;
425 receiver = *(top-1); 425 receiver = *(top-1);
426 ttype(top) = LUA_T_STRING; 426 ttype(top) = TAG_STRING;
427 tsvalue(top++) = kstr[GETARG_U(i)]; 427 tsvalue(top++) = kstr[GETARG_U(i)];
428 luaV_gettable(L, top); 428 luaV_gettable(L, top);
429 *(top-1) = receiver; 429 *(top-1) = receiver;
430 break; 430 break;
431 } 431 }
432 432
433 case CREATETABLE: 433 case OP_CREATETABLE:
434 L->top = top; 434 L->top = top;
435 luaC_checkGC(L); 435 luaC_checkGC(L);
436 avalue(top) = luaH_new(L, GETARG_U(i)); 436 avalue(top) = luaH_new(L, GETARG_U(i));
437 ttype(top) = LUA_T_ARRAY; 437 ttype(top) = TAG_ARRAY;
438 top++; 438 top++;
439 break; 439 break;
440 440
441 case SETLOCAL: 441 case OP_SETLOCAL:
442 *(base+GETARG_U(i)) = *(--top); 442 *(base+GETARG_U(i)) = *(--top);
443 break; 443 break;
444 444
445 case SETGLOBAL: 445 case OP_SETGLOBAL:
446 luaV_setglobal(L, kstr[GETARG_U(i)]->u.s.gv, top); 446 luaV_setglobal(L, kstr[GETARG_U(i)]->u.s.gv, top);
447 top--; 447 top--;
448 break; 448 break;
449 449
450 case SETTABLEPOP: 450 case OP_SETTABLEPOP:
451 luaV_settable(L, top-3, top); 451 luaV_settable(L, top-3, top);
452 top -= 3; /* pop table, index, and value */ 452 top -= 3; /* pop table, index, and value */
453 break; 453 break;
454 454
455 case SETTABLE: 455 case OP_SETTABLE:
456 luaV_settable(L, top-3-GETARG_U(i), top); 456 luaV_settable(L, top-3-GETARG_U(i), top);
457 top--; /* pop value */ 457 top--; /* pop value */
458 break; 458 break;
459 459
460 case SETLIST: { 460 case OP_SETLIST: {
461 int aux = GETARG_A(i) * LFIELDS_PER_FLUSH; 461 int aux = GETARG_A(i) * LFIELDS_PER_FLUSH;
462 int n = GETARG_B(i)+1; 462 int n = GETARG_B(i)+1;
463 Hash *arr = avalue(top-n-1); 463 Hash *arr = avalue(top-n-1);
@@ -467,7 +467,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
467 break; 467 break;
468 } 468 }
469 469
470 case SETMAP: { 470 case OP_SETMAP: {
471 int n = GETARG_U(i); 471 int n = GETARG_U(i);
472 StkId finaltop = top-2*(n+1); 472 StkId finaltop = top-2*(n+1);
473 Hash *arr = avalue(finaltop-1); 473 Hash *arr = avalue(finaltop-1);
@@ -479,7 +479,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
479 break; 479 break;
480 } 480 }
481 481
482 case ADDOP: 482 case OP_ADD:
483 if (tonumber(top-1) || tonumber(top-2)) 483 if (tonumber(top-1) || tonumber(top-2))
484 call_arith(L, top, IM_ADD); 484 call_arith(L, top, IM_ADD);
485 else 485 else
@@ -487,17 +487,17 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
487 top--; 487 top--;
488 break; 488 break;
489 489
490 case ADDI: 490 case OP_ADDI:
491 if (tonumber(top-1)) { 491 if (tonumber(top-1)) {
492 ttype(top) = LUA_T_NUMBER; 492 ttype(top) = TAG_NUMBER;
493 nvalue(top) = (real)GETARG_S(i); 493 nvalue(top) = (Number)GETARG_S(i);
494 call_arith(L, top+1, IM_ADD); 494 call_arith(L, top+1, IM_ADD);
495 } 495 }
496 else 496 else
497 nvalue(top-1) += (real)GETARG_S(i); 497 nvalue(top-1) += (Number)GETARG_S(i);
498 break; 498 break;
499 499
500 case SUBOP: 500 case OP_SUB:
501 if (tonumber(top-1) || tonumber(top-2)) 501 if (tonumber(top-1) || tonumber(top-2))
502 call_arith(L, top, IM_SUB); 502 call_arith(L, top, IM_SUB);
503 else 503 else
@@ -505,7 +505,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
505 top--; 505 top--;
506 break; 506 break;
507 507
508 case MULTOP: 508 case OP_MULT:
509 if (tonumber(top-1) || tonumber(top-2)) 509 if (tonumber(top-1) || tonumber(top-2))
510 call_arith(L, top, IM_MUL); 510 call_arith(L, top, IM_MUL);
511 else 511 else
@@ -513,7 +513,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
513 top--; 513 top--;
514 break; 514 break;
515 515
516 case DIVOP: 516 case OP_DIV:
517 if (tonumber(top-1) || tonumber(top-2)) 517 if (tonumber(top-1) || tonumber(top-2))
518 call_arith(L, top, IM_DIV); 518 call_arith(L, top, IM_DIV);
519 else 519 else
@@ -521,12 +521,12 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
521 top--; 521 top--;
522 break; 522 break;
523 523
524 case POWOP: 524 case OP_POW:
525 call_binTM(L, top, IM_POW, "undefined operation"); 525 call_binTM(L, top, IM_POW, "undefined operation");
526 top--; 526 top--;
527 break; 527 break;
528 528
529 case CONCOP: { 529 case OP_CONC: {
530 int n = GETARG_U(i); 530 int n = GETARG_U(i);
531 strconc(L, n, top); 531 strconc(L, n, top);
532 top -= n-1; 532 top -= n-1;
@@ -535,80 +535,80 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
535 break; 535 break;
536 } 536 }
537 537
538 case MINUSOP: 538 case OP_MINUS:
539 if (tonumber(top-1)) { 539 if (tonumber(top-1)) {
540 ttype(top) = LUA_T_NIL; 540 ttype(top) = TAG_NIL;
541 call_arith(L, top+1, IM_UNM); 541 call_arith(L, top+1, IM_UNM);
542 } 542 }
543 else 543 else
544 nvalue(top-1) = -nvalue(top-1); 544 nvalue(top-1) = -nvalue(top-1);
545 break; 545 break;
546 546
547 case NOTOP: 547 case OP_NOT:
548 ttype(top-1) = 548 ttype(top-1) =
549 (ttype(top-1) == LUA_T_NIL) ? LUA_T_NUMBER : LUA_T_NIL; 549 (ttype(top-1) == TAG_NIL) ? TAG_NUMBER : TAG_NIL;
550 nvalue(top-1) = 1; 550 nvalue(top-1) = 1;
551 break; 551 break;
552 552
553 case IFNEQJMP: 553 case OP_IFNEQJMP:
554 top -= 2; 554 top -= 2;
555 if (!luaO_equalObj(top, top+1)) pc += GETARG_S(i); 555 if (!luaO_equalObj(top, top+1)) pc += GETARG_S(i);
556 break; 556 break;
557 557
558 case IFEQJMP: 558 case OP_IFEQJMP:
559 top -= 2; 559 top -= 2;
560 if (luaO_equalObj(top, top+1)) pc += GETARG_S(i); 560 if (luaO_equalObj(top, top+1)) pc += GETARG_S(i);
561 break; 561 break;
562 562
563 case IFLTJMP: 563 case OP_IFLTJMP:
564 top -= 2; 564 top -= 2;
565 if (luaV_lessthan(L, top, top+1, top+2)) pc += GETARG_S(i); 565 if (luaV_lessthan(L, top, top+1, top+2)) pc += GETARG_S(i);
566 break; 566 break;
567 567
568 case IFLEJMP: /* a <= b === !(b<a) */ 568 case OP_IFLEJMP: /* a <= b === !(b<a) */
569 top -= 2; 569 top -= 2;
570 if (!luaV_lessthan(L, top+1, top, top+2)) pc += GETARG_S(i); 570 if (!luaV_lessthan(L, top+1, top, top+2)) pc += GETARG_S(i);
571 break; 571 break;
572 572
573 case IFGTJMP: /* a > b === (b<a) */ 573 case OP_IFGTJMP: /* a > b === (b<a) */
574 top -= 2; 574 top -= 2;
575 if (luaV_lessthan(L, top+1, top, top+2)) pc += GETARG_S(i); 575 if (luaV_lessthan(L, top+1, top, top+2)) pc += GETARG_S(i);
576 break; 576 break;
577 577
578 case IFGEJMP: /* a >= b === !(a<b) */ 578 case OP_IFGEJMP: /* a >= b === !(a<b) */
579 top -= 2; 579 top -= 2;
580 if (!luaV_lessthan(L, top, top+1, top+2)) pc += GETARG_S(i); 580 if (!luaV_lessthan(L, top, top+1, top+2)) pc += GETARG_S(i);
581 break; 581 break;
582 582
583 case IFTJMP: 583 case OP_IFTJMP:
584 if (ttype(--top) != LUA_T_NIL) pc += GETARG_S(i); 584 if (ttype(--top) != TAG_NIL) pc += GETARG_S(i);
585 break; 585 break;
586 586
587 case IFFJMP: 587 case OP_IFFJMP:
588 if (ttype(--top) == LUA_T_NIL) pc += GETARG_S(i); 588 if (ttype(--top) == TAG_NIL) pc += GETARG_S(i);
589 break; 589 break;
590 590
591 case ONTJMP: 591 case OP_ONTJMP:
592 if (ttype(top-1) != LUA_T_NIL) pc += GETARG_S(i); 592 if (ttype(top-1) != TAG_NIL) pc += GETARG_S(i);
593 else top--; 593 else top--;
594 break; 594 break;
595 595
596 case ONFJMP: 596 case OP_ONFJMP:
597 if (ttype(top-1) == LUA_T_NIL) pc += GETARG_S(i); 597 if (ttype(top-1) == TAG_NIL) pc += GETARG_S(i);
598 else top--; 598 else top--;
599 break; 599 break;
600 600
601 case JMP: 601 case OP_JMP:
602 pc += GETARG_S(i); 602 pc += GETARG_S(i);
603 break; 603 break;
604 604
605 case PUSHNILJMP: 605 case OP_PUSHNILJMP:
606 ttype(top++) = LUA_T_NIL; 606 ttype(top++) = TAG_NIL;
607 pc++; 607 pc++;
608 break; 608 break;
609 609
610 case CLOSURE: 610 case OP_CLOSURE:
611 ttype(top) = LUA_T_LPROTO; 611 ttype(top) = TAG_LPROTO;
612 tfvalue(top) = tf->kproto[GETARG_A(i)]; 612 tfvalue(top) = tf->kproto[GETARG_A(i)];
613 L->top = ++top; 613 L->top = ++top;
614 luaV_closure(L, GETARG_B(i)); 614 luaV_closure(L, GETARG_B(i));
@@ -616,14 +616,14 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
616 luaC_checkGC(L); 616 luaC_checkGC(L);
617 break; 617 break;
618 618
619 case SETLINE: 619 case OP_SETLINE:
620 if ((base-1)->ttype != LUA_T_LINE) { 620 if ((base-1)->ttype != TAG_LINE) {
621 /* open space for LINE value */ 621 /* open space for LINE value */
622 int n = top-base; 622 int n = top-base;
623 while (n--) base[n+1] = base[n]; 623 while (n--) base[n+1] = base[n];
624 base++; 624 base++;
625 top++; 625 top++;
626 (base-1)->ttype = LUA_T_LINE; 626 (base-1)->ttype = TAG_LINE;
627 } 627 }
628 (base-1)->value.i = GETARG_U(i); 628 (base-1)->value.i = GETARG_U(i);
629 if (L->linehook) { 629 if (L->linehook) {