mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 13:04:13 +02:00
[PRISM] Account for multiple arguments when compiling ArgumentsNode
BreakNode, ReturnNode and NextNode all compile the ArgumentsNode directly, but we weren't accounting for multiple arguments. If there is more than one argument, we need to also emit a newarray instruction to put the arguments onto the stack
This commit is contained in:
parent
7738b31d39
commit
a0c7bb4328
2 changed files with 29 additions and 3 deletions
|
@ -1762,6 +1762,9 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||
for (size_t index = 0; index < node_list.size; index++) {
|
||||
PM_COMPILE(node_list.nodes[index]);
|
||||
}
|
||||
if (node_list.size > 1) {
|
||||
ADD_INSN1(ret, &dummy_line_node, newarray, INT2FIX(node_list.size));
|
||||
}
|
||||
return;
|
||||
}
|
||||
case PM_ARRAY_NODE: {
|
||||
|
@ -3578,7 +3581,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||
ADD_ADJUST(ret, &dummy_line_node, ISEQ_COMPILE_DATA(iseq)->start_label);
|
||||
|
||||
if (next_node->arguments) {
|
||||
PM_COMPILE((pm_node_t *)next_node->arguments);
|
||||
PM_COMPILE_NOT_POPPED((pm_node_t *)next_node->arguments);
|
||||
}
|
||||
else {
|
||||
PM_PUTNIL;
|
||||
|
@ -3618,7 +3621,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||
}
|
||||
if (ip != 0) {
|
||||
if (next_node->arguments) {
|
||||
PM_COMPILE((pm_node_t *)next_node->arguments);
|
||||
PM_COMPILE_NOT_POPPED((pm_node_t *)next_node->arguments);
|
||||
}
|
||||
else {
|
||||
PM_PUTNIL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue