diff options
author | Mike Pall <mike> | 2009-12-08 19:46:35 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2009-12-08 19:46:35 +0100 |
commit | 55b16959717084884fd4a0cbae6d19e3786c20c7 (patch) | |
tree | c8a07a43c13679751ed25a9d06796e9e7b2134a6 /src/lj_obj.c | |
download | luajit-2.0.0-beta1.tar.gz luajit-2.0.0-beta1.tar.bz2 luajit-2.0.0-beta1.zip |
RELEASE LuaJIT-2.0.0-beta1v2.0.0-beta1
Diffstat (limited to '')
-rw-r--r-- | src/lj_obj.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/lj_obj.c b/src/lj_obj.c new file mode 100644 index 00000000..d26a6b38 --- /dev/null +++ b/src/lj_obj.c | |||
@@ -0,0 +1,41 @@ | |||
1 | /* | ||
2 | ** Miscellaneous object handling. | ||
3 | ** Copyright (C) 2005-2009 Mike Pall. See Copyright Notice in luajit.h | ||
4 | */ | ||
5 | |||
6 | #define lj_obj_c | ||
7 | #define LUA_CORE | ||
8 | |||
9 | #include "lj_obj.h" | ||
10 | |||
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", "upval" | ||
15 | }; | ||
16 | |||
17 | LJ_DATADEF const char *const lj_obj_itypename[] = { /* ORDER LJ_T */ | ||
18 | "nil", "boolean", "boolean", "userdata", "string", "upval", "thread", | ||
19 | "proto", "function", "deadkey", "table", "userdata", "number" | ||
20 | }; | ||
21 | |||
22 | /* Compare two objects without calling metamethods. */ | ||
23 | int lj_obj_equal(cTValue *o1, cTValue *o2) | ||
24 | { | ||
25 | if (itype(o1) == itype(o2)) { | ||
26 | if (tvispri(o1)) | ||
27 | return 1; | ||
28 | if (!tvisnum(o1)) { | ||
29 | #if LJ_64 | ||
30 | if (tvislightud(o1)) | ||
31 | return o1->u64 == o2->u64; | ||
32 | else | ||
33 | #endif | ||
34 | return gcrefeq(o1->gcr, o2->gcr); | ||
35 | } | ||
36 | } else if (!tvisnum(o1) || !tvisnum(o2)) { | ||
37 | return 0; | ||
38 | } | ||
39 | return numV(o1) == numV(o2); | ||
40 | } | ||
41 | |||