MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / luaV_lessthan

Function luaV_lessthan

src/Chain/libraries/glua/lvm.cpp:386–407  ·  view source on GitHub ↗

** Main operation less than; return 'l < r'. */

Source from the content-addressed store, hash-verified

384** Main operation less than; return 'l < r'.
385*/
386int luaV_lessthan(lua_State *L, const TValue *l, const TValue *r) {
387 int res;
388 if (ttisnumber(l) && ttisnumber(r)) /* both operands are numbers? */
389 return LTnum(l, r);
390 else if (ttisstring(l) && ttisstring(r)) /* both are strings? */
391 return l_strcmp(tsvalue(l), tsvalue(r)) < 0;
392 else if (ttisstring(l) && ttisnumber(r))
393 {
394 auto lstr = svalue(l);
395 auto rstr = std::to_string(ttisinteger(r) ? ivalue(r) : fltvalue(r));
396 return l_c_str_cmp(lstr, rstr.c_str());
397 }
398 else if(ttisnumber(l) && ttisstring(r))
399 {
400 auto lstr = std::to_string(ttisinteger(l) ? ivalue(l) : fltvalue(l));
401 auto rstr = svalue(r);
402 return l_c_str_cmp(lstr.c_str(), rstr);
403 }
404 else if ((res = luaT_callorderTM(L, l, r, TM_LT)) < 0) /* no metamethod? */
405 luaG_ordererror(L, l, r); /* error */
406 return res;
407}
408
409
410/*

Callers 2

vmcaseFunction · 0.85
lua_compareFunction · 0.85

Calls 7

LTnumFunction · 0.85
l_strcmpFunction · 0.85
l_c_str_cmpFunction · 0.85
luaT_callorderTMFunction · 0.85
luaG_ordererrorFunction · 0.85
to_stringFunction · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected