diff options
-rw-r--r-- | lapi.c | 19 | ||||
-rw-r--r-- | lbaselib.c | 12 | ||||
-rw-r--r-- | lcode.c | 6 | ||||
-rw-r--r-- | ldebug.c | 4 | ||||
-rw-r--r-- | lobject.c | 19 | ||||
-rw-r--r-- | lobject.h | 26 | ||||
-rw-r--r-- | ltable.c | 14 | ||||
-rw-r--r-- | ltm.c | 4 | ||||
-rw-r--r-- | ltm.h | 3 | ||||
-rw-r--r-- | lua.h | 3 | ||||
-rw-r--r-- | lvm.c | 32 | ||||
-rw-r--r-- | lvm.h | 6 |
12 files changed, 109 insertions, 39 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.196 2002/06/06 12:40:22 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.197 2002/06/12 14:51:31 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -211,11 +211,24 @@ LUA_API int lua_isstring (lua_State *L, int index) { | |||
211 | } | 211 | } |
212 | 212 | ||
213 | 213 | ||
214 | LUA_API int lua_equal (lua_State *L, int index1, int index2) { | 214 | LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { |
215 | StkId o1 = luaA_indexAcceptable(L, index1); | 215 | StkId o1 = luaA_indexAcceptable(L, index1); |
216 | StkId o2 = luaA_indexAcceptable(L, index2); | 216 | StkId o2 = luaA_indexAcceptable(L, index2); |
217 | return (o1 == NULL || o2 == NULL) ? 0 /* index out of range */ | 217 | return (o1 == NULL || o2 == NULL) ? 0 /* index out of range */ |
218 | : luaO_equalObj(o1, o2); | 218 | : luaO_rawequalObj(o1, o2); |
219 | } | ||
220 | |||
221 | |||
222 | LUA_API int lua_equal (lua_State *L, int index1, int index2) { | ||
223 | StkId o1, o2; | ||
224 | int i; | ||
225 | lua_lock(L); /* may call tag method */ | ||
226 | o1 = luaA_indexAcceptable(L, index1); | ||
227 | o2 = luaA_indexAcceptable(L, index2); | ||
228 | i = (o1 == NULL || o2 == NULL) ? 0 /* index out of range */ | ||
229 | : equalobj(L, o1, o2); | ||
230 | lua_unlock(L); | ||
231 | return i; | ||
219 | } | 232 | } |
220 | 233 | ||
221 | 234 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.78 2002/06/05 17:24:04 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.79 2002/06/06 12:39:48 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 | */ |
@@ -115,6 +115,15 @@ static int luaB_globals (lua_State *L) { | |||
115 | return 1; | 115 | return 1; |
116 | } | 116 | } |
117 | 117 | ||
118 | |||
119 | static int luaB_rawequal (lua_State *L) { | ||
120 | luaL_check_any(L, 1); | ||
121 | luaL_check_any(L, 2); | ||
122 | lua_pushboolean(L, lua_rawequal(L, 1, 2)); | ||
123 | return 1; | ||
124 | } | ||
125 | |||
126 | |||
118 | static int luaB_rawget (lua_State *L) { | 127 | static int luaB_rawget (lua_State *L) { |
119 | luaL_check_type(L, 1, LUA_TTABLE); | 128 | luaL_check_type(L, 1, LUA_TTABLE); |
120 | luaL_check_any(L, 2); | 129 | luaL_check_any(L, 2); |
@@ -400,6 +409,7 @@ static const luaL_reg base_funcs[] = { | |||
400 | {"type", luaB_type}, | 409 | {"type", luaB_type}, |
401 | {"assert", luaB_assert}, | 410 | {"assert", luaB_assert}, |
402 | {"unpack", luaB_unpack}, | 411 | {"unpack", luaB_unpack}, |
412 | {"rawequal", luaB_rawequal}, | ||
403 | {"rawget", luaB_rawget}, | 413 | {"rawget", luaB_rawget}, |
404 | {"rawset", luaB_rawset}, | 414 | {"rawset", luaB_rawset}, |
405 | {"pcall", luaB_pcall}, | 415 | {"pcall", luaB_pcall}, |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 1.106 2002/06/03 12:59:26 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 1.107 2002/06/12 14:51:31 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 | */ |
@@ -138,7 +138,7 @@ static void luaK_patchlistaux (FuncState *fs, int list, | |||
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
141 | void luaK_dischargejpc (FuncState *fs) { | 141 | static void luaK_dischargejpc (FuncState *fs) { |
142 | luaK_patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc, NO_REG, fs->pc); | 142 | luaK_patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc, NO_REG, fs->pc); |
143 | fs->jpc = NO_JUMP; | 143 | fs->jpc = NO_JUMP; |
144 | } | 144 | } |
@@ -207,7 +207,7 @@ static void freeexp (FuncState *fs, expdesc *e) { | |||
207 | static int addk (FuncState *fs, TObject *k, TObject *v) { | 207 | static int addk (FuncState *fs, TObject *k, TObject *v) { |
208 | const TObject *index = luaH_get(fs->h, k); | 208 | const TObject *index = luaH_get(fs->h, k); |
209 | if (ttype(index) == LUA_TNUMBER) { | 209 | if (ttype(index) == LUA_TNUMBER) { |
210 | lua_assert(luaO_equalObj(&fs->f->k[cast(int, nvalue(index))], v)); | 210 | lua_assert(luaO_rawequalObj(&fs->f->k[cast(int, nvalue(index))], v)); |
211 | return cast(int, nvalue(index)); | 211 | return cast(int, nvalue(index)); |
212 | } | 212 | } |
213 | else { /* constant not found; create a new entry */ | 213 | else { /* constant not found; create a new entry */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 1.117 2002/05/16 18:39:46 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.118 2002/06/06 18:17:33 roberto Exp roberto $ |
3 | ** Debug Interface | 3 | ** Debug Interface |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -165,7 +165,7 @@ static const char *travglobals (lua_State *L, const TObject *o) { | |||
165 | int i = sizenode(g); | 165 | int i = sizenode(g); |
166 | while (i--) { | 166 | while (i--) { |
167 | Node *n = node(g, i); | 167 | Node *n = node(g, i); |
168 | if (luaO_equalObj(o, val(n)) && ttype(key(n)) == LUA_TSTRING) | 168 | if (luaO_rawequalObj(o, val(n)) && ttype(key(n)) == LUA_TSTRING) |
169 | return getstr(tsvalue(key(n))); | 169 | return getstr(tsvalue(key(n))); |
170 | } | 170 | } |
171 | return NULL; | 171 | return NULL; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.c,v 1.82 2002/06/03 14:08:43 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 1.83 2002/06/05 12:34:19 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 | */ |
@@ -55,23 +55,28 @@ int luaO_log2 (unsigned int x) { | |||
55 | } | 55 | } |
56 | 56 | ||
57 | 57 | ||
58 | /* | 58 | int luaO_rawequalObj (const TObject *t1, const TObject *t2) { |
59 | ** warning: this function must return 1 for true (see opcode OP_TESTEQ) | ||
60 | */ | ||
61 | int luaO_equalObj (const TObject *t1, const TObject *t2) { | ||
62 | if (ttype(t1) != ttype(t2)) return 0; | 59 | if (ttype(t1) != ttype(t2)) return 0; |
63 | switch (ttype(t1)) { | 60 | switch (ttype(t1)) { |
64 | case LUA_TNUMBER: | 61 | case LUA_TNUMBER: |
65 | return nvalue(t1) == nvalue(t2); | 62 | return nvalue(t1) == nvalue(t2); |
66 | case LUA_TNIL: | 63 | case LUA_TNIL: |
67 | return 1; | 64 | return 1; |
65 | case LUA_TSTRING: | ||
66 | return tsvalue(t1) == tsvalue(t2); | ||
68 | case LUA_TBOOLEAN: | 67 | case LUA_TBOOLEAN: |
69 | return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */ | 68 | return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */ |
70 | case LUA_TUDATAVAL: | 69 | case LUA_TUDATAVAL: |
71 | return pvalue(t1) == pvalue(t2); | 70 | return pvalue(t1) == pvalue(t2); |
72 | default: /* other types are equal if struct pointers are equal */ | 71 | case LUA_TUSERDATA: |
73 | return tsvalue(t1) == tsvalue(t2); | 72 | return uvalue(t1) == uvalue(t2); |
73 | case LUA_TTABLE: | ||
74 | return hvalue(t1) == hvalue(t2); | ||
75 | case LUA_TFUNCTION: | ||
76 | return clvalue(t1) == clvalue(t2); | ||
74 | } | 77 | } |
78 | lua_assert(0); | ||
79 | return 0; /* to avoid warnings */ | ||
75 | } | 80 | } |
76 | 81 | ||
77 | 82 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.h,v 1.133 2002/05/16 18:39:46 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 1.134 2002/06/12 14:56:22 roberto Exp roberto $ |
3 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -34,14 +34,14 @@ typedef struct lua_TObject { | |||
34 | 34 | ||
35 | 35 | ||
36 | /* Macros to access values */ | 36 | /* Macros to access values */ |
37 | #define ttype(o) ((o)->tt) | 37 | #define ttype(o) ((o)->tt) |
38 | #define pvalue(o) ((o)->value.p) | 38 | #define pvalue(o) check_exp(ttype(o)==LUA_TUDATAVAL, (o)->value.p) |
39 | #define nvalue(o) ((o)->value.n) | 39 | #define nvalue(o) check_exp(ttype(o)==LUA_TNUMBER, (o)->value.n) |
40 | #define tsvalue(o) ((o)->value.ts) | 40 | #define tsvalue(o) check_exp(ttype(o)==LUA_TSTRING, (o)->value.ts) |
41 | #define uvalue(o) ((o)->value.u) | 41 | #define uvalue(o) check_exp(ttype(o)==LUA_TUSERDATA, (o)->value.u) |
42 | #define clvalue(o) ((o)->value.cl) | 42 | #define clvalue(o) check_exp(ttype(o)==LUA_TFUNCTION, (o)->value.cl) |
43 | #define hvalue(o) ((o)->value.h) | 43 | #define hvalue(o) check_exp(ttype(o)==LUA_TTABLE, (o)->value.h) |
44 | #define bvalue(o) ((o)->value.b) | 44 | #define bvalue(o) check_exp(ttype(o)==LUA_TBOOLEAN, (o)->value.b) |
45 | 45 | ||
46 | #define l_isfalse(o) (ttype(o) == LUA_TNIL || \ | 46 | #define l_isfalse(o) (ttype(o) == LUA_TNIL || \ |
47 | (ttype(o) == LUA_TBOOLEAN && bvalue(o) == 0)) | 47 | (ttype(o) == LUA_TBOOLEAN && bvalue(o) == 0)) |
@@ -50,7 +50,8 @@ typedef struct lua_TObject { | |||
50 | #define setnvalue(obj,x) \ | 50 | #define setnvalue(obj,x) \ |
51 | { TObject *i_o=(obj); i_o->tt=LUA_TNUMBER; i_o->value.n=(x); } | 51 | { TObject *i_o=(obj); i_o->tt=LUA_TNUMBER; i_o->value.n=(x); } |
52 | 52 | ||
53 | #define chgnvalue(obj,x) ((obj)->value.n=(x)) | 53 | #define chgnvalue(obj,x) \ |
54 | check_exp(ttype(obj)==LUA_TNUMBER, (obj)->value.n=(x)) | ||
54 | 55 | ||
55 | #define setpvalue(obj,x) \ | 56 | #define setpvalue(obj,x) \ |
56 | { TObject *i_o=(obj); i_o->tt=LUA_TUDATAVAL; i_o->value.p=(x); } | 57 | { TObject *i_o=(obj); i_o->tt=LUA_TUDATAVAL; i_o->value.p=(x); } |
@@ -222,7 +223,8 @@ typedef struct Table { | |||
222 | /* | 223 | /* |
223 | ** `module' operation for hashing (size is always a power of 2) | 224 | ** `module' operation for hashing (size is always a power of 2) |
224 | */ | 225 | */ |
225 | #define lmod(s,size) (cast(int, (s) & ((size)-1))) | 226 | #define lmod(s,size) \ |
227 | check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1)))) | ||
226 | 228 | ||
227 | 229 | ||
228 | #define twoto(x) (1<<(x)) | 230 | #define twoto(x) (1<<(x)) |
@@ -239,7 +241,7 @@ int luaO_log2 (unsigned int x); | |||
239 | #define luaO_openspace(L,n,t) cast(t *, luaO_openspaceaux(L,(n)*sizeof(t))) | 241 | #define luaO_openspace(L,n,t) cast(t *, luaO_openspaceaux(L,(n)*sizeof(t))) |
240 | void *luaO_openspaceaux (lua_State *L, size_t n); | 242 | void *luaO_openspaceaux (lua_State *L, size_t n); |
241 | 243 | ||
242 | int luaO_equalObj (const TObject *t1, const TObject *t2); | 244 | int luaO_rawequalObj (const TObject *t1, const TObject *t2); |
243 | int luaO_str2d (const char *s, lua_Number *result); | 245 | int luaO_str2d (const char *s, lua_Number *result); |
244 | 246 | ||
245 | const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp); | 247 | const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 1.108 2002/05/15 18:57:44 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 1.109 2002/05/27 20:35:40 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 | */ |
@@ -76,9 +76,15 @@ Node *luaH_mainposition (const Table *t, const TObject *key) { | |||
76 | return hashboolean(t, bvalue(key)); | 76 | return hashboolean(t, bvalue(key)); |
77 | case LUA_TUDATAVAL: | 77 | case LUA_TUDATAVAL: |
78 | return hashpointer(t, pvalue(key)); | 78 | return hashpointer(t, pvalue(key)); |
79 | default: /* other types are hashed as (struct *) */ | 79 | case LUA_TUSERDATA: |
80 | return hashpointer(t, tsvalue(key)); | 80 | return hashpointer(t, uvalue(key)); |
81 | case LUA_TFUNCTION: | ||
82 | return hashpointer(t, clvalue(key)); | ||
83 | case LUA_TTABLE: | ||
84 | return hashpointer(t, hvalue(key)); | ||
81 | } | 85 | } |
86 | lua_assert(0); | ||
87 | return 0; /* to avoid warnings */ | ||
82 | } | 88 | } |
83 | 89 | ||
84 | 90 | ||
@@ -391,7 +397,7 @@ static const TObject *luaH_getany (Table *t, const TObject *key) { | |||
391 | else { | 397 | else { |
392 | Node *n = luaH_mainposition(t, key); | 398 | Node *n = luaH_mainposition(t, key); |
393 | do { /* check whether `key' is somewhere in the chain */ | 399 | do { /* check whether `key' is somewhere in the chain */ |
394 | if (luaO_equalObj(key(n), key)) return val(n); /* that's it */ | 400 | if (luaO_rawequalObj(key(n), key)) return val(n); /* that's it */ |
395 | else n = n->next; | 401 | else n = n->next; |
396 | } while (n); | 402 | } while (n); |
397 | return &luaO_nilobject; | 403 | return &luaO_nilobject; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltm.c,v 1.93 2002/06/03 14:09:57 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 1.94 2002/06/12 14:51:31 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 | */ |
@@ -26,7 +26,7 @@ const char *const luaT_typenames[] = { | |||
26 | void luaT_init (lua_State *L) { | 26 | void luaT_init (lua_State *L) { |
27 | static const char *const luaT_eventname[] = { /* ORDER TM */ | 27 | static const char *const luaT_eventname[] = { /* ORDER TM */ |
28 | "__gettable", "__settable", "__index", "__newindex", | 28 | "__gettable", "__settable", "__index", "__newindex", |
29 | "__gc", "__weakmode", | 29 | "__gc", "__eq", "__weakmode", |
30 | "__add", "__sub", "__mul", "__div", | 30 | "__add", "__sub", "__mul", "__div", |
31 | "__pow", "__unm", "__lt", "__le", | 31 | "__pow", "__unm", "__lt", "__le", |
32 | "__concat", "__call" | 32 | "__concat", "__call" |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltm.h,v 1.33 2002/05/27 20:35:40 roberto Exp roberto $ | 2 | ** $Id: ltm.h,v 1.34 2002/06/12 14:51:31 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 | */ |
@@ -20,6 +20,7 @@ typedef enum { | |||
20 | TM_INDEX, | 20 | TM_INDEX, |
21 | TM_NEWINDEX, | 21 | TM_NEWINDEX, |
22 | TM_GC, | 22 | TM_GC, |
23 | TM_EQ, | ||
23 | TM_WEAKMODE, /* last tag method with `fast' access */ | 24 | TM_WEAKMODE, /* last tag method with `fast' access */ |
24 | TM_ADD, | 25 | TM_ADD, |
25 | TM_SUB, | 26 | TM_SUB, |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.137 2002/06/05 12:34:19 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.138 2002/06/06 12:40:22 roberto Exp roberto $ |
3 | ** Lua - An Extensible Extension Language | 3 | ** Lua - An Extensible Extension Language |
4 | ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil | 4 | ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil |
5 | ** http://www.lua.org mailto:info@lua.org | 5 | ** http://www.lua.org mailto:info@lua.org |
@@ -130,6 +130,7 @@ LUA_API int lua_type (lua_State *L, int index); | |||
130 | LUA_API const char *lua_typename (lua_State *L, int type); | 130 | LUA_API const char *lua_typename (lua_State *L, int type); |
131 | 131 | ||
132 | LUA_API int lua_equal (lua_State *L, int index1, int index2); | 132 | LUA_API int lua_equal (lua_State *L, int index1, int index2); |
133 | LUA_API int lua_rawequal (lua_State *L, int index1, int index2); | ||
133 | LUA_API int lua_lessthan (lua_State *L, int index1, int index2); | 134 | LUA_API int lua_lessthan (lua_State *L, int index1, int index2); |
134 | 135 | ||
135 | LUA_API lua_Number lua_tonumber (lua_State *L, int index); | 136 | LUA_API lua_Number lua_tonumber (lua_State *L, int index); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.236 2002/06/06 18:17:33 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.237 2002/06/12 14:51:31 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 | */ |
@@ -250,6 +250,34 @@ static int luaV_lessequal (lua_State *L, const TObject *l, const TObject *r) { | |||
250 | } | 250 | } |
251 | 251 | ||
252 | 252 | ||
253 | int luaV_equalval (lua_State *L, const TObject *t1, const TObject *t2) { | ||
254 | const TObject *tm = NULL; | ||
255 | lua_assert(ttype(t1) == ttype(t2)); | ||
256 | switch (ttype(t1)) { | ||
257 | case LUA_TNIL: return 1; | ||
258 | case LUA_TNUMBER: return nvalue(t1) == nvalue(t2); | ||
259 | case LUA_TSTRING: return tsvalue(t1) == tsvalue(t2); | ||
260 | case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ | ||
261 | case LUA_TUDATAVAL: return pvalue(t1) == pvalue(t2); | ||
262 | case LUA_TFUNCTION: return clvalue(t1) == clvalue(t2); | ||
263 | case LUA_TUSERDATA: | ||
264 | if (uvalue(t1) == uvalue(t2)) return 1; | ||
265 | else if ((tm = fasttm(L, uvalue(t1)->uv.metatable, TM_EQ)) == NULL && | ||
266 | (tm = fasttm(L, uvalue(t2)->uv.metatable, TM_EQ)) == NULL) | ||
267 | return 0; /* no TM */ | ||
268 | else break; /* will try TM */ | ||
269 | case LUA_TTABLE: | ||
270 | if (hvalue(t1) == hvalue(t2)) return 1; | ||
271 | else if ((tm = fasttm(L, hvalue(t1)->metatable, TM_EQ)) == NULL && | ||
272 | (tm = fasttm(L, hvalue(t2)->metatable, TM_EQ)) == NULL) | ||
273 | return 0; /* no TM */ | ||
274 | else break; /* will try TM */ | ||
275 | } | ||
276 | callTMres(L, tm, t1, t2, L->top); /* call TM */ | ||
277 | return !l_isfalse(L->top); | ||
278 | } | ||
279 | |||
280 | |||
253 | void luaV_concat (lua_State *L, int total, int last) { | 281 | void luaV_concat (lua_State *L, int total, int last) { |
254 | do { | 282 | do { |
255 | StkId top = L->ci->base + last + 1; | 283 | StkId top = L->ci->base + last + 1; |
@@ -464,7 +492,7 @@ StkId luaV_execute (lua_State *L) { | |||
464 | break; | 492 | break; |
465 | } | 493 | } |
466 | case OP_EQ: { /* skip next instruction if test fails */ | 494 | case OP_EQ: { /* skip next instruction if test fails */ |
467 | if (luaO_equalObj(ra, RKC(i)) != GETARG_B(i)) pc++; | 495 | if (equalobj(L, ra, RKC(i)) != GETARG_B(i)) pc++; |
468 | else dojump(pc, GETARG_sBx(*pc) + 1); | 496 | else dojump(pc, GETARG_sBx(*pc) + 1); |
469 | break; | 497 | break; |
470 | } | 498 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.h,v 1.40 2002/06/03 14:08:43 roberto Exp roberto $ | 2 | ** $Id: lvm.h,v 1.41 2002/06/12 14:51:31 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 | */ |
@@ -18,8 +18,12 @@ | |||
18 | #define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ | 18 | #define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ |
19 | (((o) = luaV_tonumber(o,n)) != NULL)) | 19 | (((o) = luaV_tonumber(o,n)) != NULL)) |
20 | 20 | ||
21 | #define equalobj(L,o1,o2) \ | ||
22 | (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) | ||
23 | |||
21 | 24 | ||
22 | int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r); | 25 | int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r); |
26 | int luaV_equalval (lua_State *L, const TObject *t1, const TObject *t2); | ||
23 | const TObject *luaV_tonumber (const TObject *obj, TObject *n); | 27 | const TObject *luaV_tonumber (const TObject *obj, TObject *n); |
24 | int luaV_tostring (lua_State *L, TObject *obj); | 28 | int luaV_tostring (lua_State *L, TObject *obj); |
25 | void luaV_gettable (lua_State *L, const TObject *t, TObject *key, StkId res); | 29 | void luaV_gettable (lua_State *L, const TObject *t, TObject *key, StkId res); |