diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-07-21 14:56:59 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-07-21 14:56:59 -0300 |
| commit | 15231d4fb2f6984b25e0353ff46eda1a180b686d (patch) | |
| tree | fea343d493f04539a2a9ebe46c838cc5b8a01cd5 /lstate.h | |
| parent | f407b3c4a1bc9667867ec51e835c20d97aab55a2 (diff) | |
| download | lua-15231d4fb2f6984b25e0353ff46eda1a180b686d.tar.gz lua-15231d4fb2f6984b25e0353ff46eda1a180b686d.tar.bz2 lua-15231d4fb2f6984b25e0353ff46eda1a180b686d.zip | |
'nresults' moved into 'callstatus'
That gives us more free bits in 'callstatus', for future use.
Diffstat (limited to 'lstate.h')
| -rw-r--r-- | lstate.h | 54 |
1 files changed, 35 insertions, 19 deletions
| @@ -211,31 +211,45 @@ struct CallInfo { | |||
| 211 | int ntransfer; /* number of values transferred */ | 211 | int ntransfer; /* number of values transferred */ |
| 212 | } transferinfo; | 212 | } transferinfo; |
| 213 | } u2; | 213 | } u2; |
| 214 | short nresults; /* expected number of results from this function */ | 214 | l_uint32 callstatus; |
| 215 | unsigned short callstatus; | ||
| 216 | }; | 215 | }; |
| 217 | 216 | ||
| 218 | 217 | ||
| 219 | /* | 218 | /* |
| 220 | ** Bits in CallInfo status | 219 | ** Bits in CallInfo status |
| 221 | */ | 220 | */ |
| 222 | #define CIST_OAH (1<<0) /* original value of 'allowhook' */ | 221 | /* bits 0-7 are the expected number of results from this function + 1 */ |
| 223 | #define CIST_C (1<<1) /* call is running a C function */ | 222 | #define CIST_NRESULTS 0xff |
| 224 | #define CIST_FRESH (1<<2) /* call is on a fresh "luaV_execute" frame */ | 223 | /* original value of 'allowhook' */ |
| 225 | #define CIST_HOOKED (1<<3) /* call is running a debug hook */ | 224 | #define CIST_OAH (cast(l_uint32, 1) << 8) |
| 226 | #define CIST_YPCALL (1<<4) /* doing a yieldable protected call */ | 225 | /* call is running a C function */ |
| 227 | #define CIST_TAIL (1<<5) /* call was tail called */ | 226 | #define CIST_C (cast(l_uint32, 1) << 9) |
| 228 | #define CIST_HOOKYIELD (1<<6) /* last hook called yielded */ | 227 | /* call is on a fresh "luaV_execute" frame */ |
| 229 | #define CIST_FIN (1<<7) /* function "called" a finalizer */ | 228 | #define CIST_FRESH (cast(l_uint32, 1) << 10) |
| 230 | #define CIST_TRAN (1<<8) /* 'ci' has transfer information */ | 229 | /* call is running a debug hook */ |
| 231 | #define CIST_CLSRET (1<<9) /* function is closing tbc variables */ | 230 | #define CIST_HOOKED (cast(l_uint32, 1) << 11) |
| 232 | /* Bits 10-12 are used for CIST_RECST (see below) */ | 231 | /* doing a yieldable protected call */ |
| 233 | #define CIST_RECST 10 | 232 | #define CIST_YPCALL (cast(l_uint32, 1) << 12) |
| 233 | /* call was tail called */ | ||
| 234 | #define CIST_TAIL (cast(l_uint32, 1) << 13) | ||
| 235 | /* last hook called yielded */ | ||
| 236 | #define CIST_HOOKYIELD (cast(l_uint32, 1) << 14) | ||
| 237 | /* function "called" a finalizer */ | ||
| 238 | #define CIST_FIN (cast(l_uint32, 1) << 15) | ||
| 239 | /* 'ci' has transfer information */ | ||
| 240 | #define CIST_TRAN (cast(l_uint32, 1) << 16) | ||
| 241 | /* function is closing tbc variables */ | ||
| 242 | #define CIST_CLSRET (cast(l_uint32, 1) << 17) | ||
| 243 | /* Bits 18-20 are used for CIST_RECST (see below) */ | ||
| 244 | #define CIST_RECST 18 /* the offset, not the mask */ | ||
| 234 | #if defined(LUA_COMPAT_LT_LE) | 245 | #if defined(LUA_COMPAT_LT_LE) |
| 235 | #define CIST_LEQ (1<<13) /* using __lt for __le */ | 246 | /* using __lt for __le */ |
| 247 | #define CIST_LEQ (cast(l_uint32, 1) << 21) | ||
| 236 | #endif | 248 | #endif |
| 237 | 249 | ||
| 238 | 250 | ||
| 251 | #define get_nresults(cs) (cast_int((cs) & CIST_NRESULTS) - 1) | ||
| 252 | |||
| 239 | /* | 253 | /* |
| 240 | ** Field CIST_RECST stores the "recover status", used to keep the error | 254 | ** Field CIST_RECST stores the "recover status", used to keep the error |
| 241 | ** status while closing to-be-closed variables in coroutines, so that | 255 | ** status while closing to-be-closed variables in coroutines, so that |
| @@ -246,7 +260,7 @@ struct CallInfo { | |||
| 246 | #define setcistrecst(ci,st) \ | 260 | #define setcistrecst(ci,st) \ |
| 247 | check_exp(((st) & 7) == (st), /* status must fit in three bits */ \ | 261 | check_exp(((st) & 7) == (st), /* status must fit in three bits */ \ |
| 248 | ((ci)->callstatus = ((ci)->callstatus & ~(7 << CIST_RECST)) \ | 262 | ((ci)->callstatus = ((ci)->callstatus & ~(7 << CIST_RECST)) \ |
| 249 | | ((st) << CIST_RECST))) | 263 | | (cast(l_uint32, st) << CIST_RECST))) |
| 250 | 264 | ||
| 251 | 265 | ||
| 252 | /* active function is a Lua function */ | 266 | /* active function is a Lua function */ |
| @@ -255,9 +269,11 @@ struct CallInfo { | |||
| 255 | /* call is running Lua code (not a hook) */ | 269 | /* call is running Lua code (not a hook) */ |
| 256 | #define isLuacode(ci) (!((ci)->callstatus & (CIST_C | CIST_HOOKED))) | 270 | #define isLuacode(ci) (!((ci)->callstatus & (CIST_C | CIST_HOOKED))) |
| 257 | 271 | ||
| 258 | /* assume that CIST_OAH has offset 0 and that 'v' is strictly 0/1 */ | 272 | |
| 259 | #define setoah(st,v) ((st) = ((st) & ~CIST_OAH) | (v)) | 273 | #define setoah(ci,v) \ |
| 260 | #define getoah(st) ((st) & CIST_OAH) | 274 | ((ci)->callstatus = ((v) ? (ci)->callstatus | CIST_OAH \ |
| 275 | : (ci)->callstatus & ~CIST_OAH)) | ||
| 276 | #define getoah(ci) (((ci)->callstatus & CIST_OAH) ? 1 : 0) | ||
| 261 | 277 | ||
| 262 | 278 | ||
| 263 | /* | 279 | /* |
