Move a GC macro.
[luajit-2.0/celess22.git] / src / lj_obj.c
blob04aeb461ef030726d7cfc942ee7d32f4032db8cb
1 /*
2 ** Miscellaneous object handling.
3 ** Copyright (C) 2005-2012 Mike Pall. See Copyright Notice in luajit.h
4 */
6 #define lj_obj_c
7 #define LUA_CORE
9 #include "lj_obj.h"
11 /* Object type names. */
12 LJ_DATADEF const char *const lj_obj_typename[] = { /* ORDER LUA_T */
13 "no value", "nil", "boolean", "userdata", "number", "string",
14 "table", "function", "userdata", "thread", "proto", "cdata"
17 LJ_DATADEF const char *const lj_obj_itypename[] = { /* ORDER LJ_T */
18 "nil", "boolean", "boolean", "userdata", "string", "upval", "thread",
19 "proto", "function", "trace", "cdata", "table", "userdata", "number"
22 /* Compare two objects without calling metamethods. */
23 int lj_obj_equal(cTValue *o1, cTValue *o2)
25 if (itype(o1) == itype(o2)) {
26 if (tvispri(o1))
27 return 1;
28 if (!tvisnum(o1))
29 return gcrefeq(o1->gcr, o2->gcr);
30 } else if (!tvisnumber(o1) || !tvisnumber(o2)) {
31 return 0;
33 return numberVnum(o1) == numberVnum(o2);