** Main operation less than or equal to; return 'l <= r'. */
| 282 | ** Main operation less than or equal to; return 'l <= r'. |
| 283 | */ |
| 284 | int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r) { |
| 285 | int res; |
| 286 | lua_Number nl, nr; |
| 287 | if (ttisinteger(l) && ttisinteger(r)) /* both operands are integers? */ |
| 288 | return (ivalue(l) <= ivalue(r)); |
| 289 | else if (tofloat(l, &nl) && tofloat(r, &nr)) /* both are numbers? */ |
| 290 | return luai_numle(nl, nr); |
| 291 | else if (ttisstring(l) && ttisstring(r)) /* both are strings? */ |
| 292 | return l_strcmp(tsvalue(l), tsvalue(r)) <= 0; |
| 293 | else if ((res = luaT_callorderTM(L, l, r, TM_LE)) >= 0) /* first try 'le' */ |
| 294 | return res; |
| 295 | else if ((res = luaT_callorderTM(L, r, l, TM_LT)) < 0) /* else try 'lt' */ |
| 296 | luaG_ordererror(L, l, r); |
| 297 | return !res; |
| 298 | } |
| 299 | |
| 300 | |
| 301 | /* |
no test coverage detected