MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaV_lessequal

Function luaV_lessequal

third-party/lua-5.3.5/src/lvm.c:384–400  ·  view source on GitHub ↗

** 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. */

Source from the content-addressed store, hash-verified

382** status keeps that information.
383*/
384int 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/*

Callers 2

luaV_executeFunction · 0.70
lua_compareFunction · 0.70

Calls 4

LEnumFunction · 0.70
l_strcmpFunction · 0.70
luaT_callorderTMFunction · 0.70
luaG_ordererrorFunction · 0.70

Tested by

no test coverage detected