mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fixed visibility at method definition
There was a problem with visibility state from proc that straddles a fiber or is independent. Therefore, it has been changed to give priority to env objects, if any. Also, added "separate module" flag to block traversal to a higher level env object. Note that the "separate module" flag is now set when calling blocks with the `mrb_yield_with_class()` function. fixed https://github.com/mruby/mruby/issues/6494
This commit is contained in:
@@ -191,9 +191,13 @@ size_t mrb_gc_mark_iv(mrb_state*, struct RObject*);
|
||||
void mrb_gc_free_iv(mrb_state*, struct RObject*);
|
||||
|
||||
/* VM */
|
||||
#define MRB_CI_VISIBILITY(ci) MRB_FLAGS_GET((ci)->vis, 0, 2)
|
||||
#define MRB_CI_SET_VISIBILITY(ci, visi) MRB_FLAGS_SET((ci)->vis, 0, 2, visi)
|
||||
#define MRB_CI_SEPARATE_MODULE_P(ci) MRB_FLAG_P((ci)->vis, 2)
|
||||
#define MRB_CI_SET_SEPARATE_MODULE(ci) MRB_FLAG_ENABLE((ci)->vis, 2)
|
||||
mrb_int mrb_ci_bidx(mrb_callinfo *ci);
|
||||
mrb_int mrb_ci_nregs(mrb_callinfo *ci);
|
||||
mrb_value mrb_exec_irep(mrb_state *mrb, mrb_value self, const struct RProc *p);
|
||||
mrb_value mrb_exec_irep(mrb_state *mrb, mrb_value self, const struct RProc *p, mrb_bool separate_module);
|
||||
mrb_value mrb_obj_instance_eval(mrb_state*, mrb_value);
|
||||
mrb_value mrb_object_exec(mrb_state *mrb, mrb_value self, struct RClass *target_class);
|
||||
mrb_value mrb_mod_module_eval(mrb_state*, mrb_value);
|
||||
|
||||
@@ -30,13 +30,17 @@ struct REnv {
|
||||
mrb_sym mid;
|
||||
};
|
||||
|
||||
/* flags (21bits): 5(ZERO):8(cioff/bidx):8(stack_len) */
|
||||
/* flags (20bits): 1(ZERO):1(separate module):2(visibility):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_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))
|
||||
#define MRB_ENV_SET_VISIBILITY(e, vis) MRB_FLAGS_SET((e)->flags, 16, 2, vis)
|
||||
#define MRB_ENV_VISIBILITY(e) MRB_FLAGS_GET((e)->flags, 16, 2)
|
||||
#define MRB_ENV_SEPARATE_MODULE_P(e) MRB_FLAG_P((e)->flags, 18)
|
||||
#define MRB_ENV_COPY_FLAGS_FROM_CI(e, ci) MRB_FLAGS_SET((e)->flags, 16, 3, (ci)->vis)
|
||||
|
||||
/*
|
||||
* Returns TRUE on success.
|
||||
|
||||
@@ -94,6 +94,14 @@ struct mrb_state;
|
||||
# define MRB_PRIx PRIx32
|
||||
#endif
|
||||
|
||||
#define MRB_FLAGS_MASK(shift, width) (~(~0U << (width)) << (shift))
|
||||
#define MRB_FLAGS_GET(b, s, w) (((b) >> (s)) & MRB_FLAGS_MASK(0, w))
|
||||
#define MRB_FLAGS_SET(b, s, w, n) ((b) = MRB_FLAGS_INVERT_TRIM(b, s, w) | MRB_FLAGS_MAKE(s, w, n))
|
||||
#define MRB_FLAGS_INVERT_TRIM(b, s, w) ((b) & ~MRB_FLAGS_MASK(s, w))
|
||||
#define MRB_FLAGS_MAKE(s, w, n) (((n) & MRB_FLAGS_MASK(0, w)) << (s))
|
||||
#define MRB_FLAG_ENABLE(b, s) ((b) |= MRB_FLAGS_MASK(s, 1))
|
||||
#define MRB_FLAG_P(b, s) (!!((b) & MRB_FLAGS_MASK(s, 1)))
|
||||
|
||||
MRB_API mrb_bool mrb_read_int(const char *p, const char *e, char **endp, mrb_int *np);
|
||||
/* obsolete; do not use mrb_int_read() */
|
||||
MRB_API mrb_int mrb_int_read(const char*, const char*, char**);
|
||||
|
||||
Reference in New Issue
Block a user