diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-05-20 12:53:42 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-05-20 12:53:42 -0300 |
commit | f21e9c172f9f15d8d7501e35635e78dc11f5ff58 (patch) | |
tree | cb50795d8bceff944dd8f7d75626069491d5e8d0 | |
parent | 67578ec51f1a3ec2c967f15d370067caf9e0b87b (diff) | |
download | lua-f21e9c172f9f15d8d7501e35635e78dc11f5ff58.tar.gz lua-f21e9c172f9f15d8d7501e35635e78dc11f5ff58.tar.bz2 lua-f21e9c172f9f15d8d7501e35635e78dc11f5ff58.zip |
details
-rw-r--r-- | lbaselib.c | 10 | ||||
-rw-r--r-- | lcode.c | 8 | ||||
-rw-r--r-- | lcode.h | 4 | ||||
-rw-r--r-- | lobject.c | 4 | ||||
-rw-r--r-- | lopcodes.c | 6 | ||||
-rw-r--r-- | lopcodes.h | 4 | ||||
-rw-r--r-- | lparser.c | 4 | ||||
-rw-r--r-- | lstrlib.c | 4 | ||||
-rw-r--r-- | ltable.c | 10 | ||||
-rw-r--r-- | ltm.c | 4 | ||||
-rw-r--r-- | ltm.h | 4 | ||||
-rw-r--r-- | luaconf.h | 26 | ||||
-rw-r--r-- | lvm.c | 46 |
13 files changed, 63 insertions, 71 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.175 2005/05/16 21:19:00 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.176 2005/05/17 19:49:15 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -331,13 +331,6 @@ static int luaB_assert (lua_State *L) { | |||
331 | } | 331 | } |
332 | 332 | ||
333 | 333 | ||
334 | static int luaB_getn (lua_State *L) { | ||
335 | luaL_checktype(L, 1, LUA_TTABLE); | ||
336 | lua_pushinteger(L, lua_objsize(L, 1)); | ||
337 | return 1; | ||
338 | } | ||
339 | |||
340 | |||
341 | static int luaB_unpack (lua_State *L) { | 334 | static int luaB_unpack (lua_State *L) { |
342 | int i = luaL_optint(L, 2, 1); | 335 | int i = luaL_optint(L, 2, 1); |
343 | int e = luaL_optint(L, 3, -1); | 336 | int e = luaL_optint(L, 3, -1); |
@@ -454,7 +447,6 @@ static const luaL_reg base_funcs[] = { | |||
454 | {"tostring", luaB_tostring}, | 447 | {"tostring", luaB_tostring}, |
455 | {"type", luaB_type}, | 448 | {"type", luaB_type}, |
456 | {"assert", luaB_assert}, | 449 | {"assert", luaB_assert}, |
457 | {"getn", luaB_getn}, | ||
458 | {"unpack", luaB_unpack}, | 450 | {"unpack", luaB_unpack}, |
459 | {"select", luaB_select}, | 451 | {"select", luaB_select}, |
460 | {"rawequal", luaB_rawequal}, | 452 | {"rawequal", luaB_rawequal}, |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 2.11 2005/03/09 16:28:07 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 2.12 2005/03/16 16:59:21 roberto Exp roberto $ |
3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -607,7 +607,7 @@ void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { | |||
607 | case OPR_MINUS: { | 607 | case OPR_MINUS: { |
608 | luaK_exp2val(fs, e); | 608 | luaK_exp2val(fs, e); |
609 | if (e->k == VK && ttisnumber(&fs->f->k[e->info])) | 609 | if (e->k == VK && ttisnumber(&fs->f->k[e->info])) |
610 | e->info = luaK_numberK(fs, luai_numunm(nvalue(&fs->f->k[e->info]))); | 610 | e->info = luaK_numberK(fs, luai_numunm(L, nvalue(&fs->f->k[e->info]))); |
611 | else { | 611 | else { |
612 | luaK_exp2anyreg(fs, e); | 612 | luaK_exp2anyreg(fs, e); |
613 | freeexp(fs, e); | 613 | freeexp(fs, e); |
@@ -620,10 +620,10 @@ void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { | |||
620 | codenot(fs, e); | 620 | codenot(fs, e); |
621 | break; | 621 | break; |
622 | } | 622 | } |
623 | case OPR_SIZE: { | 623 | case OPR_LEN: { |
624 | luaK_exp2anyreg(fs, e); | 624 | luaK_exp2anyreg(fs, e); |
625 | freeexp(fs, e); | 625 | freeexp(fs, e); |
626 | e->info = luaK_codeABC(fs, OP_SIZ, 0, e->info, 0); | 626 | e->info = luaK_codeABC(fs, OP_LEN, 0, e->info, 0); |
627 | e->k = VRELOCABLE; | 627 | e->k = VRELOCABLE; |
628 | break; | 628 | break; |
629 | } | 629 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.h,v 1.42 2005/03/16 16:59:21 roberto Exp roberto $ | 2 | ** $Id: lcode.h,v 1.43 2005/04/25 19:24:10 roberto Exp roberto $ |
3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -34,7 +34,7 @@ typedef enum BinOpr { | |||
34 | 34 | ||
35 | #define binopistest(op) ((op) >= OPR_NE) | 35 | #define binopistest(op) ((op) >= OPR_NE) |
36 | 36 | ||
37 | typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_SIZE, OPR_NOUNOPR } UnOpr; | 37 | typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; |
38 | 38 | ||
39 | 39 | ||
40 | #define getcode(fs,e) ((fs)->f->code[(e)->info]) | 40 | #define getcode(fs,e) ((fs)->f->code[(e)->info]) |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.c,v 2.12 2005/03/28 12:53:40 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 2.13 2005/05/16 21:19:00 roberto Exp roberto $ |
3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -75,7 +75,7 @@ int luaO_rawequalObj (const TValue *t1, const TValue *t2) { | |||
75 | case LUA_TNIL: | 75 | case LUA_TNIL: |
76 | return 1; | 76 | return 1; |
77 | case LUA_TNUMBER: | 77 | case LUA_TNUMBER: |
78 | return luai_numeq(nvalue(t1), nvalue(t2)); | 78 | return luai_numeq(L, nvalue(t1), nvalue(t2)); |
79 | case LUA_TBOOLEAN: | 79 | case LUA_TBOOLEAN: |
80 | return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */ | 80 | return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */ |
81 | case LUA_TLIGHTUSERDATA: | 81 | case LUA_TLIGHTUSERDATA: |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lopcodes.c,v 1.32 2005/03/16 16:59:21 roberto Exp roberto $ | 2 | ** $Id: lopcodes.c,v 1.33 2005/05/04 20:42:28 roberto Exp roberto $ |
3 | ** See Copyright Notice in lua.h | 3 | ** See Copyright Notice in lua.h |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -36,7 +36,7 @@ const char *const luaP_opnames[NUM_OPCODES+1] = { | |||
36 | "POW", | 36 | "POW", |
37 | "UNM", | 37 | "UNM", |
38 | "NOT", | 38 | "NOT", |
39 | "SIZ", | 39 | "LEN", |
40 | "CONCAT", | 40 | "CONCAT", |
41 | "JMP", | 41 | "JMP", |
42 | "EQ", | 42 | "EQ", |
@@ -81,7 +81,7 @@ const lu_byte luaP_opmodes[NUM_OPCODES] = { | |||
81 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ | 81 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ |
82 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ | 82 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ |
83 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ | 83 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ |
84 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_SIZ */ | 84 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ |
85 | ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ | 85 | ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ |
86 | ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ | 86 | ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ |
87 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ | 87 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lopcodes.h,v 1.118 2005/03/16 16:59:21 roberto Exp roberto $ | 2 | ** $Id: lopcodes.h,v 1.119 2005/05/04 20:42:28 roberto Exp roberto $ |
3 | ** Opcodes for Lua virtual machine | 3 | ** Opcodes for Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -176,7 +176,7 @@ OP_MOD,/* A B C R(A) := RK(B) % RK(C) */ | |||
176 | OP_POW,/* A B C R(A) := RK(B) ^ RK(C) */ | 176 | OP_POW,/* A B C R(A) := RK(B) ^ RK(C) */ |
177 | OP_UNM,/* A B R(A) := -R(B) */ | 177 | OP_UNM,/* A B R(A) := -R(B) */ |
178 | OP_NOT,/* A B R(A) := not R(B) */ | 178 | OP_NOT,/* A B R(A) := not R(B) */ |
179 | OP_SIZ,/* A B R(A) := size of R(B) */ | 179 | OP_LEN,/* A B R(A) := length of R(B) */ |
180 | 180 | ||
181 | OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */ | 181 | OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */ |
182 | 182 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 2.26 2005/05/16 21:19:00 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 2.27 2005/05/17 19:49:15 roberto Exp roberto $ |
3 | ** Lua Parser | 3 | ** Lua Parser |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -792,7 +792,7 @@ static UnOpr getunopr (int op) { | |||
792 | switch (op) { | 792 | switch (op) { |
793 | case TK_NOT: return OPR_NOT; | 793 | case TK_NOT: return OPR_NOT; |
794 | case '-': return OPR_MINUS; | 794 | case '-': return OPR_MINUS; |
795 | case '*': return OPR_SIZE; | 795 | case '*': return OPR_LEN; |
796 | default: return OPR_NOUNOPR; | 796 | default: return OPR_NOUNOPR; |
797 | } | 797 | } |
798 | } | 798 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstrlib.c,v 1.114 2005/05/16 21:19:00 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.115 2005/05/17 19:49:15 roberto Exp roberto $ |
3 | ** Standard library for string operations and pattern-matching | 3 | ** Standard library for string operations and pattern-matching |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -780,7 +780,7 @@ static void createmetatable (lua_State *L) { | |||
780 | lua_pushvalue(L, -2); /* string library... */ | 780 | lua_pushvalue(L, -2); /* string library... */ |
781 | lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */ | 781 | lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */ |
782 | lua_getfield(L, -2, "len"); | 782 | lua_getfield(L, -2, "len"); |
783 | lua_setfield(L, -2, "__siz"); | 783 | lua_setfield(L, -2, "__len"); |
784 | lua_pop(L, 1); /* pop metatable */ | 784 | lua_pop(L, 1); /* pop metatable */ |
785 | } | 785 | } |
786 | 786 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 2.22 2005/05/16 21:19:00 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 2.23 2005/05/17 19:49:15 roberto Exp roberto $ |
3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -120,7 +120,7 @@ static int arrayindex (const TValue *key) { | |||
120 | lua_Number n = nvalue(key); | 120 | lua_Number n = nvalue(key); |
121 | int k; | 121 | int k; |
122 | lua_number2int(k, n); | 122 | lua_number2int(k, n); |
123 | if (luai_numeq(cast(lua_Number, k), nvalue(key))) | 123 | if (luai_numeq(L, cast(lua_Number, k), nvalue(key))) |
124 | return k; | 124 | return k; |
125 | } | 125 | } |
126 | return -1; /* `key' did not match some condition */ | 126 | return -1; /* `key' did not match some condition */ |
@@ -437,7 +437,7 @@ const TValue *luaH_getnum (Table *t, int key) { | |||
437 | lua_Number nk = cast(lua_Number, key); | 437 | lua_Number nk = cast(lua_Number, key); |
438 | Node *n = hashnum(t, nk); | 438 | Node *n = hashnum(t, nk); |
439 | do { /* check whether `key' is somewhere in the chain */ | 439 | do { /* check whether `key' is somewhere in the chain */ |
440 | if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk)) | 440 | if (ttisnumber(gkey(n)) && luai_numeq(L, nvalue(gkey(n)), nk)) |
441 | return gval(n); /* that's it */ | 441 | return gval(n); /* that's it */ |
442 | else n = gnext(n); | 442 | else n = gnext(n); |
443 | } while (n); | 443 | } while (n); |
@@ -471,7 +471,7 @@ const TValue *luaH_get (Table *t, const TValue *key) { | |||
471 | int k; | 471 | int k; |
472 | lua_Number n = nvalue(key); | 472 | lua_Number n = nvalue(key); |
473 | lua_number2int(k, n); | 473 | lua_number2int(k, n); |
474 | if (luai_numeq(cast(lua_Number, k), nvalue(key))) /* index is integer? */ | 474 | if (luai_numeq(L, cast(lua_Number, k), nvalue(key))) /* index is int? */ |
475 | return luaH_getnum(t, k); /* use specialized version */ | 475 | return luaH_getnum(t, k); /* use specialized version */ |
476 | /* else go through */ | 476 | /* else go through */ |
477 | } | 477 | } |
@@ -495,7 +495,7 @@ TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { | |||
495 | return cast(TValue *, p); | 495 | return cast(TValue *, p); |
496 | else { | 496 | else { |
497 | if (ttisnil(key)) luaG_runerror(L, "table index is nil"); | 497 | if (ttisnil(key)) luaG_runerror(L, "table index is nil"); |
498 | else if (ttisnumber(key) && !luai_numeq(nvalue(key), nvalue(key))) | 498 | else if (ttisnumber(key) && !luai_numeq(L, nvalue(key), nvalue(key))) |
499 | luaG_runerror(L, "table index is NaN"); | 499 | luaG_runerror(L, "table index is NaN"); |
500 | return newkey(L, t, key); | 500 | return newkey(L, t, key); |
501 | } | 501 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltm.c,v 2.4 2005/03/08 18:00:16 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 2.5 2005/05/05 15:34:03 roberto Exp roberto $ |
3 | ** Tag methods | 3 | ** Tag methods |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -32,7 +32,7 @@ void luaT_init (lua_State *L) { | |||
32 | "__index", "__newindex", | 32 | "__index", "__newindex", |
33 | "__gc", "__mode", "__eq", | 33 | "__gc", "__mode", "__eq", |
34 | "__add", "__sub", "__mul", "__div", "__mod", | 34 | "__add", "__sub", "__mul", "__div", "__mod", |
35 | "__pow", "__unm", "__siz", "__lt", "__le", | 35 | "__pow", "__unm", "__len", "__lt", "__le", |
36 | "__concat", "__call" | 36 | "__concat", "__call" |
37 | }; | 37 | }; |
38 | int i; | 38 | int i; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltm.h,v 2.3 2005/04/25 19:24:10 roberto Exp roberto $ | 2 | ** $Id: ltm.h,v 2.4 2005/05/05 15:34:03 roberto Exp roberto $ |
3 | ** Tag methods | 3 | ** Tag methods |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -28,7 +28,7 @@ typedef enum { | |||
28 | TM_MOD, | 28 | TM_MOD, |
29 | TM_POW, | 29 | TM_POW, |
30 | TM_UNM, | 30 | TM_UNM, |
31 | TM_SIZ, | 31 | TM_LEN, |
32 | TM_LT, | 32 | TM_LT, |
33 | TM_LE, | 33 | TM_LE, |
34 | TM_CONCAT, | 34 | TM_CONCAT, |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: luaconf.h,v 1.48 2005/05/16 21:19:00 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.49 2005/05/17 19:49:15 roberto Exp roberto $ |
3 | ** Configuration file for Lua | 3 | ** Configuration file for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -437,8 +437,8 @@ | |||
437 | /* On Windows/Pentium, resort to assembler */ | 437 | /* On Windows/Pentium, resort to assembler */ |
438 | #elif !defined(__STRICT_ANSI__) && defined(_MSC_VER) && defined(_M_IX86) | 438 | #elif !defined(__STRICT_ANSI__) && defined(_MSC_VER) && defined(_M_IX86) |
439 | #define lua_number2int(i,d) \ | 439 | #define lua_number2int(i,d) \ |
440 | __asm fld d; \ | 440 | __asm fld d \ |
441 | __asm fistp i; | 441 | __asm fistp i |
442 | 442 | ||
443 | 443 | ||
444 | /* on Pentium machines compliant with C99, you can try lrint */ | 444 | /* on Pentium machines compliant with C99, you can try lrint */ |
@@ -505,16 +505,16 @@ | |||
505 | /* | 505 | /* |
506 | @@ The luai_num* macros define the primitive operations over numbers. | 506 | @@ The luai_num* macros define the primitive operations over numbers. |
507 | */ | 507 | */ |
508 | #define luai_numadd(a,b) ((a)+(b)) | 508 | #define luai_numadd(L,a,b) ((a)+(b)) |
509 | #define luai_numsub(a,b) ((a)-(b)) | 509 | #define luai_numsub(L,a,b) ((a)-(b)) |
510 | #define luai_nummul(a,b) ((a)*(b)) | 510 | #define luai_nummul(L,a,b) ((a)*(b)) |
511 | #define luai_numdiv(a,b) ((a)/(b)) | 511 | #define luai_numdiv(L,a,b) ((a)/(b)) |
512 | #define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) | 512 | #define luai_nummod(L,a,b) ((a) - floor((a)/(b))*(b)) |
513 | #define luai_numpow(a,b) pow(a,b) | 513 | #define luai_numpow(L,a,b) pow(a,b) |
514 | #define luai_numunm(a) (-(a)) | 514 | #define luai_numunm(L,a) (-(a)) |
515 | #define luai_numeq(a,b) ((a)==(b)) | 515 | #define luai_numeq(L,a,b) ((a)==(b)) |
516 | #define luai_numlt(a,b) ((a)<(b)) | 516 | #define luai_numlt(L,a,b) ((a)<(b)) |
517 | #define luai_numle(a,b) ((a)<=(b)) | 517 | #define luai_numle(L,a,b) ((a)<=(b)) |
518 | 518 | ||
519 | /* }================================================================== */ | 519 | /* }================================================================== */ |
520 | 520 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.43 2005/05/16 21:19:00 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.44 2005/05/17 19:49:15 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 | */ |
@@ -226,7 +226,7 @@ int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { | |||
226 | if (ttype(l) != ttype(r)) | 226 | if (ttype(l) != ttype(r)) |
227 | return luaG_ordererror(L, l, r); | 227 | return luaG_ordererror(L, l, r); |
228 | else if (ttisnumber(l)) | 228 | else if (ttisnumber(l)) |
229 | return luai_numlt(nvalue(l), nvalue(r)); | 229 | return luai_numlt(L, nvalue(l), nvalue(r)); |
230 | else if (ttisstring(l)) | 230 | else if (ttisstring(l)) |
231 | return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; | 231 | return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; |
232 | else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) | 232 | else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) |
@@ -240,7 +240,7 @@ static int lessequal (lua_State *L, const TValue *l, const TValue *r) { | |||
240 | if (ttype(l) != ttype(r)) | 240 | if (ttype(l) != ttype(r)) |
241 | return luaG_ordererror(L, l, r); | 241 | return luaG_ordererror(L, l, r); |
242 | else if (ttisnumber(l)) | 242 | else if (ttisnumber(l)) |
243 | return luai_numle(nvalue(l), nvalue(r)); | 243 | return luai_numle(L, nvalue(l), nvalue(r)); |
244 | else if (ttisstring(l)) | 244 | else if (ttisstring(l)) |
245 | return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; | 245 | return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; |
246 | else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ | 246 | else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ |
@@ -256,7 +256,7 @@ int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) { | |||
256 | lua_assert(ttype(t1) == ttype(t2)); | 256 | lua_assert(ttype(t1) == ttype(t2)); |
257 | switch (ttype(t1)) { | 257 | switch (ttype(t1)) { |
258 | case LUA_TNIL: return 1; | 258 | case LUA_TNIL: return 1; |
259 | case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2)); | 259 | case LUA_TNUMBER: return luai_numeq(L, nvalue(t1), nvalue(t2)); |
260 | case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ | 260 | case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ |
261 | case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); | 261 | case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); |
262 | case LUA_TUSERDATA: { | 262 | case LUA_TUSERDATA: { |
@@ -319,12 +319,12 @@ static StkId Arith (lua_State *L, StkId ra, const TValue *rb, | |||
319 | (c = luaV_tonumber(rc, &tempc)) != NULL) { | 319 | (c = luaV_tonumber(rc, &tempc)) != NULL) { |
320 | lua_Number nb = nvalue(b), nc = nvalue(c); | 320 | lua_Number nb = nvalue(b), nc = nvalue(c); |
321 | switch (op) { | 321 | switch (op) { |
322 | case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break; | 322 | case TM_ADD: setnvalue(ra, luai_numadd(L, nb, nc)); break; |
323 | case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break; | 323 | case TM_SUB: setnvalue(ra, luai_numsub(L, nb, nc)); break; |
324 | case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break; | 324 | case TM_MUL: setnvalue(ra, luai_nummul(L, nb, nc)); break; |
325 | case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break; | 325 | case TM_DIV: setnvalue(ra, luai_numdiv(L, nb, nc)); break; |
326 | case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break; | 326 | case TM_MOD: setnvalue(ra, luai_nummod(L, nb, nc)); break; |
327 | case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break; | 327 | case TM_POW: setnvalue(ra, luai_numpow(L, nb, nc)); break; |
328 | default: lua_assert(0); break; | 328 | default: lua_assert(0); break; |
329 | } | 329 | } |
330 | } | 330 | } |
@@ -462,7 +462,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
462 | TValue *rc = RKC(i); | 462 | TValue *rc = RKC(i); |
463 | if (ttisnumber(rb) && ttisnumber(rc)) { | 463 | if (ttisnumber(rb) && ttisnumber(rc)) { |
464 | lua_Number nb = nvalue(rb), nc = nvalue(rc); | 464 | lua_Number nb = nvalue(rb), nc = nvalue(rc); |
465 | setnvalue(ra, luai_numadd(nb, nc)); | 465 | setnvalue(ra, luai_numadd(L, nb, nc)); |
466 | } | 466 | } |
467 | else | 467 | else |
468 | Protect(Arith(L, ra, rb, rc, TM_ADD)); | 468 | Protect(Arith(L, ra, rb, rc, TM_ADD)); |
@@ -473,7 +473,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
473 | TValue *rc = RKC(i); | 473 | TValue *rc = RKC(i); |
474 | if (ttisnumber(rb) && ttisnumber(rc)) { | 474 | if (ttisnumber(rb) && ttisnumber(rc)) { |
475 | lua_Number nb = nvalue(rb), nc = nvalue(rc); | 475 | lua_Number nb = nvalue(rb), nc = nvalue(rc); |
476 | setnvalue(ra, luai_numsub(nb, nc)); | 476 | setnvalue(ra, luai_numsub(L, nb, nc)); |
477 | } | 477 | } |
478 | else | 478 | else |
479 | Protect(Arith(L, ra, rb, rc, TM_SUB)); | 479 | Protect(Arith(L, ra, rb, rc, TM_SUB)); |
@@ -484,7 +484,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
484 | TValue *rc = RKC(i); | 484 | TValue *rc = RKC(i); |
485 | if (ttisnumber(rb) && ttisnumber(rc)) { | 485 | if (ttisnumber(rb) && ttisnumber(rc)) { |
486 | lua_Number nb = nvalue(rb), nc = nvalue(rc); | 486 | lua_Number nb = nvalue(rb), nc = nvalue(rc); |
487 | setnvalue(ra, luai_nummul(nb, nc)); | 487 | setnvalue(ra, luai_nummul(L, nb, nc)); |
488 | } | 488 | } |
489 | else | 489 | else |
490 | Protect(Arith(L, ra, rb, rc, TM_MUL)); | 490 | Protect(Arith(L, ra, rb, rc, TM_MUL)); |
@@ -495,7 +495,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
495 | TValue *rc = RKC(i); | 495 | TValue *rc = RKC(i); |
496 | if (ttisnumber(rb) && ttisnumber(rc)) { | 496 | if (ttisnumber(rb) && ttisnumber(rc)) { |
497 | lua_Number nb = nvalue(rb), nc = nvalue(rc); | 497 | lua_Number nb = nvalue(rb), nc = nvalue(rc); |
498 | setnvalue(ra, luai_numdiv(nb, nc)); | 498 | setnvalue(ra, luai_numdiv(L, nb, nc)); |
499 | } | 499 | } |
500 | else | 500 | else |
501 | Protect(Arith(L, ra, rb, rc, TM_DIV)); | 501 | Protect(Arith(L, ra, rb, rc, TM_DIV)); |
@@ -506,7 +506,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
506 | TValue *rc = RKC(i); | 506 | TValue *rc = RKC(i); |
507 | if (ttisnumber(rb) && ttisnumber(rc)) { | 507 | if (ttisnumber(rb) && ttisnumber(rc)) { |
508 | lua_Number nb = nvalue(rb), nc = nvalue(rc); | 508 | lua_Number nb = nvalue(rb), nc = nvalue(rc); |
509 | setnvalue(ra, luai_nummod(nb, nc)); | 509 | setnvalue(ra, luai_nummod(L, nb, nc)); |
510 | } | 510 | } |
511 | else | 511 | else |
512 | Protect(Arith(L, ra, rb, rc, TM_MOD)); | 512 | Protect(Arith(L, ra, rb, rc, TM_MOD)); |
@@ -517,7 +517,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
517 | TValue *rc = RKC(i); | 517 | TValue *rc = RKC(i); |
518 | if (ttisnumber(rb) && ttisnumber(rc)) { | 518 | if (ttisnumber(rb) && ttisnumber(rc)) { |
519 | lua_Number nb = nvalue(rb), nc = nvalue(rc); | 519 | lua_Number nb = nvalue(rb), nc = nvalue(rc); |
520 | setnvalue(ra, luai_numpow(nb, nc)); | 520 | setnvalue(ra, luai_numpow(L, nb, nc)); |
521 | } | 521 | } |
522 | else | 522 | else |
523 | Protect(Arith(L, ra, rb, rc, TM_POW)); | 523 | Protect(Arith(L, ra, rb, rc, TM_POW)); |
@@ -528,7 +528,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
528 | TValue temp; | 528 | TValue temp; |
529 | if (tonumber(rb, &temp)) { | 529 | if (tonumber(rb, &temp)) { |
530 | lua_Number nb = nvalue(rb); | 530 | lua_Number nb = nvalue(rb); |
531 | setnvalue(ra, luai_numunm(nb)); | 531 | setnvalue(ra, luai_numunm(L, nb)); |
532 | } | 532 | } |
533 | else { | 533 | else { |
534 | rb = RB(i); /* `tonumber' erased `rb' */ | 534 | rb = RB(i); /* `tonumber' erased `rb' */ |
@@ -544,15 +544,15 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
544 | setbvalue(ra, res); | 544 | setbvalue(ra, res); |
545 | continue; | 545 | continue; |
546 | } | 546 | } |
547 | case OP_SIZ: { | 547 | case OP_LEN: { |
548 | const TValue *rb = RB(i); | 548 | const TValue *rb = RB(i); |
549 | if (ttype(rb) == LUA_TTABLE) { | 549 | if (ttype(rb) == LUA_TTABLE) { |
550 | setnvalue(ra, cast(lua_Number, luaH_getn(hvalue(rb)))); | 550 | setnvalue(ra, cast(lua_Number, luaH_getn(hvalue(rb)))); |
551 | } | 551 | } |
552 | else { /* try metamethod */ | 552 | else { /* try metamethod */ |
553 | Protect( | 553 | Protect( |
554 | if (!call_binTM(L, rb, &luaO_nilobject, ra, TM_SIZ)) | 554 | if (!call_binTM(L, rb, &luaO_nilobject, ra, TM_LEN)) |
555 | luaG_typeerror(L, rb, "get size of"); | 555 | luaG_typeerror(L, rb, "get length of"); |
556 | ) | 556 | ) |
557 | } | 557 | } |
558 | continue; | 558 | continue; |
@@ -673,9 +673,9 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
673 | } | 673 | } |
674 | case OP_FORLOOP: { | 674 | case OP_FORLOOP: { |
675 | lua_Number step = nvalue(ra+2); | 675 | lua_Number step = nvalue(ra+2); |
676 | lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */ | 676 | lua_Number idx = luai_numadd(L, nvalue(ra), step); /* increment index */ |
677 | lua_Number limit = nvalue(ra+1); | 677 | lua_Number limit = nvalue(ra+1); |
678 | if (step > 0 ? luai_numle(idx, limit) : luai_numle(limit, idx)) { | 678 | if (step > 0 ? luai_numle(L, idx, limit) : luai_numle(L, limit, idx)) { |
679 | dojump(L, pc, GETARG_sBx(i)); /* jump back */ | 679 | dojump(L, pc, GETARG_sBx(i)); /* jump back */ |
680 | setnvalue(ra, idx); /* update internal index... */ | 680 | setnvalue(ra, idx); /* update internal index... */ |
681 | setnvalue(ra+3, idx); /* ...and external index */ | 681 | setnvalue(ra+3, idx); /* ...and external index */ |
@@ -693,7 +693,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
693 | luaG_runerror(L, LUA_QL("for") " limit must be a number"); | 693 | luaG_runerror(L, LUA_QL("for") " limit must be a number"); |
694 | else if (!tonumber(pstep, ra+2)) | 694 | else if (!tonumber(pstep, ra+2)) |
695 | luaG_runerror(L, LUA_QL("for") " step must be a number"); | 695 | luaG_runerror(L, LUA_QL("for") " step must be a number"); |
696 | setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); | 696 | setnvalue(ra, luai_numsub(L, nvalue(ra), nvalue(pstep))); |
697 | dojump(L, pc, GETARG_sBx(i)); | 697 | dojump(L, pc, GETARG_sBx(i)); |
698 | continue; | 698 | continue; |
699 | } | 699 | } |