diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-03-09 13:28:07 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-03-09 13:28:07 -0300 |
commit | 370d31a5593220723d222dec6e3e4019decc3309 (patch) | |
tree | e04ad903d079da2feea0b1759e89b65d1a70815c /lvm.c | |
parent | f8df21bd2071c4e3729d37d1552f54ca2742551a (diff) | |
download | lua-370d31a5593220723d222dec6e3e4019decc3309.tar.gz lua-370d31a5593220723d222dec6e3e4019decc3309.tar.bz2 lua-370d31a5593220723d222dec6e3e4019decc3309.zip |
`luacĀ“ -> `luai' (to avoid confusion with other luac stuff)
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 42 |
1 files changed, 21 insertions, 21 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.30 2005/03/08 18:09:16 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.31 2005/03/08 20:10:05 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 | */ |
@@ -49,7 +49,7 @@ int luaV_tostring (lua_State *L, StkId obj) { | |||
49 | if (!ttisnumber(obj)) | 49 | if (!ttisnumber(obj)) |
50 | return 0; | 50 | return 0; |
51 | else { | 51 | else { |
52 | char s[LUAC_MAXNUMBER2STR]; | 52 | char s[LUAI_MAXNUMBER2STR]; |
53 | lua_number2str(s, nvalue(obj)); | 53 | lua_number2str(s, nvalue(obj)); |
54 | setsvalue2s(L, obj, luaS_new(L, s)); | 54 | setsvalue2s(L, obj, luaS_new(L, s)); |
55 | return 1; | 55 | return 1; |
@@ -243,7 +243,7 @@ int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { | |||
243 | if (ttype(l) != ttype(r)) | 243 | if (ttype(l) != ttype(r)) |
244 | return luaG_ordererror(L, l, r); | 244 | return luaG_ordererror(L, l, r); |
245 | else if (ttisnumber(l)) | 245 | else if (ttisnumber(l)) |
246 | return luac_numlt(nvalue(l), nvalue(r)); | 246 | return luai_numlt(nvalue(l), nvalue(r)); |
247 | else if (ttisstring(l)) | 247 | else if (ttisstring(l)) |
248 | return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; | 248 | return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; |
249 | else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) | 249 | else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) |
@@ -257,7 +257,7 @@ static int lessequal (lua_State *L, const TValue *l, const TValue *r) { | |||
257 | if (ttype(l) != ttype(r)) | 257 | if (ttype(l) != ttype(r)) |
258 | return luaG_ordererror(L, l, r); | 258 | return luaG_ordererror(L, l, r); |
259 | else if (ttisnumber(l)) | 259 | else if (ttisnumber(l)) |
260 | return luac_numle(nvalue(l), nvalue(r)); | 260 | return luai_numle(nvalue(l), nvalue(r)); |
261 | else if (ttisstring(l)) | 261 | else if (ttisstring(l)) |
262 | return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; | 262 | return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; |
263 | else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ | 263 | else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ |
@@ -273,7 +273,7 @@ int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) { | |||
273 | lua_assert(ttype(t1) == ttype(t2)); | 273 | lua_assert(ttype(t1) == ttype(t2)); |
274 | switch (ttype(t1)) { | 274 | switch (ttype(t1)) { |
275 | case LUA_TNIL: return 1; | 275 | case LUA_TNIL: return 1; |
276 | case LUA_TNUMBER: return luac_numeq(nvalue(t1), nvalue(t2)); | 276 | case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2)); |
277 | case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ | 277 | case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ |
278 | case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); | 278 | case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); |
279 | case LUA_TUSERDATA: { | 279 | case LUA_TUSERDATA: { |
@@ -338,12 +338,12 @@ static StkId Arith (lua_State *L, StkId ra, const TValue *rb, | |||
338 | (c = luaV_tonumber(rc, &tempc)) != NULL) { | 338 | (c = luaV_tonumber(rc, &tempc)) != NULL) { |
339 | lua_Number nb = nvalue(b), nc = nvalue(c); | 339 | lua_Number nb = nvalue(b), nc = nvalue(c); |
340 | switch (op) { | 340 | switch (op) { |
341 | case TM_ADD: setnvalue(ra, luac_numadd(nb, nc)); break; | 341 | case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break; |
342 | case TM_SUB: setnvalue(ra, luac_numsub(nb, nc)); break; | 342 | case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break; |
343 | case TM_MUL: setnvalue(ra, luac_nummul(nb, nc)); break; | 343 | case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break; |
344 | case TM_DIV: setnvalue(ra, luac_numdiv(nb, nc)); break; | 344 | case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break; |
345 | case TM_MOD: setnvalue(ra, luac_nummod(nb, nc)); break; | 345 | case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break; |
346 | case TM_POW: setnvalue(ra, luac_numpow(nb, nc)); break; | 346 | case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break; |
347 | default: lua_assert(0); break; | 347 | default: lua_assert(0); break; |
348 | } | 348 | } |
349 | } | 349 | } |
@@ -480,7 +480,7 @@ StkId 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, luac_numadd(nb, nc)); | 483 | setnvalue(ra, luai_numadd(nb, nc)); |
484 | } | 484 | } |
485 | else | 485 | else |
486 | base = Arith(L, ra, rb, rc, TM_ADD, pc); /***/ | 486 | base = Arith(L, ra, rb, rc, TM_ADD, pc); /***/ |
@@ -491,7 +491,7 @@ StkId 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, luac_numsub(nb, nc)); | 494 | setnvalue(ra, luai_numsub(nb, nc)); |
495 | } | 495 | } |
496 | else | 496 | else |
497 | base = Arith(L, ra, rb, rc, TM_SUB, pc); /***/ | 497 | base = Arith(L, ra, rb, rc, TM_SUB, pc); /***/ |
@@ -502,7 +502,7 @@ StkId 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, luac_nummul(nb, nc)); | 505 | setnvalue(ra, luai_nummul(nb, nc)); |
506 | } | 506 | } |
507 | else | 507 | else |
508 | base = Arith(L, ra, rb, rc, TM_MUL, pc); /***/ | 508 | base = Arith(L, ra, rb, rc, TM_MUL, pc); /***/ |
@@ -513,7 +513,7 @@ StkId 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, luac_numdiv(nb, nc)); | 516 | setnvalue(ra, luai_numdiv(nb, nc)); |
517 | } | 517 | } |
518 | else | 518 | else |
519 | base = Arith(L, ra, rb, rc, TM_DIV, pc); /***/ | 519 | base = Arith(L, ra, rb, rc, TM_DIV, pc); /***/ |
@@ -524,7 +524,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
524 | TValue *rc = RKC(i); | 524 | TValue *rc = RKC(i); |
525 | if (ttisnumber(rb) && ttisnumber(rc)) { | 525 | if (ttisnumber(rb) && ttisnumber(rc)) { |
526 | lua_Number nb = nvalue(rb), nc = nvalue(rc); | 526 | lua_Number nb = nvalue(rb), nc = nvalue(rc); |
527 | setnvalue(ra, luac_nummod(nb, nc)); | 527 | setnvalue(ra, luai_nummod(nb, nc)); |
528 | } | 528 | } |
529 | else | 529 | else |
530 | base = Arith(L, ra, rb, rc, TM_MOD, pc); /***/ | 530 | base = Arith(L, ra, rb, rc, TM_MOD, pc); /***/ |
@@ -535,7 +535,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
535 | TValue *rc = RKC(i); | 535 | TValue *rc = RKC(i); |
536 | if (ttisnumber(rb) && ttisnumber(rc)) { | 536 | if (ttisnumber(rb) && ttisnumber(rc)) { |
537 | lua_Number nb = nvalue(rb), nc = nvalue(rc); | 537 | lua_Number nb = nvalue(rb), nc = nvalue(rc); |
538 | setnvalue(ra, luac_numpow(nb, nc)); | 538 | setnvalue(ra, luai_numpow(nb, nc)); |
539 | } | 539 | } |
540 | else | 540 | else |
541 | base = Arith(L, ra, rb, rc, TM_POW, pc); /***/ | 541 | base = Arith(L, ra, rb, rc, TM_POW, pc); /***/ |
@@ -546,7 +546,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
546 | TValue temp; | 546 | TValue temp; |
547 | if (tonumber(rb, &temp)) { | 547 | if (tonumber(rb, &temp)) { |
548 | lua_Number nb = nvalue(rb); | 548 | lua_Number nb = nvalue(rb); |
549 | setnvalue(ra, luac_numunm(nb)); | 549 | setnvalue(ra, luai_numunm(nb)); |
550 | } | 550 | } |
551 | else { | 551 | else { |
552 | setnilvalue(&temp); | 552 | setnilvalue(&temp); |
@@ -682,9 +682,9 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
682 | } | 682 | } |
683 | case OP_FORLOOP: { | 683 | case OP_FORLOOP: { |
684 | lua_Number step = nvalue(ra+2); | 684 | lua_Number step = nvalue(ra+2); |
685 | lua_Number idx = luac_numadd(nvalue(ra), step); /* increment index */ | 685 | lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */ |
686 | lua_Number limit = nvalue(ra+1); | 686 | lua_Number limit = nvalue(ra+1); |
687 | if (step > 0 ? luac_numle(idx, limit) : luac_numle(limit, idx)) { | 687 | if (step > 0 ? luai_numle(idx, limit) : luai_numle(limit, idx)) { |
688 | dojump(L, pc, GETARG_sBx(i)); /* jump back */ | 688 | dojump(L, pc, GETARG_sBx(i)); /* jump back */ |
689 | setnvalue(ra, idx); /* update internal index... */ | 689 | setnvalue(ra, idx); /* update internal index... */ |
690 | setnvalue(ra+3, idx); /* ...and external index */ | 690 | setnvalue(ra+3, idx); /* ...and external index */ |
@@ -702,7 +702,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
702 | luaG_runerror(L, "`for' limit must be a number"); | 702 | luaG_runerror(L, "`for' limit must be a number"); |
703 | else if (!tonumber(pstep, ra+2)) | 703 | else if (!tonumber(pstep, ra+2)) |
704 | luaG_runerror(L, "`for' step must be a number"); | 704 | luaG_runerror(L, "`for' step must be a number"); |
705 | setnvalue(ra, luac_numsub(nvalue(ra), nvalue(pstep))); | 705 | setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); |
706 | dojump(L, pc, GETARG_sBx(i)); | 706 | dojump(L, pc, GETARG_sBx(i)); |
707 | continue; | 707 | continue; |
708 | } | 708 | } |