summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authordearblue <[email protected]>2021-01-10 10:50:22 +0900
committerdearblue <[email protected]>2021-01-10 13:23:43 +0900
commitced89c25ffc9ac748dc2dd336cce24d080ebf419 (patch)
treec72aa35170876cf2904315a43a383127f796ce34 /include
parent16baea06771f38fea810ad1eaf3239086442c258 (diff)
downloadmruby-ced89c25ffc9ac748dc2dd336cce24d080ebf419.tar.gz
mruby-ced89c25ffc9ac748dc2dd336cce24d080ebf419.zip
Unified `pc` and `err` of `mrb_callinfo`
This enhances self-containment. - Changed the `mrb_callinfo::pc` field to point to itself. Previously it indicated the return destination of the previous call level. `mrb_callinfo::pc` will now hold the address to its own `proc->body.irep->iseq`. - Removed `mrb_callinfo::err` field. This is because `mrb_callinfo::pc - 1` is semantically the same as the previous `err`. - The `pc0` and `pc_save` variables in `mrb_vm_exec()` are no longer needed and have been deleted. - It removes the argument because `cipush()` doesn't need to save the previous `pc`.
Diffstat (limited to 'include')
-rw-r--r--include/mruby.h3
-rw-r--r--include/mruby/proc.h7
2 files changed, 8 insertions, 2 deletions
diff --git a/include/mruby.h b/include/mruby.h
index 3f78e66c6..b54e4f98e 100644
--- a/include/mruby.h
+++ b/include/mruby.h
@@ -152,8 +152,7 @@ typedef struct {
mrb_sym mid;
const struct RProc *proc;
mrb_value *stack;
- const mrb_code *pc; /* return address */
- const mrb_code *err; /* error position */
+ const mrb_code *pc; /* current address on iseq of this proc */
int16_t argc;
int16_t acc;
union {
diff --git a/include/mruby/proc.h b/include/mruby/proc.h
index b4d0927a9..be45a06d8 100644
--- a/include/mruby/proc.h
+++ b/include/mruby/proc.h
@@ -136,6 +136,13 @@ 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)
{