Skip to content

Commit

Permalink
details
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto-ieru committed May 20, 2005
1 parent 67578ec commit f21e9c1
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 71 deletions.
10 changes: 1 addition & 9 deletions lbaselib.c
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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},
Expand Down
8 changes: 4 additions & 4 deletions lcode.c
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions lcode.h
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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])
Expand Down
4 changes: 2 additions & 2 deletions lobject.c
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions lopcodes.c
Original file line number Diff line number Diff line change
@@ -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
*/

Expand Down Expand Up @@ -36,7 +36,7 @@ const char *const luaP_opnames[NUM_OPCODES+1] = {
"POW",
"UNM",
"NOT",
"SIZ",
"LEN",
"CONCAT",
"JMP",
"EQ",
Expand Down Expand Up @@ -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 */
Expand Down
4 changes: 2 additions & 2 deletions lopcodes.h
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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) */

Expand Down
4 changes: 2 additions & 2 deletions lparser.c
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions lstrlib.c
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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 */
}

Expand Down
10 changes: 5 additions & 5 deletions ltable.c
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
}
Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions ltm.c
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions ltm.h
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -28,7 +28,7 @@ typedef enum {
TM_MOD,
TM_POW,
TM_UNM,
TM_SIZ,
TM_LEN,
TM_LT,
TM_LE,
TM_CONCAT,
Expand Down
26 changes: 13 additions & 13 deletions luaconf.h
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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))

/* }================================================================== */

Expand Down
Loading

0 comments on commit f21e9c1

Please sign in to comment.