diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-01-31 13:13:28 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-01-31 13:13:28 -0300 |
commit | 28ef7061bbcce39590c97a2ad662e0b60f7adab5 (patch) | |
tree | 955b63ae68b5e82f10ebc64cce3de492c43f71a5 /lobject.h | |
parent | 46c3587a6feb28e1ee4a32aabe463b0ecb9e8f5e (diff) | |
download | lua-28ef7061bbcce39590c97a2ad662e0b60f7adab5.tar.gz lua-28ef7061bbcce39590c97a2ad662e0b60f7adab5.tar.bz2 lua-28ef7061bbcce39590c97a2ad662e0b60f7adab5.zip |
Tag values don't need to be different from type values
Variants can use zero for first variant.
Diffstat (limited to 'lobject.h')
-rw-r--r-- | lobject.h | 37 |
1 files changed, 19 insertions, 18 deletions
@@ -155,13 +155,13 @@ typedef StackValue *StkId; | |||
155 | */ | 155 | */ |
156 | 156 | ||
157 | /* Standard nil */ | 157 | /* Standard nil */ |
158 | #define LUA_VNIL makevariant(LUA_TNIL, 1) | 158 | #define LUA_VNIL makevariant(LUA_TNIL, 0) |
159 | 159 | ||
160 | /* Empty slot (which might be different from a slot containing nil) */ | 160 | /* Empty slot (which might be different from a slot containing nil) */ |
161 | #define LUA_VEMPTY makevariant(LUA_TNIL, 2) | 161 | #define LUA_VEMPTY makevariant(LUA_TNIL, 1) |
162 | 162 | ||
163 | /* Value returned for a key not found in a table (absent key) */ | 163 | /* Value returned for a key not found in a table (absent key) */ |
164 | #define LUA_VABSTKEY makevariant(LUA_TNIL, 3) | 164 | #define LUA_VABSTKEY makevariant(LUA_TNIL, 2) |
165 | 165 | ||
166 | 166 | ||
167 | /* macro to test for (any kind of) nil */ | 167 | /* macro to test for (any kind of) nil */ |
@@ -211,8 +211,8 @@ typedef StackValue *StkId; | |||
211 | */ | 211 | */ |
212 | 212 | ||
213 | 213 | ||
214 | #define LUA_VFALSE makevariant(LUA_TBOOLEAN, 1) | 214 | #define LUA_VFALSE makevariant(LUA_TBOOLEAN, 0) |
215 | #define LUA_VTRUE makevariant(LUA_TBOOLEAN, 2) | 215 | #define LUA_VTRUE makevariant(LUA_TBOOLEAN, 1) |
216 | 216 | ||
217 | #define ttisboolean(o) checktype((o), LUA_TBOOLEAN) | 217 | #define ttisboolean(o) checktype((o), LUA_TBOOLEAN) |
218 | #define ttisfalse(o) checktag((o), LUA_VFALSE) | 218 | #define ttisfalse(o) checktag((o), LUA_VFALSE) |
@@ -234,7 +234,7 @@ typedef StackValue *StkId; | |||
234 | ** =================================================================== | 234 | ** =================================================================== |
235 | */ | 235 | */ |
236 | 236 | ||
237 | #define LUA_VTHREAD makevariant(LUA_TTHREAD, 1) | 237 | #define LUA_VTHREAD makevariant(LUA_TTHREAD, 0) |
238 | 238 | ||
239 | #define ttisthread(o) checktag((o), ctb(LUA_VTHREAD)) | 239 | #define ttisthread(o) checktag((o), ctb(LUA_VTHREAD)) |
240 | 240 | ||
@@ -295,8 +295,8 @@ typedef struct GCObject { | |||
295 | */ | 295 | */ |
296 | 296 | ||
297 | /* Variant tags for numbers */ | 297 | /* Variant tags for numbers */ |
298 | #define LUA_VNUMINT makevariant(LUA_TNUMBER, 1) /* integer numbers */ | 298 | #define LUA_VNUMINT makevariant(LUA_TNUMBER, 0) /* integer numbers */ |
299 | #define LUA_VNUMFLT makevariant(LUA_TNUMBER, 2) /* float numbers */ | 299 | #define LUA_VNUMFLT makevariant(LUA_TNUMBER, 1) /* float numbers */ |
300 | 300 | ||
301 | #define ttisnumber(o) checktype((o), LUA_TNUMBER) | 301 | #define ttisnumber(o) checktype((o), LUA_TNUMBER) |
302 | #define ttisfloat(o) checktag((o), LUA_VNUMFLT) | 302 | #define ttisfloat(o) checktag((o), LUA_VNUMFLT) |
@@ -332,8 +332,8 @@ typedef struct GCObject { | |||
332 | */ | 332 | */ |
333 | 333 | ||
334 | /* Variant tags for strings */ | 334 | /* Variant tags for strings */ |
335 | #define LUA_VSHRSTR makevariant(LUA_TSTRING, 1) /* short strings */ | 335 | #define LUA_VSHRSTR makevariant(LUA_TSTRING, 0) /* short strings */ |
336 | #define LUA_VLNGSTR makevariant(LUA_TSTRING, 2) /* long strings */ | 336 | #define LUA_VLNGSTR makevariant(LUA_TSTRING, 1) /* long strings */ |
337 | 337 | ||
338 | #define ttisstring(o) checktype((o), LUA_TSTRING) | 338 | #define ttisstring(o) checktype((o), LUA_TSTRING) |
339 | #define ttisshrstring(o) checktag((o), ctb(LUA_VSHRSTR)) | 339 | #define ttisshrstring(o) checktag((o), ctb(LUA_VSHRSTR)) |
@@ -403,8 +403,9 @@ typedef struct TString { | |||
403 | ** Light userdata should be a variant of userdata, but for compatibility | 403 | ** Light userdata should be a variant of userdata, but for compatibility |
404 | ** reasons they are also different types. | 404 | ** reasons they are also different types. |
405 | */ | 405 | */ |
406 | #define LUA_VLIGHTUSERDATA makevariant(LUA_TLIGHTUSERDATA, 1) | 406 | #define LUA_VLIGHTUSERDATA makevariant(LUA_TLIGHTUSERDATA, 0) |
407 | #define LUA_VUSERDATA makevariant(LUA_TUSERDATA, 1) | 407 | |
408 | #define LUA_VUSERDATA makevariant(LUA_TUSERDATA, 0) | ||
408 | 409 | ||
409 | #define ttislightuserdata(o) checktag((o), LUA_VLIGHTUSERDATA) | 410 | #define ttislightuserdata(o) checktag((o), LUA_VLIGHTUSERDATA) |
410 | #define ttisfulluserdata(o) checktag((o), ctb(LUA_VUSERDATA)) | 411 | #define ttisfulluserdata(o) checktag((o), ctb(LUA_VUSERDATA)) |
@@ -482,7 +483,7 @@ typedef struct Udata0 { | |||
482 | ** =================================================================== | 483 | ** =================================================================== |
483 | */ | 484 | */ |
484 | 485 | ||
485 | #define LUA_VPROTO makevariant(LUA_TPROTO, 1) | 486 | #define LUA_VPROTO makevariant(LUA_TPROTO, 0) |
486 | 487 | ||
487 | 488 | ||
488 | /* | 489 | /* |
@@ -559,13 +560,13 @@ typedef struct Proto { | |||
559 | ** =================================================================== | 560 | ** =================================================================== |
560 | */ | 561 | */ |
561 | 562 | ||
562 | #define LUA_VUPVAL makevariant(LUA_TUPVAL, 1) | 563 | #define LUA_VUPVAL makevariant(LUA_TUPVAL, 0) |
563 | 564 | ||
564 | 565 | ||
565 | /* Variant tags for functions */ | 566 | /* Variant tags for functions */ |
566 | #define LUA_VLCL makevariant(LUA_TFUNCTION, 1) /* Lua closure */ | 567 | #define LUA_VLCL makevariant(LUA_TFUNCTION, 0) /* Lua closure */ |
567 | #define LUA_VLCF makevariant(LUA_TFUNCTION, 2) /* light C function */ | 568 | #define LUA_VLCF makevariant(LUA_TFUNCTION, 1) /* light C function */ |
568 | #define LUA_VCCL makevariant(LUA_TFUNCTION, 3) /* C closure */ | 569 | #define LUA_VCCL makevariant(LUA_TFUNCTION, 2) /* C closure */ |
569 | 570 | ||
570 | #define ttisfunction(o) checktype(o, LUA_TFUNCTION) | 571 | #define ttisfunction(o) checktype(o, LUA_TFUNCTION) |
571 | #define ttisclosure(o) ((rawtt(o) & 0x1F) == LUA_VLCL) | 572 | #define ttisclosure(o) ((rawtt(o) & 0x1F) == LUA_VLCL) |
@@ -650,7 +651,7 @@ typedef union Closure { | |||
650 | ** =================================================================== | 651 | ** =================================================================== |
651 | */ | 652 | */ |
652 | 653 | ||
653 | #define LUA_VTABLE makevariant(LUA_TTABLE, 1) | 654 | #define LUA_VTABLE makevariant(LUA_TTABLE, 0) |
654 | 655 | ||
655 | #define ttistable(o) checktag((o), ctb(LUA_VTABLE)) | 656 | #define ttistable(o) checktag((o), ctb(LUA_VTABLE)) |
656 | 657 | ||