Remove MRB_ENV_CLOSED flag

Set `env->cxt` to `NULL` when it is detached from the call frame.
In other words, we can determine if `env->cxt` is `NULL` or not.

Also, `mruby-binding` had been setting `env->cxt` unnecessarily, so this has been fixed.
This commit is contained in:
dearblue
2024-05-30 21:09:49 +09:00
parent 0a11af74f4
commit 7ab6386cc6
3 changed files with 4 additions and 11 deletions
+4 -5
View File
@@ -26,16 +26,15 @@ MRB_BEGIN_DECL
struct REnv {
MRB_OBJECT_HEADER;
mrb_value *stack;
struct mrb_context *cxt;
struct mrb_context *cxt; /* if not null, it means that the stack is shared with the call frame */
mrb_sym mid;
};
/* flags (21bits): 1(close):1(touched):1(heap):8(cioff/bidx):8(stack_len) */
/* flags (21bits): 5(ZERO):8(cioff/bidx):8(stack_len) */
#define MRB_ENV_SET_LEN(e,len) ((e)->flags = (((e)->flags & ~0xff)|((unsigned int)(len) & 0xff)))
#define MRB_ENV_LEN(e) ((mrb_int)((e)->flags & 0xff))
#define MRB_ENV_CLOSED (1<<20)
#define MRB_ENV_CLOSE(e) ((e)->flags |= MRB_ENV_CLOSED)
#define MRB_ENV_ONSTACK_P(e) (((e)->flags & MRB_ENV_CLOSED) == 0)
#define MRB_ENV_CLOSE(e) ((e)->cxt = NULL)
#define MRB_ENV_ONSTACK_P(e) ((e)->cxt != NULL)
#define MRB_ENV_BIDX(e) (((e)->flags >> 8) & 0xff)
#define MRB_ENV_SET_BIDX(e,idx) ((e)->flags = (((e)->flags & ~(0xff<<8))|((unsigned int)(idx) & 0xff)<<8))