MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / luaV_lessequal

Function luaV_lessequal

libraries/AP_Scripting/lua/src/lvm.c:388–404  ·  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

386** status keeps that information.
387*/
388int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r) {
389 int res;
390 if (ttisnumber(l) && ttisnumber(r)) /* both operands are numbers? */
391 return LEnum(l, r);
392 else if (ttisstring(l) && ttisstring(r)) /* both are strings? */
393 return l_strcmp(tsvalue(l), tsvalue(r)) <= 0;
394 else if ((res = luaT_callorderTM(L, l, r, TM_LE)) >= 0) /* try 'le' */
395 return res;
396 else { /* try 'lt': */
397 L->ci->callstatus |= CIST_LEQ; /* mark it is doing 'lt' for 'le' */
398 res = luaT_callorderTM(L, r, l, TM_LT);
399 L->ci->callstatus ^= CIST_LEQ; /* clear mark */
400 if (res < 0)
401 luaG_ordererror(L, l, r);
402 return !res; /* result is negated */
403 }
404}
405
406
407/*

Callers 2

luaV_executeFunction · 0.85
lua_compareFunction · 0.85

Calls 4

LEnumFunction · 0.85
l_strcmpFunction · 0.85
luaT_callorderTMFunction · 0.85
luaG_ordererrorFunction · 0.85

Tested by

no test coverage detected