mirror of
https://github.com/lua/lua.git
synced 2024-11-27 12:13:38 +08:00
details
This commit is contained in:
parent
67578ec51f
commit
f21e9c172f
10
lbaselib.c
10
lbaselib.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lbaselib.c,v 1.175 2005/05/16 21:19:00 roberto Exp roberto $
|
||||
** $Id: lbaselib.c,v 1.176 2005/05/17 19:49:15 roberto Exp roberto $
|
||||
** Basic library
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -331,13 +331,6 @@ static int luaB_assert (lua_State *L) {
|
||||
}
|
||||
|
||||
|
||||
static int luaB_getn (lua_State *L) {
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
lua_pushinteger(L, lua_objsize(L, 1));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int luaB_unpack (lua_State *L) {
|
||||
int i = luaL_optint(L, 2, 1);
|
||||
int e = luaL_optint(L, 3, -1);
|
||||
@ -454,7 +447,6 @@ static const luaL_reg base_funcs[] = {
|
||||
{"tostring", luaB_tostring},
|
||||
{"type", luaB_type},
|
||||
{"assert", luaB_assert},
|
||||
{"getn", luaB_getn},
|
||||
{"unpack", luaB_unpack},
|
||||
{"select", luaB_select},
|
||||
{"rawequal", luaB_rawequal},
|
||||
|
8
lcode.c
8
lcode.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lcode.c,v 2.11 2005/03/09 16:28:07 roberto Exp roberto $
|
||||
** $Id: lcode.c,v 2.12 2005/03/16 16:59:21 roberto Exp roberto $
|
||||
** Code generator for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -607,7 +607,7 @@ void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
|
||||
case OPR_MINUS: {
|
||||
luaK_exp2val(fs, e);
|
||||
if (e->k == VK && ttisnumber(&fs->f->k[e->info]))
|
||||
e->info = luaK_numberK(fs, luai_numunm(nvalue(&fs->f->k[e->info])));
|
||||
e->info = luaK_numberK(fs, luai_numunm(L, nvalue(&fs->f->k[e->info])));
|
||||
else {
|
||||
luaK_exp2anyreg(fs, e);
|
||||
freeexp(fs, e);
|
||||
@ -620,10 +620,10 @@ void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
|
||||
codenot(fs, e);
|
||||
break;
|
||||
}
|
||||
case OPR_SIZE: {
|
||||
case OPR_LEN: {
|
||||
luaK_exp2anyreg(fs, e);
|
||||
freeexp(fs, e);
|
||||
e->info = luaK_codeABC(fs, OP_SIZ, 0, e->info, 0);
|
||||
e->info = luaK_codeABC(fs, OP_LEN, 0, e->info, 0);
|
||||
e->k = VRELOCABLE;
|
||||
break;
|
||||
}
|
||||
|
4
lcode.h
4
lcode.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lcode.h,v 1.42 2005/03/16 16:59:21 roberto Exp roberto $
|
||||
** $Id: lcode.h,v 1.43 2005/04/25 19:24:10 roberto Exp roberto $
|
||||
** Code generator for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -34,7 +34,7 @@ typedef enum BinOpr {
|
||||
|
||||
#define binopistest(op) ((op) >= OPR_NE)
|
||||
|
||||
typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_SIZE, OPR_NOUNOPR } UnOpr;
|
||||
typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
|
||||
|
||||
|
||||
#define getcode(fs,e) ((fs)->f->code[(e)->info])
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lobject.c,v 2.12 2005/03/28 12:53:40 roberto Exp roberto $
|
||||
** $Id: lobject.c,v 2.13 2005/05/16 21:19:00 roberto Exp roberto $
|
||||
** Some generic functions over Lua objects
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -75,7 +75,7 @@ int luaO_rawequalObj (const TValue *t1, const TValue *t2) {
|
||||
case LUA_TNIL:
|
||||
return 1;
|
||||
case LUA_TNUMBER:
|
||||
return luai_numeq(nvalue(t1), nvalue(t2));
|
||||
return luai_numeq(L, nvalue(t1), nvalue(t2));
|
||||
case LUA_TBOOLEAN:
|
||||
return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */
|
||||
case LUA_TLIGHTUSERDATA:
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lopcodes.c,v 1.32 2005/03/16 16:59:21 roberto Exp roberto $
|
||||
** $Id: lopcodes.c,v 1.33 2005/05/04 20:42:28 roberto Exp roberto $
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
@ -36,7 +36,7 @@ const char *const luaP_opnames[NUM_OPCODES+1] = {
|
||||
"POW",
|
||||
"UNM",
|
||||
"NOT",
|
||||
"SIZ",
|
||||
"LEN",
|
||||
"CONCAT",
|
||||
"JMP",
|
||||
"EQ",
|
||||
@ -81,7 +81,7 @@ const lu_byte luaP_opmodes[NUM_OPCODES] = {
|
||||
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */
|
||||
,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */
|
||||
,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */
|
||||
,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_SIZ */
|
||||
,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */
|
||||
,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */
|
||||
,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */
|
||||
,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lopcodes.h,v 1.118 2005/03/16 16:59:21 roberto Exp roberto $
|
||||
** $Id: lopcodes.h,v 1.119 2005/05/04 20:42:28 roberto Exp roberto $
|
||||
** Opcodes for Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -176,7 +176,7 @@ OP_MOD,/* A B C R(A) := RK(B) % RK(C) */
|
||||
OP_POW,/* A B C R(A) := RK(B) ^ RK(C) */
|
||||
OP_UNM,/* A B R(A) := -R(B) */
|
||||
OP_NOT,/* A B R(A) := not R(B) */
|
||||
OP_SIZ,/* A B R(A) := size of R(B) */
|
||||
OP_LEN,/* A B R(A) := length of R(B) */
|
||||
|
||||
OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lparser.c,v 2.26 2005/05/16 21:19:00 roberto Exp roberto $
|
||||
** $Id: lparser.c,v 2.27 2005/05/17 19:49:15 roberto Exp roberto $
|
||||
** Lua Parser
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -792,7 +792,7 @@ static UnOpr getunopr (int op) {
|
||||
switch (op) {
|
||||
case TK_NOT: return OPR_NOT;
|
||||
case '-': return OPR_MINUS;
|
||||
case '*': return OPR_SIZE;
|
||||
case '*': return OPR_LEN;
|
||||
default: return OPR_NOUNOPR;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lstrlib.c,v 1.114 2005/05/16 21:19:00 roberto Exp roberto $
|
||||
** $Id: lstrlib.c,v 1.115 2005/05/17 19:49:15 roberto Exp roberto $
|
||||
** Standard library for string operations and pattern-matching
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -780,7 +780,7 @@ static void createmetatable (lua_State *L) {
|
||||
lua_pushvalue(L, -2); /* string library... */
|
||||
lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */
|
||||
lua_getfield(L, -2, "len");
|
||||
lua_setfield(L, -2, "__siz");
|
||||
lua_setfield(L, -2, "__len");
|
||||
lua_pop(L, 1); /* pop metatable */
|
||||
}
|
||||
|
||||
|
10
ltable.c
10
ltable.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ltable.c,v 2.22 2005/05/16 21:19:00 roberto Exp roberto $
|
||||
** $Id: ltable.c,v 2.23 2005/05/17 19:49:15 roberto Exp roberto $
|
||||
** Lua tables (hash)
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -120,7 +120,7 @@ static int arrayindex (const TValue *key) {
|
||||
lua_Number n = nvalue(key);
|
||||
int k;
|
||||
lua_number2int(k, n);
|
||||
if (luai_numeq(cast(lua_Number, k), nvalue(key)))
|
||||
if (luai_numeq(L, cast(lua_Number, k), nvalue(key)))
|
||||
return k;
|
||||
}
|
||||
return -1; /* `key' did not match some condition */
|
||||
@ -437,7 +437,7 @@ const TValue *luaH_getnum (Table *t, int key) {
|
||||
lua_Number nk = cast(lua_Number, key);
|
||||
Node *n = hashnum(t, nk);
|
||||
do { /* check whether `key' is somewhere in the chain */
|
||||
if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk))
|
||||
if (ttisnumber(gkey(n)) && luai_numeq(L, nvalue(gkey(n)), nk))
|
||||
return gval(n); /* that's it */
|
||||
else n = gnext(n);
|
||||
} while (n);
|
||||
@ -471,7 +471,7 @@ const TValue *luaH_get (Table *t, const TValue *key) {
|
||||
int k;
|
||||
lua_Number n = nvalue(key);
|
||||
lua_number2int(k, n);
|
||||
if (luai_numeq(cast(lua_Number, k), nvalue(key))) /* index is integer? */
|
||||
if (luai_numeq(L, cast(lua_Number, k), nvalue(key))) /* index is int? */
|
||||
return luaH_getnum(t, k); /* use specialized version */
|
||||
/* else go through */
|
||||
}
|
||||
@ -495,7 +495,7 @@ TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
|
||||
return cast(TValue *, p);
|
||||
else {
|
||||
if (ttisnil(key)) luaG_runerror(L, "table index is nil");
|
||||
else if (ttisnumber(key) && !luai_numeq(nvalue(key), nvalue(key)))
|
||||
else if (ttisnumber(key) && !luai_numeq(L, nvalue(key), nvalue(key)))
|
||||
luaG_runerror(L, "table index is NaN");
|
||||
return newkey(L, t, key);
|
||||
}
|
||||
|
4
ltm.c
4
ltm.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ltm.c,v 2.4 2005/03/08 18:00:16 roberto Exp roberto $
|
||||
** $Id: ltm.c,v 2.5 2005/05/05 15:34:03 roberto Exp roberto $
|
||||
** Tag methods
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -32,7 +32,7 @@ void luaT_init (lua_State *L) {
|
||||
"__index", "__newindex",
|
||||
"__gc", "__mode", "__eq",
|
||||
"__add", "__sub", "__mul", "__div", "__mod",
|
||||
"__pow", "__unm", "__siz", "__lt", "__le",
|
||||
"__pow", "__unm", "__len", "__lt", "__le",
|
||||
"__concat", "__call"
|
||||
};
|
||||
int i;
|
||||
|
4
ltm.h
4
ltm.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ltm.h,v 2.3 2005/04/25 19:24:10 roberto Exp roberto $
|
||||
** $Id: ltm.h,v 2.4 2005/05/05 15:34:03 roberto Exp roberto $
|
||||
** Tag methods
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -28,7 +28,7 @@ typedef enum {
|
||||
TM_MOD,
|
||||
TM_POW,
|
||||
TM_UNM,
|
||||
TM_SIZ,
|
||||
TM_LEN,
|
||||
TM_LT,
|
||||
TM_LE,
|
||||
TM_CONCAT,
|
||||
|
26
luaconf.h
26
luaconf.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: luaconf.h,v 1.48 2005/05/16 21:19:00 roberto Exp roberto $
|
||||
** $Id: luaconf.h,v 1.49 2005/05/17 19:49:15 roberto Exp roberto $
|
||||
** Configuration file for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -437,8 +437,8 @@
|
||||
/* On Windows/Pentium, resort to assembler */
|
||||
#elif !defined(__STRICT_ANSI__) && defined(_MSC_VER) && defined(_M_IX86)
|
||||
#define lua_number2int(i,d) \
|
||||
__asm fld d; \
|
||||
__asm fistp i;
|
||||
__asm fld d \
|
||||
__asm fistp i
|
||||
|
||||
|
||||
/* on Pentium machines compliant with C99, you can try lrint */
|
||||
@ -505,16 +505,16 @@
|
||||
/*
|
||||
@@ The luai_num* macros define the primitive operations over numbers.
|
||||
*/
|
||||
#define luai_numadd(a,b) ((a)+(b))
|
||||
#define luai_numsub(a,b) ((a)-(b))
|
||||
#define luai_nummul(a,b) ((a)*(b))
|
||||
#define luai_numdiv(a,b) ((a)/(b))
|
||||
#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
|
||||
#define luai_numpow(a,b) pow(a,b)
|
||||
#define luai_numunm(a) (-(a))
|
||||
#define luai_numeq(a,b) ((a)==(b))
|
||||
#define luai_numlt(a,b) ((a)<(b))
|
||||
#define luai_numle(a,b) ((a)<=(b))
|
||||
#define luai_numadd(L,a,b) ((a)+(b))
|
||||
#define luai_numsub(L,a,b) ((a)-(b))
|
||||
#define luai_nummul(L,a,b) ((a)*(b))
|
||||
#define luai_numdiv(L,a,b) ((a)/(b))
|
||||
#define luai_nummod(L,a,b) ((a) - floor((a)/(b))*(b))
|
||||
#define luai_numpow(L,a,b) pow(a,b)
|
||||
#define luai_numunm(L,a) (-(a))
|
||||
#define luai_numeq(L,a,b) ((a)==(b))
|
||||
#define luai_numlt(L,a,b) ((a)<(b))
|
||||
#define luai_numle(L,a,b) ((a)<=(b))
|
||||
|
||||
/* }================================================================== */
|
||||
|
||||
|
46
lvm.c
46
lvm.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lvm.c,v 2.43 2005/05/16 21:19:00 roberto Exp roberto $
|
||||
** $Id: lvm.c,v 2.44 2005/05/17 19:49:15 roberto Exp roberto $
|
||||
** Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -226,7 +226,7 @@ int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
|
||||
if (ttype(l) != ttype(r))
|
||||
return luaG_ordererror(L, l, r);
|
||||
else if (ttisnumber(l))
|
||||
return luai_numlt(nvalue(l), nvalue(r));
|
||||
return luai_numlt(L, nvalue(l), nvalue(r));
|
||||
else if (ttisstring(l))
|
||||
return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
|
||||
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) {
|
||||
if (ttype(l) != ttype(r))
|
||||
return luaG_ordererror(L, l, r);
|
||||
else if (ttisnumber(l))
|
||||
return luai_numle(nvalue(l), nvalue(r));
|
||||
return luai_numle(L, nvalue(l), nvalue(r));
|
||||
else if (ttisstring(l))
|
||||
return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
|
||||
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) {
|
||||
lua_assert(ttype(t1) == ttype(t2));
|
||||
switch (ttype(t1)) {
|
||||
case LUA_TNIL: return 1;
|
||||
case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2));
|
||||
case LUA_TNUMBER: return luai_numeq(L, nvalue(t1), nvalue(t2));
|
||||
case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
|
||||
case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
|
||||
case LUA_TUSERDATA: {
|
||||
@ -319,12 +319,12 @@ static StkId Arith (lua_State *L, StkId ra, const TValue *rb,
|
||||
(c = luaV_tonumber(rc, &tempc)) != NULL) {
|
||||
lua_Number nb = nvalue(b), nc = nvalue(c);
|
||||
switch (op) {
|
||||
case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break;
|
||||
case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break;
|
||||
case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break;
|
||||
case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break;
|
||||
case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break;
|
||||
case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break;
|
||||
case TM_ADD: setnvalue(ra, luai_numadd(L, nb, nc)); break;
|
||||
case TM_SUB: setnvalue(ra, luai_numsub(L, nb, nc)); break;
|
||||
case TM_MUL: setnvalue(ra, luai_nummul(L, nb, nc)); break;
|
||||
case TM_DIV: setnvalue(ra, luai_numdiv(L, nb, nc)); break;
|
||||
case TM_MOD: setnvalue(ra, luai_nummod(L, nb, nc)); break;
|
||||
case TM_POW: setnvalue(ra, luai_numpow(L, nb, nc)); break;
|
||||
default: lua_assert(0); break;
|
||||
}
|
||||
}
|
||||
@ -462,7 +462,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
TValue *rc = RKC(i);
|
||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
||||
setnvalue(ra, luai_numadd(nb, nc));
|
||||
setnvalue(ra, luai_numadd(L, nb, nc));
|
||||
}
|
||||
else
|
||||
Protect(Arith(L, ra, rb, rc, TM_ADD));
|
||||
@ -473,7 +473,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
TValue *rc = RKC(i);
|
||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
||||
setnvalue(ra, luai_numsub(nb, nc));
|
||||
setnvalue(ra, luai_numsub(L, nb, nc));
|
||||
}
|
||||
else
|
||||
Protect(Arith(L, ra, rb, rc, TM_SUB));
|
||||
@ -484,7 +484,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
TValue *rc = RKC(i);
|
||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
||||
setnvalue(ra, luai_nummul(nb, nc));
|
||||
setnvalue(ra, luai_nummul(L, nb, nc));
|
||||
}
|
||||
else
|
||||
Protect(Arith(L, ra, rb, rc, TM_MUL));
|
||||
@ -495,7 +495,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
TValue *rc = RKC(i);
|
||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
||||
setnvalue(ra, luai_numdiv(nb, nc));
|
||||
setnvalue(ra, luai_numdiv(L, nb, nc));
|
||||
}
|
||||
else
|
||||
Protect(Arith(L, ra, rb, rc, TM_DIV));
|
||||
@ -506,7 +506,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
TValue *rc = RKC(i);
|
||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
||||
setnvalue(ra, luai_nummod(nb, nc));
|
||||
setnvalue(ra, luai_nummod(L, nb, nc));
|
||||
}
|
||||
else
|
||||
Protect(Arith(L, ra, rb, rc, TM_MOD));
|
||||
@ -517,7 +517,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
TValue *rc = RKC(i);
|
||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
||||
setnvalue(ra, luai_numpow(nb, nc));
|
||||
setnvalue(ra, luai_numpow(L, nb, nc));
|
||||
}
|
||||
else
|
||||
Protect(Arith(L, ra, rb, rc, TM_POW));
|
||||
@ -528,7 +528,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
TValue temp;
|
||||
if (tonumber(rb, &temp)) {
|
||||
lua_Number nb = nvalue(rb);
|
||||
setnvalue(ra, luai_numunm(nb));
|
||||
setnvalue(ra, luai_numunm(L, nb));
|
||||
}
|
||||
else {
|
||||
rb = RB(i); /* `tonumber' erased `rb' */
|
||||
@ -544,15 +544,15 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
setbvalue(ra, res);
|
||||
continue;
|
||||
}
|
||||
case OP_SIZ: {
|
||||
case OP_LEN: {
|
||||
const TValue *rb = RB(i);
|
||||
if (ttype(rb) == LUA_TTABLE) {
|
||||
setnvalue(ra, cast(lua_Number, luaH_getn(hvalue(rb))));
|
||||
}
|
||||
else { /* try metamethod */
|
||||
Protect(
|
||||
if (!call_binTM(L, rb, &luaO_nilobject, ra, TM_SIZ))
|
||||
luaG_typeerror(L, rb, "get size of");
|
||||
if (!call_binTM(L, rb, &luaO_nilobject, ra, TM_LEN))
|
||||
luaG_typeerror(L, rb, "get length of");
|
||||
)
|
||||
}
|
||||
continue;
|
||||
@ -673,9 +673,9 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
}
|
||||
case OP_FORLOOP: {
|
||||
lua_Number step = nvalue(ra+2);
|
||||
lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
|
||||
lua_Number idx = luai_numadd(L, nvalue(ra), step); /* increment index */
|
||||
lua_Number limit = nvalue(ra+1);
|
||||
if (step > 0 ? luai_numle(idx, limit) : luai_numle(limit, idx)) {
|
||||
if (step > 0 ? luai_numle(L, idx, limit) : luai_numle(L, limit, idx)) {
|
||||
dojump(L, pc, GETARG_sBx(i)); /* jump back */
|
||||
setnvalue(ra, idx); /* update internal index... */
|
||||
setnvalue(ra+3, idx); /* ...and external index */
|
||||
@ -693,7 +693,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||
luaG_runerror(L, LUA_QL("for") " limit must be a number");
|
||||
else if (!tonumber(pstep, ra+2))
|
||||
luaG_runerror(L, LUA_QL("for") " step must be a number");
|
||||
setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
|
||||
setnvalue(ra, luai_numsub(L, nvalue(ra), nvalue(pstep)));
|
||||
dojump(L, pc, GETARG_sBx(i));
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user