diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-06-24 12:07:21 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-06-24 12:07:21 -0300 |
commit | 922f36a05b249739814c54142036dc81f23bc7a0 (patch) | |
tree | 844627bfc57ac7e6ed219ef7ce9d1a9025dea719 | |
parent | ad41fc11eb2be960ee700c913c7a5c341d541af5 (diff) | |
download | lua-922f36a05b249739814c54142036dc81f23bc7a0.tar.gz lua-922f36a05b249739814c54142036dc81f23bc7a0.tar.bz2 lua-922f36a05b249739814c54142036dc81f23bc7a0.zip |
details
-rw-r--r-- | ldebug.c | 5 | ||||
-rw-r--r-- | ldebug.h | 4 | ||||
-rw-r--r-- | lvm.c | 30 |
3 files changed, 20 insertions, 19 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 1.121 2002/06/18 17:10:43 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.122 2002/06/20 20:39:44 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 | */ |
@@ -506,13 +506,14 @@ void luaG_aritherror (lua_State *L, StkId p1, const TObject *p2) { | |||
506 | } | 506 | } |
507 | 507 | ||
508 | 508 | ||
509 | void luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) { | 509 | int luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) { |
510 | const char *t1 = luaT_typenames[ttype(p1)]; | 510 | const char *t1 = luaT_typenames[ttype(p1)]; |
511 | const char *t2 = luaT_typenames[ttype(p2)]; | 511 | const char *t2 = luaT_typenames[ttype(p2)]; |
512 | if (t1[2] == t2[2]) | 512 | if (t1[2] == t2[2]) |
513 | luaG_runerror(L, "attempt to compare two %s values", t1); | 513 | luaG_runerror(L, "attempt to compare two %s values", t1); |
514 | else | 514 | else |
515 | luaG_runerror(L, "attempt to compare %s with %s", t1, t2); | 515 | luaG_runerror(L, "attempt to compare %s with %s", t1, t2); |
516 | return 0; | ||
516 | } | 517 | } |
517 | 518 | ||
518 | 519 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.h,v 1.21 2002/05/15 18:57:44 roberto Exp roberto $ | 2 | ** $Id: ldebug.h,v 1.22 2002/06/18 15:19:27 roberto Exp roberto $ |
3 | ** Auxiliary functions from Debug Interface module | 3 | ** Auxiliary functions from Debug Interface module |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -19,7 +19,7 @@ | |||
19 | void luaG_typeerror (lua_State *L, const TObject *o, const char *opname); | 19 | void luaG_typeerror (lua_State *L, const TObject *o, const char *opname); |
20 | void luaG_concaterror (lua_State *L, StkId p1, StkId p2); | 20 | void luaG_concaterror (lua_State *L, StkId p1, StkId p2); |
21 | void luaG_aritherror (lua_State *L, StkId p1, const TObject *p2); | 21 | void luaG_aritherror (lua_State *L, StkId p1, const TObject *p2); |
22 | void luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2); | 22 | int luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2); |
23 | void luaG_runerror (lua_State *L, const char *fmt, ...); | 23 | void luaG_runerror (lua_State *L, const char *fmt, ...); |
24 | void luaG_errormsg (lua_State *L, int internal); | 24 | void luaG_errormsg (lua_State *L, int internal); |
25 | int luaG_checkcode (const Proto *pt); | 25 | int luaG_checkcode (const Proto *pt); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.241 2002/06/24 13:08:45 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.242 2002/06/24 14:11:14 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 | */ |
@@ -205,30 +205,30 @@ static int luaV_strcmp (const TString *ls, const TString *rs) { | |||
205 | 205 | ||
206 | 206 | ||
207 | int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r) { | 207 | int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r) { |
208 | if (ttype(l) == LUA_TNUMBER && ttype(r) == LUA_TNUMBER) | 208 | if (ttype(l) != ttype(r)) |
209 | return luaG_ordererror(L, l, r); | ||
210 | else if (ttype(l) == LUA_TNUMBER) | ||
209 | return nvalue(l) < nvalue(r); | 211 | return nvalue(l) < nvalue(r); |
210 | else if (ttype(l) == LUA_TSTRING && ttype(r) == LUA_TSTRING) | 212 | else if (ttype(l) == LUA_TSTRING) |
211 | return luaV_strcmp(tsvalue(l), tsvalue(r)) < 0; | 213 | return luaV_strcmp(tsvalue(l), tsvalue(r)) < 0; |
212 | else { /* try TM */ | 214 | else if (call_binTM(L, l, r, L->top, TM_LT)) |
213 | if (!call_binTM(L, l, r, L->top, TM_LT)) | ||
214 | luaG_ordererror(L, l, r); | ||
215 | return !l_isfalse(L->top); | 215 | return !l_isfalse(L->top); |
216 | } | 216 | return luaG_ordererror(L, l, r); |
217 | } | 217 | } |
218 | 218 | ||
219 | 219 | ||
220 | static int luaV_lessequal (lua_State *L, const TObject *l, const TObject *r) { | 220 | static int luaV_lessequal (lua_State *L, const TObject *l, const TObject *r) { |
221 | if (ttype(l) == LUA_TNUMBER && ttype(r) == LUA_TNUMBER) | 221 | if (ttype(l) != ttype(r)) |
222 | return luaG_ordererror(L, l, r); | ||
223 | else if (ttype(l) == LUA_TNUMBER) | ||
222 | return nvalue(l) <= nvalue(r); | 224 | return nvalue(l) <= nvalue(r); |
223 | else if (ttype(l) == LUA_TSTRING && ttype(r) == LUA_TSTRING) | 225 | else if (ttype(l) == LUA_TSTRING) |
224 | return luaV_strcmp(tsvalue(l), tsvalue(r)) <= 0; | 226 | return luaV_strcmp(tsvalue(l), tsvalue(r)) <= 0; |
225 | else { /* try TM */ | 227 | else if (call_binTM(L, l, r, L->top, TM_LE)) /* first try `le' */ |
226 | if (call_binTM(L, l, r, L->top, TM_LE)) /* first try `le' */ | 228 | return !l_isfalse(L->top); |
227 | return !l_isfalse(L->top); | 229 | else if (call_binTM(L, r, l, L->top, TM_LT)) /* else try `lt' */ |
228 | else if (!call_binTM(L, r, l, L->top, TM_LT)) /* else try `lt' */ | ||
229 | luaG_ordererror(L, l, r); | ||
230 | return l_isfalse(L->top); | 230 | return l_isfalse(L->top); |
231 | } | 231 | return luaG_ordererror(L, l, r); |
232 | } | 232 | } |
233 | 233 | ||
234 | 234 | ||