diff options
Diffstat (limited to 'src/lj_obj.h')
-rw-r--r-- | src/lj_obj.h | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/src/lj_obj.h b/src/lj_obj.h index defb2088..819930c6 100644 --- a/src/lj_obj.h +++ b/src/lj_obj.h | |||
@@ -141,7 +141,7 @@ typedef LJ_ALIGN(8) union TValue { | |||
141 | struct { | 141 | struct { |
142 | LJ_ENDIAN_LOHI( | 142 | LJ_ENDIAN_LOHI( |
143 | GCRef gcr; /* GCobj reference (if any). */ | 143 | GCRef gcr; /* GCobj reference (if any). */ |
144 | , int32_t it; /* Internal object tag. Must overlap MSW of number. */ | 144 | , uint32_t it; /* Internal object tag. Must overlap MSW of number. */ |
145 | ) | 145 | ) |
146 | }; | 146 | }; |
147 | struct { | 147 | struct { |
@@ -186,42 +186,41 @@ typedef const TValue cTValue; | |||
186 | ** GC objects are at the end, table/userdata must be lowest. | 186 | ** GC objects are at the end, table/userdata must be lowest. |
187 | ** Also check lj_ir.h for similar ordering constraints. | 187 | ** Also check lj_ir.h for similar ordering constraints. |
188 | */ | 188 | */ |
189 | #define LJ_TNIL (-1) | 189 | #define LJ_TNIL (~0u) |
190 | #define LJ_TFALSE (-2) | 190 | #define LJ_TFALSE (~1u) |
191 | #define LJ_TTRUE (-3) | 191 | #define LJ_TTRUE (~2u) |
192 | #define LJ_TLIGHTUD (-4) | 192 | #define LJ_TLIGHTUD (~3u) |
193 | #define LJ_TSTR (-5) | 193 | #define LJ_TSTR (~4u) |
194 | #define LJ_TUPVAL (-6) | 194 | #define LJ_TUPVAL (~5u) |
195 | #define LJ_TTHREAD (-7) | 195 | #define LJ_TTHREAD (~6u) |
196 | #define LJ_TPROTO (-8) | 196 | #define LJ_TPROTO (~7u) |
197 | #define LJ_TFUNC (-9) | 197 | #define LJ_TFUNC (~8u) |
198 | #define LJ_TTRACE (-10) | 198 | #define LJ_TTRACE (~9u) |
199 | #define LJ_TTAB (-11) | 199 | #define LJ_TTAB (~10u) |
200 | #define LJ_TUDATA (-12) | 200 | #define LJ_TUDATA (~11u) |
201 | /* This is just the canonical number type used in some places. */ | 201 | /* This is just the canonical number type used in some places. */ |
202 | #define LJ_TNUMX (-13) | 202 | #define LJ_TNUMX (~12u) |
203 | 203 | ||
204 | #if LJ_64 | 204 | #if LJ_64 |
205 | #define LJ_TISNUM ((uint32_t)0xfffeffff) | 205 | #define LJ_TISNUM 0xfffeffffu |
206 | #else | 206 | #else |
207 | #define LJ_TISNUM ((uint32_t)LJ_TNUMX) | 207 | #define LJ_TISNUM LJ_TNUMX |
208 | #endif | 208 | #endif |
209 | #define LJ_TISTRUECOND ((uint32_t)LJ_TFALSE) | 209 | #define LJ_TISTRUECOND LJ_TFALSE |
210 | #define LJ_TISPRI ((uint32_t)LJ_TTRUE) | 210 | #define LJ_TISPRI LJ_TTRUE |
211 | #define LJ_TISGCV ((uint32_t)(LJ_TSTR+1)) | 211 | #define LJ_TISGCV (LJ_TSTR+1) |
212 | #define LJ_TISTABUD ((uint32_t)LJ_TTAB) | 212 | #define LJ_TISTABUD LJ_TTAB |
213 | 213 | ||
214 | /* -- TValue getters/setters ---------------------------------------------- */ | 214 | /* -- TValue getters/setters ---------------------------------------------- */ |
215 | 215 | ||
216 | /* Macros to test types. */ | 216 | /* Macros to test types. */ |
217 | #define itype(o) ((o)->it) | 217 | #define itype(o) ((o)->it) |
218 | #define uitype(o) ((uint32_t)itype(o)) | ||
219 | #define tvisnil(o) (itype(o) == LJ_TNIL) | 218 | #define tvisnil(o) (itype(o) == LJ_TNIL) |
220 | #define tvisfalse(o) (itype(o) == LJ_TFALSE) | 219 | #define tvisfalse(o) (itype(o) == LJ_TFALSE) |
221 | #define tvistrue(o) (itype(o) == LJ_TTRUE) | 220 | #define tvistrue(o) (itype(o) == LJ_TTRUE) |
222 | #define tvisbool(o) (tvisfalse(o) || tvistrue(o)) | 221 | #define tvisbool(o) (tvisfalse(o) || tvistrue(o)) |
223 | #if LJ_64 | 222 | #if LJ_64 |
224 | #define tvislightud(o) ((itype(o) >> 15) == -2) | 223 | #define tvislightud(o) (((int32_t)itype(o) >> 15) == -2) |
225 | #else | 224 | #else |
226 | #define tvislightud(o) (itype(o) == LJ_TLIGHTUD) | 225 | #define tvislightud(o) (itype(o) == LJ_TLIGHTUD) |
227 | #endif | 226 | #endif |
@@ -231,13 +230,12 @@ typedef const TValue cTValue; | |||
231 | #define tvisproto(o) (itype(o) == LJ_TPROTO) | 230 | #define tvisproto(o) (itype(o) == LJ_TPROTO) |
232 | #define tvistab(o) (itype(o) == LJ_TTAB) | 231 | #define tvistab(o) (itype(o) == LJ_TTAB) |
233 | #define tvisudata(o) (itype(o) == LJ_TUDATA) | 232 | #define tvisudata(o) (itype(o) == LJ_TUDATA) |
234 | #define tvisnum(o) (uitype(o) <= LJ_TISNUM) | 233 | #define tvisnum(o) (itype(o) <= LJ_TISNUM) |
235 | 234 | ||
236 | #define tvistruecond(o) (uitype(o) < LJ_TISTRUECOND) | 235 | #define tvistruecond(o) (itype(o) < LJ_TISTRUECOND) |
237 | #define tvispri(o) (uitype(o) >= LJ_TISPRI) | 236 | #define tvispri(o) (itype(o) >= LJ_TISPRI) |
238 | #define tvistabud(o) (uitype(o) <= LJ_TISTABUD) /* && !tvisnum() */ | 237 | #define tvistabud(o) (itype(o) <= LJ_TISTABUD) /* && !tvisnum() */ |
239 | #define tvisgcv(o) \ | 238 | #define tvisgcv(o) ((itype(o) - LJ_TISGCV) > (LJ_TNUMX - LJ_TISGCV)) |
240 | ((uitype(o) - LJ_TISGCV) > ((uint32_t)LJ_TNUMX - LJ_TISGCV)) | ||
241 | 239 | ||
242 | /* Special macros to test numbers for NaN, +0, -0, +1 and raw equality. */ | 240 | /* Special macros to test numbers for NaN, +0, -0, +1 and raw equality. */ |
243 | #define tvisnan(o) ((o)->n != (o)->n) | 241 | #define tvisnan(o) ((o)->n != (o)->n) |