** Calls an order tag method. ** For lessequal, LUA_COMPAT_LT_LE keeps compatibility with old ** behavior: if there is no '__le', try '__lt', based on l <= r iff ** !(r < l) (assuming a total order). If the metamethod yields during ** this substitution, the continuation has to know about it (to negate ** the result of r<l); bit CIST_LEQ in the call status keeps that ** information. */
| 199 | ** information. |
| 200 | */ |
| 201 | int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2, |
| 202 | TMS event) { |
| 203 | if (callbinTM(L, p1, p2, L->top.p, event)) /* try original event */ |
| 204 | return !l_isfalse(s2v(L->top.p)); |
| 205 | #if defined(LUA_COMPAT_LT_LE) |
| 206 | else if (event == TM_LE) { |
| 207 | /* try '!(p2 < p1)' for '(p1 <= p2)' */ |
| 208 | L->ci->callstatus |= CIST_LEQ; /* mark it is doing 'lt' for 'le' */ |
| 209 | if (callbinTM(L, p2, p1, L->top.p, TM_LT)) { |
| 210 | L->ci->callstatus ^= CIST_LEQ; /* clear mark */ |
| 211 | return l_isfalse(s2v(L->top.p)); |
| 212 | } |
| 213 | /* else error will remove this 'ci'; no need to clear mark */ |
| 214 | } |
| 215 | #endif |
| 216 | luaG_ordererror(L, p1, p2); /* no metamethod found */ |
| 217 | return 0; /* to avoid warnings */ |
| 218 | } |
| 219 | |
| 220 | |
| 221 | int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2, |
no test coverage detected