aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/lvm.c b/lvm.c
index 5e8637c9..87d3d0dc 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.56 2005/10/03 14:01:26 roberto Exp roberto $ 2** $Id: lvm.c,v 2.57 2005/10/13 12:21:26 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*/
@@ -225,7 +225,7 @@ int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
225 if (ttype(l) != ttype(r)) 225 if (ttype(l) != ttype(r))
226 return luaG_ordererror(L, l, r); 226 return luaG_ordererror(L, l, r);
227 else if (ttisnumber(l)) 227 else if (ttisnumber(l))
228 return luai_numlt(L, nvalue(l), nvalue(r)); 228 return luai_numlt(nvalue(l), nvalue(r));
229 else if (ttisstring(l)) 229 else if (ttisstring(l))
230 return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; 230 return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
231 else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) 231 else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
@@ -239,7 +239,7 @@ static int lessequal (lua_State *L, const TValue *l, const TValue *r) {
239 if (ttype(l) != ttype(r)) 239 if (ttype(l) != ttype(r))
240 return luaG_ordererror(L, l, r); 240 return luaG_ordererror(L, l, r);
241 else if (ttisnumber(l)) 241 else if (ttisnumber(l))
242 return luai_numle(L, nvalue(l), nvalue(r)); 242 return luai_numle(nvalue(l), nvalue(r));
243 else if (ttisstring(l)) 243 else if (ttisstring(l))
244 return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; 244 return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
245 else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ 245 else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */
@@ -255,7 +255,7 @@ int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
255 lua_assert(ttype(t1) == ttype(t2)); 255 lua_assert(ttype(t1) == ttype(t2));
256 switch (ttype(t1)) { 256 switch (ttype(t1)) {
257 case LUA_TNIL: return 1; 257 case LUA_TNIL: return 1;
258 case LUA_TNUMBER: return luai_numeq(L, nvalue(t1), nvalue(t2)); 258 case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2));
259 case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ 259 case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
260 case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); 260 case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
261 case LUA_TUSERDATA: { 261 case LUA_TUSERDATA: {
@@ -318,13 +318,13 @@ static void Arith (lua_State *L, StkId ra, const TValue *rb,
318 (c = luaV_tonumber(rc, &tempc)) != NULL) { 318 (c = luaV_tonumber(rc, &tempc)) != NULL) {
319 lua_Number nb = nvalue(b), nc = nvalue(c); 319 lua_Number nb = nvalue(b), nc = nvalue(c);
320 switch (op) { 320 switch (op) {
321 case TM_ADD: setnvalue(ra, luai_numadd(L, nb, nc)); break; 321 case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break;
322 case TM_SUB: setnvalue(ra, luai_numsub(L, nb, nc)); break; 322 case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break;
323 case TM_MUL: setnvalue(ra, luai_nummul(L, nb, nc)); break; 323 case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break;
324 case TM_DIV: setnvalue(ra, luai_numdiv(L, nb, nc)); break; 324 case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break;
325 case TM_MOD: setnvalue(ra, luai_nummod(L, nb, nc)); break; 325 case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break;
326 case TM_POW: setnvalue(ra, luai_numpow(L, nb, nc)); break; 326 case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break;
327 case TM_UNM: setnvalue(ra, luai_numunm(L, nb)); break; 327 case TM_UNM: setnvalue(ra, luai_numunm(nb)); break;
328 default: lua_assert(0); break; 328 default: lua_assert(0); break;
329 } 329 }
330 } 330 }
@@ -458,7 +458,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
458 TValue *rc = RKC(i); 458 TValue *rc = RKC(i);
459 if (ttisnumber(rb) && ttisnumber(rc)) { 459 if (ttisnumber(rb) && ttisnumber(rc)) {
460 lua_Number nb = nvalue(rb), nc = nvalue(rc); 460 lua_Number nb = nvalue(rb), nc = nvalue(rc);
461 setnvalue(ra, luai_numadd(L, nb, nc)); 461 setnvalue(ra, luai_numadd(nb, nc));
462 } 462 }
463 else 463 else
464 Protect(Arith(L, ra, rb, rc, TM_ADD)); 464 Protect(Arith(L, ra, rb, rc, TM_ADD));
@@ -469,7 +469,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
469 TValue *rc = RKC(i); 469 TValue *rc = RKC(i);
470 if (ttisnumber(rb) && ttisnumber(rc)) { 470 if (ttisnumber(rb) && ttisnumber(rc)) {
471 lua_Number nb = nvalue(rb), nc = nvalue(rc); 471 lua_Number nb = nvalue(rb), nc = nvalue(rc);
472 setnvalue(ra, luai_numsub(L, nb, nc)); 472 setnvalue(ra, luai_numsub(nb, nc));
473 } 473 }
474 else 474 else
475 Protect(Arith(L, ra, rb, rc, TM_SUB)); 475 Protect(Arith(L, ra, rb, rc, TM_SUB));
@@ -480,7 +480,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
480 TValue *rc = RKC(i); 480 TValue *rc = RKC(i);
481 if (ttisnumber(rb) && ttisnumber(rc)) { 481 if (ttisnumber(rb) && ttisnumber(rc)) {
482 lua_Number nb = nvalue(rb), nc = nvalue(rc); 482 lua_Number nb = nvalue(rb), nc = nvalue(rc);
483 setnvalue(ra, luai_nummul(L, nb, nc)); 483 setnvalue(ra, luai_nummul(nb, nc));
484 } 484 }
485 else 485 else
486 Protect(Arith(L, ra, rb, rc, TM_MUL)); 486 Protect(Arith(L, ra, rb, rc, TM_MUL));
@@ -491,7 +491,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
491 TValue *rc = RKC(i); 491 TValue *rc = RKC(i);
492 if (ttisnumber(rb) && ttisnumber(rc)) { 492 if (ttisnumber(rb) && ttisnumber(rc)) {
493 lua_Number nb = nvalue(rb), nc = nvalue(rc); 493 lua_Number nb = nvalue(rb), nc = nvalue(rc);
494 setnvalue(ra, luai_numdiv(L, nb, nc)); 494 setnvalue(ra, luai_numdiv(nb, nc));
495 } 495 }
496 else 496 else
497 Protect(Arith(L, ra, rb, rc, TM_DIV)); 497 Protect(Arith(L, ra, rb, rc, TM_DIV));
@@ -502,7 +502,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
502 TValue *rc = RKC(i); 502 TValue *rc = RKC(i);
503 if (ttisnumber(rb) && ttisnumber(rc)) { 503 if (ttisnumber(rb) && ttisnumber(rc)) {
504 lua_Number nb = nvalue(rb), nc = nvalue(rc); 504 lua_Number nb = nvalue(rb), nc = nvalue(rc);
505 setnvalue(ra, luai_nummod(L, nb, nc)); 505 setnvalue(ra, luai_nummod(nb, nc));
506 } 506 }
507 else 507 else
508 Protect(Arith(L, ra, rb, rc, TM_MOD)); 508 Protect(Arith(L, ra, rb, rc, TM_MOD));
@@ -513,7 +513,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
513 TValue *rc = RKC(i); 513 TValue *rc = RKC(i);
514 if (ttisnumber(rb) && ttisnumber(rc)) { 514 if (ttisnumber(rb) && ttisnumber(rc)) {
515 lua_Number nb = nvalue(rb), nc = nvalue(rc); 515 lua_Number nb = nvalue(rb), nc = nvalue(rc);
516 setnvalue(ra, luai_numpow(L, nb, nc)); 516 setnvalue(ra, luai_numpow(nb, nc));
517 } 517 }
518 else 518 else
519 Protect(Arith(L, ra, rb, rc, TM_POW)); 519 Protect(Arith(L, ra, rb, rc, TM_POW));
@@ -523,7 +523,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
523 TValue *rb = RB(i); 523 TValue *rb = RB(i);
524 if (ttisnumber(rb)) { 524 if (ttisnumber(rb)) {
525 lua_Number nb = nvalue(rb); 525 lua_Number nb = nvalue(rb);
526 setnvalue(ra, luai_numunm(L, nb)); 526 setnvalue(ra, luai_numunm(nb));
527 } 527 }
528 else { 528 else {
529 Protect(Arith(L, ra, rb, rb, TM_UNM)); 529 Protect(Arith(L, ra, rb, rb, TM_UNM));
@@ -677,9 +677,9 @@ void luaV_execute (lua_State *L, int nexeccalls) {
677 } 677 }
678 case OP_FORLOOP: { 678 case OP_FORLOOP: {
679 lua_Number step = nvalue(ra+2); 679 lua_Number step = nvalue(ra+2);
680 lua_Number idx = luai_numadd(L, nvalue(ra), step); /* increment index */ 680 lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
681 lua_Number limit = nvalue(ra+1); 681 lua_Number limit = nvalue(ra+1);
682 if (step > 0 ? luai_numle(L, idx, limit) : luai_numle(L, limit, idx)) { 682 if (step > 0 ? luai_numle(idx, limit) : luai_numle(limit, idx)) {
683 dojump(L, pc, GETARG_sBx(i)); /* jump back */ 683 dojump(L, pc, GETARG_sBx(i)); /* jump back */
684 setnvalue(ra, idx); /* update internal index... */ 684 setnvalue(ra, idx); /* update internal index... */
685 setnvalue(ra+3, idx); /* ...and external index */ 685 setnvalue(ra+3, idx); /* ...and external index */
@@ -697,7 +697,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
697 luaG_runerror(L, LUA_QL("for") " limit must be a number"); 697 luaG_runerror(L, LUA_QL("for") " limit must be a number");
698 else if (!tonumber(pstep, ra+2)) 698 else if (!tonumber(pstep, ra+2))
699 luaG_runerror(L, LUA_QL("for") " step must be a number"); 699 luaG_runerror(L, LUA_QL("for") " step must be a number");
700 setnvalue(ra, luai_numsub(L, nvalue(ra), nvalue(pstep))); 700 setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
701 dojump(L, pc, GETARG_sBx(i)); 701 dojump(L, pc, GETARG_sBx(i));
702 continue; 702 continue;
703 } 703 }