diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-10-19 12:03:12 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-10-19 12:03:12 +0900 |
| commit | 5d5e4f521464d134250501774f49f61f11dc3997 (patch) | |
| tree | b60ec512cf477d04df4e459b879a24b9f80cb9d4 /src/vm.c | |
| parent | 45491cdd8cc00e837448184150e1b3f36f46bf84 (diff) | |
| download | mruby-5d5e4f521464d134250501774f49f61f11dc3997.tar.gz mruby-5d5e4f521464d134250501774f49f61f11dc3997.zip | |
ops.h: add new instructions `OP_SSEND` and `OP_SSENDB`.
These instructions call methods of the receiver.
Diffstat (limited to 'src/vm.c')
| -rw-r--r-- | src/vm.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -1539,6 +1539,17 @@ RETRY_TRY_BLOCK: NEXT; } + CASE(OP_SSEND, BBB) { + regs[a] = regs[0]; + insn = OP_SEND; + } + goto L_SENDB; + + CASE(OP_SSENDB, BBB) { + regs[a] = regs[0]; + } + goto L_SENDB; + CASE(OP_SEND, BBB) goto L_SENDB; @@ -1556,7 +1567,7 @@ RETRY_TRY_BLOCK: int n = c&0xf; int nk = (c>>4)&0xf; mrb_callinfo *ci = mrb->c->ci; - mrb_int bidx = a + ((n == 15) ? 1 : n) + ((nk == 15) ? 1 : 2*nk) + 1; + mrb_int bidx = a + mrb_bidx(c); mrb_method_t m; struct RClass *cls; mrb_value recv; @@ -1570,11 +1581,12 @@ RETRY_TRY_BLOCK: } mrb_assert(bidx < irep->nregs+a); - mrb_value blk = mrb_nil_value(); - mrb_int new_bidx = a+((n==15)?1:n)+1+(nk==15); + mrb_value blk; + mrb_int new_bidx = a+mrb_bidx(c); if (insn == OP_SEND) { /* clear block argument */ SET_NIL_VALUE(regs[new_bidx]); + SET_NIL_VALUE(blk); } else { blk = regs[bidx]; |
