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

Function equalkey

third-party/lua-5.5.0/src/ltable.c:252–283  ·  view source on GitHub ↗

** Check whether key 'k1' is equal to the key in node 'n2'. This ** equality is raw, so there are no metamethods. Floats with integer ** values have been normalized, so integers cannot be equal to ** floats. It is assumed that 'eqshrstr' is simply pointer equality, ** so that short strings are handled in the default case. The flag ** 'deadok' means to accept dead keys as equal to their original v

Source from the content-addressed store, hash-verified

250** on the table or nil.)
251*/
252static int equalkey (const TValue *k1, const Node *n2, int deadok) {
253 if (rawtt(k1) != keytt(n2)) { /* not the same variants? */
254 if (keyisshrstr(n2) && ttislngstring(k1)) {
255 /* an external string can be equal to a short-string key */
256 return luaS_eqstr(tsvalue(k1), keystrval(n2));
257 }
258 else if (deadok && keyisdead(n2) && iscollectable(k1)) {
259 /* a collectable value can be equal to a dead key */
260 return gcvalue(k1) == gcvalueraw(keyval(n2));
261 }
262 else
263 return 0; /* otherwise, different variants cannot be equal */
264 }
265 else { /* equal variants */
266 switch (keytt(n2)) {
267 case LUA_VNIL: case LUA_VFALSE: case LUA_VTRUE:
268 return 1;
269 case LUA_VNUMINT:
270 return (ivalue(k1) == keyival(n2));
271 case LUA_VNUMFLT:
272 return luai_numeq(fltvalue(k1), fltvalueraw(keyval(n2)));
273 case LUA_VLIGHTUSERDATA:
274 return pvalue(k1) == pvalueraw(keyval(n2));
275 case LUA_VLCF:
276 return fvalue(k1) == fvalueraw(keyval(n2));
277 case ctb(LUA_VLNGSTR):
278 return luaS_eqstr(tsvalue(k1), keystrval(n2));
279 default:
280 return gcvalue(k1) == gcvalueraw(keyval(n2));
281 }
282 }
283}
284
285
286/*

Callers 1

getgenericFunction · 0.70

Calls 1

luaS_eqstrFunction · 0.70

Tested by

no test coverage detected