Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/objects/lfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,9 @@ typedef union StackValue *StkId;
** {==================================================================
** Functions
** ===================================================================
** Note: LUA_VUPVAL, LUA_VLCL, LUA_VLCF, LUA_VCCL now defined in ltvalue.h
*/

inline constexpr int LUA_VUPVAL = makevariant(LUA_TUPVAL, 0);


/* Variant tags for functions */
inline constexpr int LUA_VLCL = makevariant(LUA_TFUNCTION, 0); /* Lua closure */
inline constexpr int LUA_VLCF = makevariant(LUA_TFUNCTION, 1); /* light C function */
inline constexpr int LUA_VCCL = makevariant(LUA_TFUNCTION, 2); /* C closure */

constexpr bool ttisfunction(const TValue* o) noexcept { return checktype(o, LUA_TFUNCTION); }
constexpr bool ttisLclosure(const TValue* o) noexcept { return checktag(o, ctb(LUA_VLCL)); }
constexpr bool ttislcf(const TValue* o) noexcept { return checktag(o, LUA_VLCF); }
Expand Down
40 changes: 6 additions & 34 deletions src/objects/lobject_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ class lua_State;

/*
** Extra types for collectable non-values
** Note: LUA_TUPVAL and LUA_TPROTO now defined in ltvalue.h
*/
inline constexpr int LUA_TUPVAL = LUA_NUMTYPES; /* upvalues */
inline constexpr int LUA_TPROTO = (LUA_NUMTYPES+1); /* function prototypes */
inline constexpr int LUA_TDEADKEY = (LUA_NUMTYPES+2); /* removed keys in tables */


Expand All @@ -38,21 +37,9 @@ inline constexpr int LUA_TOTALTYPES = (LUA_TPROTO + 2);
** {==================================================================
** Nil
** ===================================================================
** Note: LUA_VNIL, LUA_VEMPTY, LUA_VABSTKEY, LUA_VNOTABLE now defined in ltvalue.h
*/

/* Standard nil */
inline constexpr int LUA_VNIL = makevariant(LUA_TNIL, 0);

/* Empty slot (which might be different from a slot containing nil) */
inline constexpr int LUA_VEMPTY = makevariant(LUA_TNIL, 1);

/* Value returned for a key not found in a table (absent key) */
inline constexpr int LUA_VABSTKEY = makevariant(LUA_TNIL, 2);

/* Special variant to signal that a fast get is accessing a non-table */
inline constexpr int LUA_VNOTABLE = makevariant(LUA_TNIL, 3);


/* macro to test for (any kind of) nil */
constexpr bool ttisnil(const TValue* v) noexcept { return checktype(v, LUA_TNIL); }

Expand Down Expand Up @@ -115,12 +102,9 @@ inline void setempty(TValue* v) noexcept { settt_(v, LUA_VEMPTY); }
** {==================================================================
** Booleans
** ===================================================================
** Note: LUA_VFALSE, LUA_VTRUE now defined in ltvalue.h
*/


inline constexpr int LUA_VFALSE = makevariant(LUA_TBOOLEAN, 0);
inline constexpr int LUA_VTRUE = makevariant(LUA_TBOOLEAN, 1);

constexpr bool ttisboolean(const TValue* o) noexcept { return checktype(o, LUA_TBOOLEAN); }
constexpr bool ttisfalse(const TValue* o) noexcept { return checktag(o, LUA_VFALSE); }
constexpr bool ttistrue(const TValue* o) noexcept { return checktag(o, LUA_VTRUE); }
Expand All @@ -146,10 +130,9 @@ inline void setbtvalue(TValue* obj) noexcept { obj->setTrue(); }
** {==================================================================
** Threads
** ===================================================================
** Note: LUA_VTHREAD now defined in ltvalue.h
*/

inline constexpr int LUA_VTHREAD = makevariant(LUA_TTHREAD, 0);

constexpr bool ttisthread(const TValue* o) noexcept { return checktag(o, ctb(LUA_VTHREAD)); }

constexpr bool TValue::isThread() const noexcept { return checktag(this, ctb(LUA_VTHREAD)); }
Expand All @@ -165,12 +148,9 @@ inline lua_State* thvalue(const TValue* o) noexcept { return o->threadValue(); }
** {==================================================================
** Numbers
** ===================================================================
** Note: LUA_VNUMINT, LUA_VNUMFLT now defined in ltvalue.h
*/

/* Variant tags for numbers */
inline constexpr int LUA_VNUMINT = makevariant(LUA_TNUMBER, 0); /* integer numbers */
inline constexpr int LUA_VNUMFLT = makevariant(LUA_TNUMBER, 1); /* float numbers */

constexpr bool ttisnumber(const TValue* o) noexcept { return checktype(o, LUA_TNUMBER); }
constexpr bool ttisfloat(const TValue* o) noexcept { return checktag(o, LUA_VNUMFLT); }
constexpr bool ttisinteger(const TValue* o) noexcept { return checktag(o, LUA_VNUMINT); }
Expand Down Expand Up @@ -339,17 +319,9 @@ inline bool TValue::hasRightType() const noexcept { return typeTag() == gcValue(
** {==================================================================
** Userdata
** ===================================================================
** Note: LUA_VLIGHTUSERDATA, LUA_VUSERDATA now defined in ltvalue.h
*/


/*
** Light userdata should be a variant of userdata, but for compatibility
** reasons they are also different types.
*/
inline constexpr int LUA_VLIGHTUSERDATA = makevariant(LUA_TLIGHTUSERDATA, 0);

inline constexpr int LUA_VUSERDATA = makevariant(LUA_TUSERDATA, 0);

constexpr bool ttislightuserdata(const TValue* o) noexcept { return checktag(o, LUA_VLIGHTUSERDATA); }
constexpr bool ttisfulluserdata(const TValue* o) noexcept { return checktag(o, ctb(LUA_VUSERDATA)); }

Expand Down
3 changes: 1 addition & 2 deletions src/objects/lproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ typedef l_uint32 Instruction;
** {==================================================================
** Prototypes
** ===================================================================
** Note: LUA_VPROTO now defined in ltvalue.h
*/

inline constexpr int LUA_VPROTO = makevariant(LUA_TPROTO, 0);


/*
** Description of an upvalue for function prototypes
Expand Down
5 changes: 1 addition & 4 deletions src/objects/lstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@ class global_State;
** {==================================================================
** Strings
** ===================================================================
** Note: LUA_VSHRSTR, LUA_VLNGSTR now defined in ltvalue.h
*/

/* Variant tags for strings */
inline constexpr int LUA_VSHRSTR = makevariant(LUA_TSTRING, 0); /* short strings */
inline constexpr int LUA_VLNGSTR = makevariant(LUA_TSTRING, 1); /* long strings */

constexpr bool ttisstring(const TValue* o) noexcept { return checktype(o, LUA_TSTRING); }
constexpr bool ttisshrstring(const TValue* o) noexcept { return checktag(o, ctb(LUA_VSHRSTR)); }
constexpr bool ttislngstring(const TValue* o) noexcept { return checktag(o, ctb(LUA_VLNGSTR)); }
Expand Down
3 changes: 1 addition & 2 deletions src/objects/ltable.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ typedef union StackValue *StkId;
** {==================================================================
** Tables
** ===================================================================
** Note: LUA_VTABLE now defined in ltvalue.h
*/

inline constexpr int LUA_VTABLE = makevariant(LUA_TTABLE, 0);

constexpr bool ttistable(const TValue* o) noexcept { return checktag(o, ctb(LUA_VTABLE)); }

constexpr bool TValue::isTable() const noexcept { return checktag(this, ctb(LUA_VTABLE)); }
Expand Down
55 changes: 55 additions & 0 deletions src/objects/ltvalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,61 @@
constexpr int makevariant(int t, int v) noexcept { return (t | (v << 4)); }


/*
** Extra types for collectable non-values
*/
inline constexpr int LUA_TUPVAL = LUA_NUMTYPES; /* upvalues */
inline constexpr int LUA_TPROTO = (LUA_NUMTYPES+1); /* function prototypes */


/*
** {==================================================================
** Variant tags for all Lua types
** ===================================================================
*/

/* Nil variants */
inline constexpr int LUA_VNIL = makevariant(LUA_TNIL, 0);
inline constexpr int LUA_VEMPTY = makevariant(LUA_TNIL, 1);
inline constexpr int LUA_VABSTKEY = makevariant(LUA_TNIL, 2);
inline constexpr int LUA_VNOTABLE = makevariant(LUA_TNIL, 3);

/* Boolean variants */
inline constexpr int LUA_VFALSE = makevariant(LUA_TBOOLEAN, 0);
inline constexpr int LUA_VTRUE = makevariant(LUA_TBOOLEAN, 1);

/* Number variants */
inline constexpr int LUA_VNUMINT = makevariant(LUA_TNUMBER, 0); /* integer numbers */
inline constexpr int LUA_VNUMFLT = makevariant(LUA_TNUMBER, 1); /* float numbers */

/* String variants */
inline constexpr int LUA_VSHRSTR = makevariant(LUA_TSTRING, 0); /* short strings */
inline constexpr int LUA_VLNGSTR = makevariant(LUA_TSTRING, 1); /* long strings */

/* Table variant */
inline constexpr int LUA_VTABLE = makevariant(LUA_TTABLE, 0);

/* Function variants */
inline constexpr int LUA_VLCL = makevariant(LUA_TFUNCTION, 0); /* Lua closure */
inline constexpr int LUA_VLCF = makevariant(LUA_TFUNCTION, 1); /* light C function */
inline constexpr int LUA_VCCL = makevariant(LUA_TFUNCTION, 2); /* C closure */

/* Userdata variants */
inline constexpr int LUA_VLIGHTUSERDATA = makevariant(LUA_TLIGHTUSERDATA, 0);
inline constexpr int LUA_VUSERDATA = makevariant(LUA_TUSERDATA, 0);

/* Thread variant */
inline constexpr int LUA_VTHREAD = makevariant(LUA_TTHREAD, 0);

/* Upvalue variant (collectable non-value) */
inline constexpr int LUA_VUPVAL = makevariant(LUA_TUPVAL, 0);

/* Proto variant (collectable non-value) */
inline constexpr int LUA_VPROTO = makevariant(LUA_TPROTO, 0);

/* }================================================================== */


/*
** Rounding modes for float->integer coercion (needed by TValue conversion methods)
*/
Expand Down
Loading