diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-02-12 13:36:30 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-02-12 13:36:30 -0300 |
| commit | bc970005ce2e258e29a5c315ea4e49f76a66586e (patch) | |
| tree | 5575ca66aeddad2036df74f38fa2bed217c2801e /lstate.h | |
| parent | f79ccdca9bbe9d486d91a44a4464b99ce38de0e2 (diff) | |
| download | lua-bc970005ce2e258e29a5c315ea4e49f76a66586e.tar.gz lua-bc970005ce2e258e29a5c315ea4e49f76a66586e.tar.bz2 lua-bc970005ce2e258e29a5c315ea4e49f76a66586e.zip | |
'__close' methods can yield in the return of a C function
When, inside a coroutine, a C function with to-be-closed slots return,
the corresponding metamethods can yield. ('__close' metamethods called
through 'lua_closeslot' still cannot yield, as there is no continuation
to go when resuming.)
Diffstat (limited to 'lstate.h')
| -rw-r--r-- | lstate.h | 12 |
1 files changed, 8 insertions, 4 deletions
| @@ -164,6 +164,8 @@ typedef struct stringtable { | |||
| 164 | ** protected call; | 164 | ** protected call; |
| 165 | ** - field 'nyield' is used only while a function is "doing" an | 165 | ** - field 'nyield' is used only while a function is "doing" an |
| 166 | ** yield (from the yield until the next resume); | 166 | ** yield (from the yield until the next resume); |
| 167 | ** - field 'nres' is used only while closing tbc variables when | ||
| 168 | ** returning from a C function; | ||
| 167 | ** - field 'transferinfo' is used only during call/returnhooks, | 169 | ** - field 'transferinfo' is used only during call/returnhooks, |
| 168 | ** before the function starts or after it ends. | 170 | ** before the function starts or after it ends. |
| 169 | */ | 171 | */ |
| @@ -186,6 +188,7 @@ typedef struct CallInfo { | |||
| 186 | union { | 188 | union { |
| 187 | int funcidx; /* called-function index */ | 189 | int funcidx; /* called-function index */ |
| 188 | int nyield; /* number of values yielded */ | 190 | int nyield; /* number of values yielded */ |
| 191 | int nres; /* number of values returned */ | ||
| 189 | struct { /* info about transferred values (for call/return hooks) */ | 192 | struct { /* info about transferred values (for call/return hooks) */ |
| 190 | unsigned short ftransfer; /* offset of first value transferred */ | 193 | unsigned short ftransfer; /* offset of first value transferred */ |
| 191 | unsigned short ntransfer; /* number of values transferred */ | 194 | unsigned short ntransfer; /* number of values transferred */ |
| @@ -203,15 +206,16 @@ typedef struct CallInfo { | |||
| 203 | #define CIST_C (1<<1) /* call is running a C function */ | 206 | #define CIST_C (1<<1) /* call is running a C function */ |
| 204 | #define CIST_FRESH (1<<2) /* call is on a fresh "luaV_execute" frame */ | 207 | #define CIST_FRESH (1<<2) /* call is on a fresh "luaV_execute" frame */ |
| 205 | #define CIST_HOOKED (1<<3) /* call is running a debug hook */ | 208 | #define CIST_HOOKED (1<<3) /* call is running a debug hook */ |
| 206 | #define CIST_YPCALL (1<<4) /* call is a yieldable protected call */ | 209 | #define CIST_YPCALL (1<<4) /* doing a yieldable protected call */ |
| 207 | #define CIST_TAIL (1<<5) /* call was tail called */ | 210 | #define CIST_TAIL (1<<5) /* call was tail called */ |
| 208 | #define CIST_HOOKYIELD (1<<6) /* last hook called yielded */ | 211 | #define CIST_HOOKYIELD (1<<6) /* last hook called yielded */ |
| 209 | #define CIST_FIN (1<<7) /* call is running a finalizer */ | 212 | #define CIST_FIN (1<<7) /* call is running a finalizer */ |
| 210 | #define CIST_TRAN (1<<8) /* 'ci' has transfer information */ | 213 | #define CIST_TRAN (1<<8) /* 'ci' has transfer information */ |
| 211 | /* Bits 9-11 are used for CIST_RECST (see below) */ | 214 | #define CIST_CLSRET (1<<9) /* function is closing tbc variables */ |
| 212 | #define CIST_RECST 9 | 215 | /* Bits 10-12 are used for CIST_RECST (see below) */ |
| 216 | #define CIST_RECST 10 | ||
| 213 | #if defined(LUA_COMPAT_LT_LE) | 217 | #if defined(LUA_COMPAT_LT_LE) |
| 214 | #define CIST_LEQ (1<<12) /* using __lt for __le */ | 218 | #define CIST_LEQ (1<<13) /* using __lt for __le */ |
| 215 | #endif | 219 | #endif |
| 216 | 220 | ||
| 217 | 221 | ||
