mikepaul-LuaJIT/src/lj_obj.c

36 lines
938 B
C
Raw Normal View History

2009-12-08 18:46:35 +00:00
/*
** Miscellaneous object handling.
2010-01-09 13:28:11 +00:00
** Copyright (C) 2005-2010 Mike Pall. See Copyright Notice in luajit.h
2009-12-08 18:46:35 +00:00
*/
#define lj_obj_c
#define LUA_CORE
#include "lj_obj.h"
/* Object type names. */
LJ_DATADEF const char *const lj_obj_typename[] = { /* ORDER LUA_T */
"no value", "nil", "boolean", "userdata", "number", "string",
2010-11-26 12:28:46 +00:00
"table", "function", "userdata", "thread", "proto", "cdata"
2009-12-08 18:46:35 +00:00
};
LJ_DATADEF const char *const lj_obj_itypename[] = { /* ORDER LJ_T */
"nil", "boolean", "boolean", "userdata", "string", "upval", "thread",
2010-11-26 12:28:46 +00:00
"proto", "function", "trace", "cdata", "table", "userdata", "number"
2009-12-08 18:46:35 +00:00
};
/* Compare two objects without calling metamethods. */
int lj_obj_equal(cTValue *o1, cTValue *o2)
{
if (itype(o1) == itype(o2)) {
if (tvispri(o1))
return 1;
if (!tvisnum(o1))
return gcrefeq(o1->gcr, o2->gcr);
2009-12-08 18:46:35 +00:00
} else if (!tvisnum(o1) || !tvisnum(o2)) {
return 0;
}
return numV(o1) == numV(o2);
}