diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-01-12 18:38:42 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-01-12 18:38:42 +0900 |
| commit | bec4d30dc6620c4102ce7acc08a4cb1c735a6ad5 (patch) | |
| tree | 9b7912d7b859c3cb2ee026a48582934c7af5cd2c /include | |
| parent | e13f34e30866add2ec1829ec1819366844701c34 (diff) | |
| parent | 9877f4ca3c10e21b9d525256fe8cebc4ea404727 (diff) | |
| download | mruby-bec4d30dc6620c4102ce7acc08a4cb1c735a6ad5.tar.gz mruby-bec4d30dc6620c4102ce7acc08a4cb1c735a6ad5.zip | |
Merge branch 'reorganize-ci' of https://github.com/dearblue/mruby into dearblue-reorganize-ci
Diffstat (limited to 'include')
| -rw-r--r-- | include/mruby.h | 18 | ||||
| -rw-r--r-- | include/mruby/proc.h | 68 |
2 files changed, 77 insertions, 9 deletions
diff --git a/include/mruby.h b/include/mruby.h index ccb76ebe4..b54e4f98e 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -151,13 +151,14 @@ typedef void* (*mrb_allocf) (struct mrb_state *mrb, void*, size_t, void *ud); typedef struct { mrb_sym mid; const struct RProc *proc; - mrb_value *stackent; - struct REnv *env; - const mrb_code *pc; /* return address */ - const mrb_code *err; /* error position */ - mrb_int argc; - mrb_int acc; - struct RClass *target_class; + mrb_value *stack; + const mrb_code *pc; /* current address on iseq of this proc */ + int16_t argc; + int16_t acc; + union { + struct REnv *env; + struct RClass *target_class; + } u; } mrb_callinfo; enum mrb_fiber_state { @@ -172,8 +173,7 @@ enum mrb_fiber_state { struct mrb_context { struct mrb_context *prev; - mrb_value *stack; /* stack of virtual machine */ - mrb_value *stbase, *stend; + mrb_value *stbase, *stend; /* stack of virtual machine */ mrb_callinfo *ci; mrb_callinfo *cibase, *ciend; diff --git a/include/mruby/proc.h b/include/mruby/proc.h index 25f4822bc..0edd3e1f1 100644 --- a/include/mruby/proc.h +++ b/include/mruby/proc.h @@ -136,6 +136,74 @@ MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx); MRB_API mrb_value mrb_load_proc(mrb_state *mrb, const struct RProc *proc); +static inline void +mrb_vm_ci_proc_set(mrb_callinfo *ci, const struct RProc *p) +{ + ci->proc = p; + ci->pc = (p && !MRB_PROC_CFUNC_P(p)) ? p->body.irep->iseq : NULL; +} + +static inline struct RClass * +mrb_vm_ci_target_class(const mrb_callinfo *ci) +{ + if (ci->u.env && ci->u.env->tt == MRB_TT_ENV) { + return ci->u.env->c; + } + else { + return ci->u.target_class; + } +} + +static inline void +mrb_vm_ci_target_class_set(mrb_callinfo *ci, struct RClass *tc) +{ + struct REnv *e = ci->u.env; + if (e) { + if (e->tt == MRB_TT_ENV) { + e->c = tc; + } + else { + ci->u.target_class = tc; + } + } +} + +static inline struct REnv * +mrb_vm_ci_env(const mrb_callinfo *ci) +{ + if (ci->u.env && ci->u.env->tt == MRB_TT_ENV) { + return ci->u.env; + } + else { + return NULL; + } +} + +static inline void +mrb_vm_ci_env_set(mrb_callinfo *ci, struct REnv *e) +{ + if (ci->u.env) { + if (ci->u.env->tt == MRB_TT_ENV) { + if (e) { + e->c = ci->u.env->c; + ci->u.env = e; + } + else { + ci->u.target_class = ci->u.env->c; + } + } + else { + if (e) { + e->c = ci->u.target_class; + ci->u.env = e; + } + } + } + else { + ci->u.env = e; + } +} + MRB_END_DECL #endif /* MRUBY_PROC_H */ |
