int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r) { int res; if (ttisnumber(l) && ttisnumber(r)) return luai_numle(L, nvalue(l), nvalue(r)); else if (ttisstring(l) && ttisstring(r)) return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ return res; else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */ return !res; return luaG_ordererror(L, l, r); }
static int luaV_lessequal (lua_State *L, const TObject *l, const TObject *r) { int res; if (ttype(l) != ttype(r)) return luaG_ordererror(L, l, r); else if (ttisnumber(l)) return nvalue(l) <= nvalue(r); else if (ttisstring(l)) return luaV_strcmp(tsvalue(l), tsvalue(r)) <= 0; else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ return res; else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */ return !res; return luaG_ordererror(L, l, r); }
static int lessequal (lua_State *L, const TValue *l, const TValue *r) { int res; if (ttype(l) != ttype(r)) return luaG_ordererror(L, l, r); else if (ttisnumber(l)) return luai_numle(nvalue(l), nvalue(r)); else if (ttisstring(l)) return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; #if LUA_WIDESTRING else if (ttiswstring(l)) return l_wstrcmp(rawtwsvalue(l), rawtwsvalue(r)) <= 0; #endif /* LUA_WIDESTRING */ else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ return res; else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */ return !res; return luaG_ordererror(L, l, r); }
static int lessequal (lua_State *L, const TValue *l, const TValue *r) { int res; int tl= ttype(l); if (tl == ttype(r)) { switch(tl) { #ifdef LUA_TINT case LUA_TINT: return ivalue(l) <= ivalue(r); #endif case LUA_TNUMBER: #ifdef LNUM_COMPLEX if ( (nvalue_img_fast(l)!=0) || (nvalue_img_fast(r)!=0) ) error_complex( L, l, r ); #endif return luai_numle(nvalue_fast(l), nvalue_fast(r)); case LUA_TSTRING: return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; } if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ return res; else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */ return !res; /* fall through to 'luaG_ordererror()' */ } #ifdef LUA_TINT else if (ttype_ext(l) == ttype_ext(r)) { lua_Integer tmp; # ifdef LNUM_COMPLEX if ( (nvalue_img(l)!=0) || (nvalue_img(r)!=0) ) error_complex( L, l, r ); # endif if (tl==LUA_TINT) { /* l:int, r:num */ return tt_integer_valued(r,&tmp) ? (ivalue(l) <= tmp) : luai_numle( cast_num(ivalue(l)), nvalue_fast(r) ); } else { /* l:num, r:int */ return tt_integer_valued(l,&tmp) ? (tmp <= ivalue(r)) : luai_numle( nvalue_fast(l), cast_num(ivalue(r)) ); } } #endif return luaG_ordererror(L, l, r); }
int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { int res; if (ttisnumber(l) && ttisnumber(r)) return luai_numlt(L, nvalue(l), nvalue(r)); else if (ttisstring(l) && ttisstring(r)) return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) return res; return luaG_ordererror(L, l, r); }
int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r) { int res; if (ttype(l) != ttype(r)) return luaG_ordererror(L, l, r); else if (ttisnumber(l)) return nvalue(l) < nvalue(r); else if (ttisstring(l)) return luaV_strcmp(tsvalue(l), tsvalue(r)) < 0; else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) return res; return luaG_ordererror(L, l, r); }
int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { int res; if (ttype(l) != ttype(r)) return luaG_ordererror(L, l, r); else if (ttisnumber(l)) return luai_numlt(nvalue(l), nvalue(r)); else if (ttisstring(l)) return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; #if LUA_WIDESTRING else if (ttiswstring(l)) return l_wstrcmp(rawtwsvalue(l), rawtwsvalue(r)) < 0; #endif /* LUA_WIDESTRING */ else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) return res; return luaG_ordererror(L, l, r); }
int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { int res; int tl= ttype(l); if (tl == ttype(r)) { switch(tl) { #ifdef LUA_TINT case LUA_TINT: return ivalue(l) < ivalue(r); #endif case LUA_TNUMBER: #ifdef LNUM_COMPLEX if ( (nvalue_img_fast(l)!=0) || (nvalue_img_fast(r)!=0) ) error_complex( L, l, r ); #endif return luai_numlt(nvalue_fast(l), nvalue_fast(r)); case LUA_TSTRING: return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; } if ((res = call_orderTM(L, l, r, TM_LT)) != -1) return res; /* fall through to 'luaG_ordererror()' */ } #ifdef LUA_TINT else if (ttype_ext(l) == ttype_ext(r)) { lua_Integer tmp; /* Avoid accuracy losing casts: if 'r' is integer by value, do comparisons * in integer realm. Only otherwise cast 'l' to FP (which might change its * value). */ # ifdef LNUM_COMPLEX if ( (nvalue_img(l)!=0) || (nvalue_img(r)!=0) ) error_complex( L, l, r ); # endif if (tl==LUA_TINT) { /* l:int, r:num */ return tt_integer_valued(r,&tmp) ? (ivalue(l) < tmp) : luai_numlt( cast_num(ivalue(l)), nvalue_fast(r) ); } else { /* l:num, r:int */ return tt_integer_valued(l,&tmp) ? (tmp < ivalue(r)) : luai_numlt( nvalue_fast(l), cast_num(ivalue(r)) ); } } #endif return luaG_ordererror(L, l, r); }