aboutsummaryrefslogtreecommitdiff
path: root/lobject.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-02-23 10:16:18 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-02-23 10:16:18 -0300
commit9243c414d92c253edd908f438caa31e2aa16f3f4 (patch)
treee8959a48f4672037aef061cc6eb82bba21d0766b /lobject.h
parent477ca2fe8ceaf79038972977915987adbef0e425 (diff)
downloadlua-9243c414d92c253edd908f438caa31e2aa16f3f4.tar.gz
lua-9243c414d92c253edd908f438caa31e2aa16f3f4.tar.bz2
lua-9243c414d92c253edd908f438caa31e2aa16f3f4.zip
first version of empty entries in tables
(so that, in the future, tables can contain regular nil entries)
Diffstat (limited to 'lobject.h')
-rw-r--r--lobject.h30
1 files changed, 27 insertions, 3 deletions
diff --git a/lobject.h b/lobject.h
index 2b65da36..c6590cf0 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 2.135 2018/02/21 16:28:12 roberto Exp roberto $ 2** $Id: lobject.h,v 2.136 2018/02/22 17:28:10 roberto Exp roberto $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -100,7 +100,7 @@ typedef struct TValue {
100#define setobj(L,obj1,obj2) \ 100#define setobj(L,obj1,obj2) \
101 { TValue *io1=(obj1); const TValue *io2=(obj2); \ 101 { TValue *io1=(obj1); const TValue *io2=(obj2); \
102 io1->value_ = io2->value_; io1->tt_ = io2->tt_; \ 102 io1->value_ = io2->value_; io1->tt_ = io2->tt_; \
103 (void)L; checkliveness(L,io1); } 103 (void)L; checkliveness(L,io1); lua_assert(!isreallyempty(io1)); }
104 104
105/* 105/*
106** different types of assignments, according to destination 106** different types of assignments, according to destination
@@ -148,6 +148,30 @@ typedef StackValue *StkId; /* index to stack elements */
148/* (address of) a fixed nil value */ 148/* (address of) a fixed nil value */
149#define luaO_nilobject (&luaO_nilobject_) 149#define luaO_nilobject (&luaO_nilobject_)
150 150
151
152/*
153** Variant tag, used only in tables to signal an empty slot
154** (which might be different from a slot containing nil)
155*/
156#define LUA_TEMPTY (LUA_TNIL | (1 << 4))
157
158#define ttisnilorempty(v) checktype((v), LUA_TNIL)
159/*
160** By default, entries with any kind of nil are considered empty
161*/
162#define isempty(v) ttisnilorempty(v)
163
164#define isreallyempty(v) checktag((v), LUA_TEMPTY)
165
166/* macro defining an empty value */
167#define EMPTYCONSTANT {NULL}, LUA_TEMPTY
168
169
170/* mark an entry as empty */
171#define setempty(v) settt_(v, LUA_TEMPTY)
172
173
174
151/* }================================================================== */ 175/* }================================================================== */
152 176
153 177
@@ -644,7 +668,7 @@ typedef struct Table {
644 668
645/* 669/*
646** Use a "nil table" to mark dead keys in a table. Those keys serve 670** Use a "nil table" to mark dead keys in a table. Those keys serve
647** only to keep space for removed entries, which may still be part of 671** to keep space for removed entries, which may still be part of
648** chains. Note that the 'keytt' does not have the BIT_ISCOLLECTABLE 672** chains. Note that the 'keytt' does not have the BIT_ISCOLLECTABLE
649** set, so these values are considered not collectable and are different 673** set, so these values are considered not collectable and are different
650** from any valid value. 674** from any valid value.