'luaH_get' functions return tag of the result
Undoing previous commit. Returning TValue increases code size without any visible gains. Returning the tag is a little simpler than returning a special code (HOK/HNOTFOUND) and the tag is useful by itself in some cases.
This commit is contained in:
26
lobject.h
26
lobject.h
@@ -75,7 +75,6 @@ typedef struct TValue {
|
||||
|
||||
/* raw type tag of a TValue */
|
||||
#define rawtt(o) ((o)->tt_)
|
||||
#define rawttV(o) ((o).tt_)
|
||||
|
||||
/* tag with no variants (bits 0-3) */
|
||||
#define novariant(t) ((t) & 0x0F)
|
||||
@@ -83,18 +82,14 @@ typedef struct TValue {
|
||||
/* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */
|
||||
#define withvariant(t) ((t) & 0x3F)
|
||||
#define ttypetag(o) withvariant(rawtt(o))
|
||||
#define ttypetagV(o) withvariant(rawttV(o))
|
||||
|
||||
/* type of a TValue */
|
||||
#define ttype(o) (novariant(rawtt(o)))
|
||||
#define ttypeV(o) (novariant(rawttV(o)))
|
||||
|
||||
|
||||
/* Macros to test type */
|
||||
#define checktag(o,t) (rawtt(o) == (t))
|
||||
#define checktagV(o,t) (rawttV(o) == (t))
|
||||
#define checktype(o,t) (ttype(o) == (t))
|
||||
#define checktypeV(o,t) (ttypeV(o) == (t))
|
||||
|
||||
|
||||
/* Macros for internal tests */
|
||||
@@ -117,7 +112,6 @@ typedef struct TValue {
|
||||
|
||||
/* set a value's tag */
|
||||
#define settt_(o,t) ((o)->tt_=(t))
|
||||
#define setttV_(o,t) ((o).tt_=(t))
|
||||
|
||||
|
||||
/* main macro to copy values (from 'obj2' to 'obj1') */
|
||||
@@ -126,11 +120,6 @@ typedef struct TValue {
|
||||
io1->value_ = io2->value_; settt_(io1, io2->tt_); \
|
||||
checkliveness(L,io1); lua_assert(!isnonstrictnil(io1)); }
|
||||
|
||||
#define setobjV(L,obj1,obj2) \
|
||||
{ TValue *io1=(obj1); const TValue io2=(obj2); \
|
||||
io1->value_ = io2.value_; settt_(io1, io2.tt_); \
|
||||
checkliveness(L,io1); lua_assert(!isnonstrictnil(io1)); }
|
||||
|
||||
/*
|
||||
** Different types of assignments, according to source and destination.
|
||||
** (They are mostly equal now, but may be different in the future.)
|
||||
@@ -199,16 +188,19 @@ typedef union {
|
||||
/* Value returned for a key not found in a table (absent key) */
|
||||
#define LUA_VABSTKEY makevariant(LUA_TNIL, 2)
|
||||
|
||||
/* Special "value" to signal that a fast get is accessing a non-table */
|
||||
#define LUA_VNOTABLE makevariant(LUA_TNIL, 3)
|
||||
|
||||
#define setnotableV(obj) setttV_(obj, LUA_VNOTABLE)
|
||||
/* Special variant to signal that a fast get is accessing a non-table */
|
||||
#define LUA_VNOTABLE makevariant(LUA_TNIL, 3)
|
||||
|
||||
|
||||
/* macro to test for (any kind of) nil */
|
||||
#define ttisnil(v) checktype((v), LUA_TNIL)
|
||||
#define ttisnilV(v) checktypeV((v), LUA_TNIL)
|
||||
|
||||
/*
|
||||
** Macro to test the result of a table access. Formally, it should
|
||||
** distinguish between LUA_VEMPTY/LUA_VABSTKEY/LUA_VNOTABLE and
|
||||
** other tags. As currently nil is equivalent to LUA_VEMPTY, it is
|
||||
** simpler to just test whether the value is nil.
|
||||
*/
|
||||
#define tagisempty(tag) (novariant(tag) == LUA_TNIL)
|
||||
|
||||
|
||||
@@ -234,7 +226,6 @@ typedef union {
|
||||
** be accepted as empty.)
|
||||
*/
|
||||
#define isempty(v) ttisnil(v)
|
||||
#define isemptyV(v) checktypeV((v), LUA_TNIL)
|
||||
|
||||
|
||||
/* macro defining a value corresponding to an absent key */
|
||||
@@ -346,7 +337,6 @@ typedef struct GCObject {
|
||||
#define ttisnumber(o) checktype((o), LUA_TNUMBER)
|
||||
#define ttisfloat(o) checktag((o), LUA_VNUMFLT)
|
||||
#define ttisinteger(o) checktag((o), LUA_VNUMINT)
|
||||
#define ttisintegerV(o) checktagV((o), LUA_VNUMINT)
|
||||
|
||||
#define nvalue(o) check_exp(ttisnumber(o), \
|
||||
(ttisinteger(o) ? cast_num(ivalue(o)) : fltvalue(o)))
|
||||
|
||||
Reference in New Issue
Block a user