mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby/ops.h: add new instructions OP_GETIDX and OP_SETIDX.
Which represent `obj[int]` and `obj[int]=val` respectively where `obj` is either `string`, `array` or `hash`, so that index access could be faster. When `obj` is not assumed type or `R(a+1)` is not integer, the instructions fallback to method calls.
This commit is contained in:
@@ -265,6 +265,12 @@ codedump(mrb_state *mrb, const mrb_irep *irep)
|
||||
printf("OP_SETCV\t%s\tR%d\t", mrb_sym_dump(mrb, irep->syms[b]), a);
|
||||
print_lv_a(mrb, irep, a);
|
||||
break;
|
||||
CASE(OP_GETIDX, B):
|
||||
printf("OP_GETIDX\tR%d\tR%d\n", a, a+1);
|
||||
break;
|
||||
CASE(OP_SETIDX, B):
|
||||
printf("OP_SETIDX\tR%d\tR%d\tR%d\n", a, a+1, a+2);
|
||||
break;
|
||||
CASE(OP_JMP, S):
|
||||
i = pc - irep->iseq;
|
||||
printf("OP_JMP\t\t%03d\n", (int)i+(int16_t)a);
|
||||
|
||||
Reference in New Issue
Block a user