** Main operation less than or equal to; return 'l <= r'. If it needs ** a metamethod and 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. */
| 382 | ** status keeps that information. |
| 383 | */ |
| 384 | int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r) { |
| 385 | int res; |
| 386 | if (ttisnumber(l) && ttisnumber(r)) /* both operands are numbers? */ |
| 387 | return LEnum(l, r); |
| 388 | else if (ttisstring(l) && ttisstring(r)) /* both are strings? */ |
| 389 | return l_strcmp(tsvalue(l), tsvalue(r)) <= 0; |
| 390 | else if ((res = luaT_callorderTM(L, l, r, TM_LE)) >= 0) /* try 'le' */ |
| 391 | return res; |
| 392 | else { /* try 'lt': */ |
| 393 | L->ci->callstatus |= CIST_LEQ; /* mark it is doing 'lt' for 'le' */ |
| 394 | res = luaT_callorderTM(L, r, l, TM_LT); |
| 395 | L->ci->callstatus ^= CIST_LEQ; /* clear mark */ |
| 396 | if (res < 0) |
| 397 | luaG_ordererror(L, l, r); |
| 398 | return !res; /* result is negated */ |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | |
| 403 | /* |
no test coverage detected