diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-02-25 09:52:32 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-02-25 09:52:32 -0300 |
commit | 75efc6722bf3bf31adffed44407674f74ac6caed (patch) | |
tree | 9760515466b7844fb9bccf08020c488e285cccc3 /lobject.h | |
parent | d766e2ae175495da85714d00e61d76174c5acc5b (diff) | |
download | lua-75efc6722bf3bf31adffed44407674f74ac6caed.tar.gz lua-75efc6722bf3bf31adffed44407674f74ac6caed.tar.bz2 lua-75efc6722bf3bf31adffed44407674f74ac6caed.zip |
avoid variant tags with the same value of the original type
(to expose bugs more easily)
Diffstat (limited to 'lobject.h')
-rw-r--r-- | lobject.h | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.h,v 2.137 2018/02/23 13:13:31 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 2.138 2018/02/25 12:48:16 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 | */ |
@@ -267,8 +267,8 @@ typedef struct GCObject { | |||
267 | */ | 267 | */ |
268 | 268 | ||
269 | /* Variant tags for numbers */ | 269 | /* Variant tags for numbers */ |
270 | #define LUA_TNUMFLT (LUA_TNUMBER | (0 << 4)) /* float numbers */ | 270 | #define LUA_TNUMFLT (LUA_TNUMBER | (1 << 4)) /* float numbers */ |
271 | #define LUA_TNUMINT (LUA_TNUMBER | (1 << 4)) /* integer numbers */ | 271 | #define LUA_TNUMINT (LUA_TNUMBER | (2 << 4)) /* integer numbers */ |
272 | 272 | ||
273 | #define ttisnumber(o) checktype((o), LUA_TNUMBER) | 273 | #define ttisnumber(o) checktype((o), LUA_TNUMBER) |
274 | #define ttisfloat(o) checktag((o), LUA_TNUMFLT) | 274 | #define ttisfloat(o) checktag((o), LUA_TNUMFLT) |
@@ -304,8 +304,8 @@ typedef struct GCObject { | |||
304 | */ | 304 | */ |
305 | 305 | ||
306 | /* Variant tags for strings */ | 306 | /* Variant tags for strings */ |
307 | #define LUA_TSHRSTR (LUA_TSTRING | (0 << 4)) /* short strings */ | 307 | #define LUA_TSHRSTR (LUA_TSTRING | (1 << 4)) /* short strings */ |
308 | #define LUA_TLNGSTR (LUA_TSTRING | (1 << 4)) /* long strings */ | 308 | #define LUA_TLNGSTR (LUA_TSTRING | (2 << 4)) /* long strings */ |
309 | 309 | ||
310 | #define ttisstring(o) checktype((o), LUA_TSTRING) | 310 | #define ttisstring(o) checktype((o), LUA_TSTRING) |
311 | #define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR)) | 311 | #define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR)) |
@@ -511,12 +511,12 @@ typedef struct Proto { | |||
511 | */ | 511 | */ |
512 | 512 | ||
513 | /* Variant tags for functions */ | 513 | /* Variant tags for functions */ |
514 | #define LUA_TLCL (LUA_TFUNCTION | (0 << 4)) /* Lua closure */ | 514 | #define LUA_TLCL (LUA_TFUNCTION | (1 << 4)) /* Lua closure */ |
515 | #define LUA_TLCF (LUA_TFUNCTION | (1 << 4)) /* light C function */ | 515 | #define LUA_TLCF (LUA_TFUNCTION | (2 << 4)) /* light C function */ |
516 | #define LUA_TCCL (LUA_TFUNCTION | (2 << 4)) /* C closure */ | 516 | #define LUA_TCCL (LUA_TFUNCTION | (3 << 4)) /* C closure */ |
517 | 517 | ||
518 | #define ttisfunction(o) checktype(o, LUA_TFUNCTION) | 518 | #define ttisfunction(o) checktype(o, LUA_TFUNCTION) |
519 | #define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TFUNCTION) | 519 | #define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TLCL) |
520 | #define ttisLclosure(o) checktag((o), ctb(LUA_TLCL)) | 520 | #define ttisLclosure(o) checktag((o), ctb(LUA_TLCL)) |
521 | #define ttislcf(o) checktag((o), LUA_TLCF) | 521 | #define ttislcf(o) checktag((o), LUA_TLCF) |
522 | #define ttisCclosure(o) checktag((o), ctb(LUA_TCCL)) | 522 | #define ttisCclosure(o) checktag((o), ctb(LUA_TCCL)) |