mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
ops.h: update OP_ARYDUP instruction and rename to OP_ARYSPLAT.
Transforms the value of a splat inside a return statement (similar to an array). For example, `return *nil` should return `nil.to_a`, while `return *1` should return `[1]`
This commit is contained in:
+2
-2
@@ -476,8 +476,8 @@ codedump(mrb_state *mrb, const mrb_irep *irep)
|
||||
printf("ARYPUSH\tR%d\t%d\t", a, b);
|
||||
print_lv_a(mrb, irep, a);
|
||||
break;
|
||||
CASE(OP_ARYDUP, B):
|
||||
printf("ARYDUP\tR%d\t", a);
|
||||
CASE(OP_ARYSPLAT, B):
|
||||
printf("ARYSPLAT\tR%d\t", a);
|
||||
print_lv_a(mrb, irep, a);
|
||||
break;
|
||||
CASE(OP_AREF, BBB):
|
||||
|
||||
@@ -2748,15 +2748,10 @@ RETRY_TRY_BLOCK:
|
||||
NEXT;
|
||||
}
|
||||
|
||||
CASE(OP_ARYDUP, B) {
|
||||
mrb_value ary = regs[a];
|
||||
if (mrb_array_p(ary)) {
|
||||
ary = mrb_ary_new_from_values(mrb, RARRAY_LEN(ary), RARRAY_PTR(ary));
|
||||
}
|
||||
else {
|
||||
ary = mrb_ary_new_from_values(mrb, 1, &ary);
|
||||
}
|
||||
CASE(OP_ARYSPLAT, B) {
|
||||
mrb_value ary = mrb_ary_splat(mrb, regs[a]);
|
||||
regs[a] = ary;
|
||||
mrb_gc_arena_restore(mrb, ai);
|
||||
NEXT;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user