diff options
| author | Roberto I <roberto@inf.puc-rio.br> | 2025-08-20 16:10:54 -0300 |
|---|---|---|
| committer | Roberto I <roberto@inf.puc-rio.br> | 2025-08-20 16:10:54 -0300 |
| commit | 06c5d3825f03eafc90b56d43f70f70048b785bc8 (patch) | |
| tree | 0b418c4a9ac5a53a6ca39bf258bb046de1fc6749 | |
| parent | c345877e4c2588324d9a1e5655e8f48200ba2e5e (diff) | |
| download | lua-06c5d3825f03eafc90b56d43f70f70048b785bc8.tar.gz lua-06c5d3825f03eafc90b56d43f70f70048b785bc8.tar.bz2 lua-06c5d3825f03eafc90b56d43f70f70048b785bc8.zip | |
Removed code for compatibility with version 5.3
Diffstat (limited to '')
| -rw-r--r-- | lstate.h | 4 | ||||
| -rw-r--r-- | ltests.h | 1 | ||||
| -rw-r--r-- | ltm.c | 16 | ||||
| -rw-r--r-- | lua.h | 7 | ||||
| -rw-r--r-- | luaconf.h | 27 | ||||
| -rw-r--r-- | lvm.c | 6 | ||||
| -rw-r--r-- | testes/api.lua | 3 |
7 files changed, 3 insertions, 61 deletions
| @@ -249,10 +249,6 @@ struct CallInfo { | |||
| 249 | #define CIST_HOOKYIELD (CIST_TAIL << 1) | 249 | #define CIST_HOOKYIELD (CIST_TAIL << 1) |
| 250 | /* function "called" a finalizer */ | 250 | /* function "called" a finalizer */ |
| 251 | #define CIST_FIN (CIST_HOOKYIELD << 1) | 251 | #define CIST_FIN (CIST_HOOKYIELD << 1) |
| 252 | #if defined(LUA_COMPAT_LT_LE) | ||
| 253 | /* using __lt for __le */ | ||
| 254 | #define CIST_LEQ (CIST_FIN << 1) | ||
| 255 | #endif | ||
| 256 | 252 | ||
| 257 | 253 | ||
| 258 | #define get_nresults(cs) (cast_int((cs) & CIST_NRESULTS) - 1) | 254 | #define get_nresults(cs) (cast_int((cs) & CIST_NRESULTS) - 1) |
| @@ -13,7 +13,6 @@ | |||
| 13 | 13 | ||
| 14 | /* test Lua with compatibility code */ | 14 | /* test Lua with compatibility code */ |
| 15 | #define LUA_COMPAT_MATHLIB | 15 | #define LUA_COMPAT_MATHLIB |
| 16 | #define LUA_COMPAT_LT_LE | ||
| 17 | #undef LUA_COMPAT_GLOBAL | 16 | #undef LUA_COMPAT_GLOBAL |
| 18 | 17 | ||
| 19 | 18 | ||
| @@ -196,28 +196,12 @@ void luaT_trybiniTM (lua_State *L, const TValue *p1, lua_Integer i2, | |||
| 196 | 196 | ||
| 197 | /* | 197 | /* |
| 198 | ** Calls an order tag method. | 198 | ** Calls an order tag method. |
| 199 | ** For lessequal, LUA_COMPAT_LT_LE keeps compatibility with old | ||
| 200 | ** behavior: if there is no '__le', try '__lt', based on l <= r iff | ||
| 201 | ** !(r < l) (assuming a total order). If the metamethod yields during | ||
| 202 | ** this substitution, the continuation has to know about it (to negate | ||
| 203 | ** the result of r<l); bit CIST_LEQ in the call status keeps that | ||
| 204 | ** information. | ||
| 205 | */ | 199 | */ |
| 206 | int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2, | 200 | int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2, |
| 207 | TMS event) { | 201 | TMS event) { |
| 208 | int tag = callbinTM(L, p1, p2, L->top.p, event); /* try original event */ | 202 | int tag = callbinTM(L, p1, p2, L->top.p, event); /* try original event */ |
| 209 | if (tag >= 0) /* found tag method? */ | 203 | if (tag >= 0) /* found tag method? */ |
| 210 | return !tagisfalse(tag); | 204 | return !tagisfalse(tag); |
| 211 | #if defined(LUA_COMPAT_LT_LE) | ||
| 212 | else if (event == TM_LE) { | ||
| 213 | /* try '!(p2 < p1)' for '(p1 <= p2)' */ | ||
| 214 | L->ci->callstatus |= CIST_LEQ; /* mark it is doing 'lt' for 'le' */ | ||
| 215 | tag = callbinTM(L, p2, p1, L->top.p, TM_LT); | ||
| 216 | L->ci->callstatus ^= CIST_LEQ; /* clear mark */ | ||
| 217 | if (tag >= 0) /* found tag method? */ | ||
| 218 | return tagisfalse(tag); | ||
| 219 | } | ||
| 220 | #endif | ||
| 221 | luaG_ordererror(L, p1, p2); /* no metamethod found */ | 205 | luaG_ordererror(L, p1, p2); /* no metamethod found */ |
| 222 | return 0; /* to avoid warnings */ | 206 | return 0; /* to avoid warnings */ |
| 223 | } | 207 | } |
| @@ -432,13 +432,6 @@ LUA_API void (lua_closeslot) (lua_State *L, int idx); | |||
| 432 | ** compatibility macros | 432 | ** compatibility macros |
| 433 | ** =============================================================== | 433 | ** =============================================================== |
| 434 | */ | 434 | */ |
| 435 | #if defined(LUA_COMPAT_APIINTCASTS) | ||
| 436 | |||
| 437 | #define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n)) | ||
| 438 | #define lua_tounsignedx(L,i,is) ((lua_Unsigned)lua_tointegerx(L,i,is)) | ||
| 439 | #define lua_tounsigned(L,i) lua_tounsignedx(L,(i),NULL) | ||
| 440 | |||
| 441 | #endif | ||
| 442 | 435 | ||
| 443 | #define lua_newuserdata(L,s) lua_newuserdatauv(L,s,1) | 436 | #define lua_newuserdata(L,s) lua_newuserdatauv(L,s,1) |
| 444 | #define lua_getuservalue(L,idx) lua_getiuservalue(L,idx,1) | 437 | #define lua_getuservalue(L,idx) lua_getiuservalue(L,idx,1) |
| @@ -362,35 +362,12 @@ | |||
| 362 | 362 | ||
| 363 | 363 | ||
| 364 | /* | 364 | /* |
| 365 | @@ LUA_COMPAT_5_3 controls other macros for compatibility with Lua 5.3. | ||
| 366 | ** You can define it to get all options, or change specific options | ||
| 367 | ** to fit your specific needs. | ||
| 368 | */ | ||
| 369 | #if defined(LUA_COMPAT_5_3) /* { */ | ||
| 370 | |||
| 371 | /* | ||
| 372 | @@ LUA_COMPAT_MATHLIB controls the presence of several deprecated | 365 | @@ LUA_COMPAT_MATHLIB controls the presence of several deprecated |
| 373 | ** functions in the mathematical library. | 366 | ** functions in the mathematical library. |
| 374 | ** (These functions were already officially removed in 5.3; | 367 | ** (These functions were already officially removed in 5.3; |
| 375 | ** nevertheless they are still available here.) | 368 | ** nevertheless they are still available here.) |
| 376 | */ | 369 | */ |
| 377 | #define LUA_COMPAT_MATHLIB | 370 | /* #define LUA_COMPAT_MATHLIB */ |
| 378 | |||
| 379 | /* | ||
| 380 | @@ LUA_COMPAT_APIINTCASTS controls the presence of macros for | ||
| 381 | ** manipulating other integer types (lua_pushunsigned, lua_tounsigned, | ||
| 382 | ** luaL_checkint, luaL_checklong, etc.) | ||
| 383 | ** (These macros were also officially removed in 5.3, but they are still | ||
| 384 | ** available here.) | ||
| 385 | */ | ||
| 386 | #define LUA_COMPAT_APIINTCASTS | ||
| 387 | |||
| 388 | |||
| 389 | /* | ||
| 390 | @@ LUA_COMPAT_LT_LE controls the emulation of the '__le' metamethod | ||
| 391 | ** using '__lt'. | ||
| 392 | */ | ||
| 393 | #define LUA_COMPAT_LT_LE | ||
| 394 | 371 | ||
| 395 | 372 | ||
| 396 | /* | 373 | /* |
| @@ -407,8 +384,6 @@ | |||
| 407 | #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) | 384 | #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) |
| 408 | #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) | 385 | #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) |
| 409 | 386 | ||
| 410 | #endif /* } */ | ||
| 411 | |||
| 412 | /* }================================================================== */ | 387 | /* }================================================================== */ |
| 413 | 388 | ||
| 414 | 389 | ||
| @@ -861,12 +861,6 @@ void luaV_finishOp (lua_State *L) { | |||
| 861 | case OP_EQ: { /* note that 'OP_EQI'/'OP_EQK' cannot yield */ | 861 | case OP_EQ: { /* note that 'OP_EQI'/'OP_EQK' cannot yield */ |
| 862 | int res = !l_isfalse(s2v(L->top.p - 1)); | 862 | int res = !l_isfalse(s2v(L->top.p - 1)); |
| 863 | L->top.p--; | 863 | L->top.p--; |
| 864 | #if defined(LUA_COMPAT_LT_LE) | ||
| 865 | if (ci->callstatus & CIST_LEQ) { /* "<=" using "<" instead? */ | ||
| 866 | ci->callstatus ^= CIST_LEQ; /* clear mark */ | ||
| 867 | res = !res; /* negate result */ | ||
| 868 | } | ||
| 869 | #endif | ||
| 870 | lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP); | 864 | lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP); |
| 871 | if (res != GETARG_k(inst)) /* condition failed? */ | 865 | if (res != GETARG_k(inst)) /* condition failed? */ |
| 872 | ci->u.l.savedpc++; /* skip jump instruction */ | 866 | ci->u.l.savedpc++; /* skip jump instruction */ |
diff --git a/testes/api.lua b/testes/api.lua index b3791654..9855f541 100644 --- a/testes/api.lua +++ b/testes/api.lua | |||
| @@ -246,7 +246,8 @@ assert(not T.testC("compare LT 1 4, return 1")) | |||
| 246 | assert(not T.testC("compare LE 9 1, return 1")) | 246 | assert(not T.testC("compare LE 9 1, return 1")) |
| 247 | assert(not T.testC("compare EQ 9 9, return 1")) | 247 | assert(not T.testC("compare EQ 9 9, return 1")) |
| 248 | 248 | ||
| 249 | local b = {__lt = function (a,b) return a[1] < b[1] end} | 249 | local b = {__lt = function (a,b) return a[1] < b[1] end, |
| 250 | __le = function (a,b) return a[1] <= b[1] end} | ||
| 250 | local a1,a3,a4 = setmetatable({1}, b), | 251 | local a1,a3,a4 = setmetatable({1}, b), |
| 251 | setmetatable({3}, b), | 252 | setmetatable({3}, b), |
| 252 | setmetatable({4}, b) | 253 | setmetatable({4}, b) |
