[PRISM] Renamed some variables, added comments

This commit is contained in:
Jemma Issroff 2023-11-27 14:07:27 -05:00
parent ba26c6eae0
commit e4dd8f6c9c

View File

@ -997,29 +997,30 @@ pm_setup_args(pm_arguments_node_t *arguments_node, int *flags, struct rb_callinf
}
static void
pm_compile_index_write_nodes_add_send(bool popped, LINK_ANCHOR *const ret, rb_iseq_t *iseq, NODE dummy_line_node, VALUE argc, int flag, int boff)
pm_compile_index_write_nodes_add_send(bool popped, LINK_ANCHOR *const ret, rb_iseq_t *iseq, NODE dummy_line_node, VALUE argc, int flag, int block_offset)
{
if (!popped) {
ADD_INSN1(ret, &dummy_line_node, setn, FIXNUM_INC(argc, 2 + boff));
ADD_INSN1(ret, &dummy_line_node, setn, FIXNUM_INC(argc, 2 + block_offset));
}
if (flag & VM_CALL_ARGS_SPLAT) {
ADD_INSN1(ret, &dummy_line_node, newarray, INT2FIX(1));
if (boff > 0) {
if (block_offset > 0) {
ADD_INSN1(ret, &dummy_line_node, dupn, INT2FIX(3));
ADD_INSN(ret, &dummy_line_node, swap);
ADD_INSN(ret, &dummy_line_node, pop);
PM_SWAP;
PM_POP;
}
ADD_INSN(ret, &dummy_line_node, concatarray);
if (boff > 0) {
if (block_offset > 0) {
ADD_INSN1(ret, &dummy_line_node, setn, INT2FIX(3));
PM_POP;
}
ADD_SEND_WITH_FLAG(ret, &dummy_line_node, idASET, argc, INT2FIX(flag));
}
else {
if (boff > 0)
ADD_INSN(ret, &dummy_line_node, swap);
if (block_offset > 0) {
PM_SWAP;
}
ADD_SEND_WITH_FLAG(ret, &dummy_line_node, idASET, FIXNUM_INC(argc, 1), INT2FIX(flag));
}
@ -1036,23 +1037,23 @@ pm_compile_index_and_or_write_node(bool and_node, pm_node_t *receiver, pm_node_t
PM_COMPILE_NOT_POPPED(receiver);
int flag = 0;
struct rb_callinfo_kwarg *keywords = NULL;
int argc_int = 0;
if (arguments) {
argc_int = pm_setup_args(arguments, &flag, &keywords, iseq, ret, src, popped, scope_node, dummy_line_node, parser);
// Get any arguments, and set the appropriate values for flag
argc_int = pm_setup_args(arguments, &flag, NULL, iseq, ret, src, popped, scope_node, dummy_line_node, parser);
}
VALUE argc = INT2FIX(argc_int);
int boff = 0;
int block_offset = 0;
if (block) {
PM_COMPILE_NOT_POPPED(block);
flag |= VM_CALL_ARGS_BLOCKARG;
boff = 1;
block_offset = 1;
}
ADD_INSN1(ret, &dummy_line_node, dupn, FIXNUM_INC(argc, 1 + boff));
ADD_INSN1(ret, &dummy_line_node, dupn, FIXNUM_INC(argc, 1 + block_offset));
ADD_SEND_WITH_FLAG(ret, &dummy_line_node, idAREF, argc, INT2FIX(flag));
@ -1073,15 +1074,16 @@ pm_compile_index_and_or_write_node(bool and_node, pm_node_t *receiver, pm_node_t
PM_COMPILE_NOT_POPPED(value);
pm_compile_index_write_nodes_add_send(popped, ret, iseq, dummy_line_node, argc, flag, boff);
pm_compile_index_write_nodes_add_send(popped, ret, iseq, dummy_line_node, argc, flag, block_offset);
ADD_INSNL(ret, &dummy_line_node, jump, lfin);
ADD_LABEL(ret, label);
if (!popped) {
ADD_INSN1(ret, &dummy_line_node, setn, FIXNUM_INC(argc, 2 + boff));
ADD_INSN1(ret, &dummy_line_node, setn, FIXNUM_INC(argc, 2 + block_offset));
}
ADD_INSN1(ret, &dummy_line_node, adjuststack, FIXNUM_INC(argc, 2 + boff));
ADD_INSN1(ret, &dummy_line_node, adjuststack, FIXNUM_INC(argc, 2 + block_offset));
ADD_LABEL(ret, lfin);
return;
}
@ -2769,15 +2771,16 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
}
VALUE argc = INT2FIX(argc_int);
int boff = 0;
int block_offset = 0;
if (index_operator_write_node->block) {
PM_COMPILE_NOT_POPPED(index_operator_write_node->block);
flag |= VM_CALL_ARGS_BLOCKARG;
boff = 1;
block_offset = 1;
}
ADD_INSN1(ret, &dummy_line_node, dupn, FIXNUM_INC(argc, 1 + boff));
ADD_INSN1(ret, &dummy_line_node, dupn, FIXNUM_INC(argc, 1 + block_offset));
ADD_SEND_WITH_FLAG(ret, &dummy_line_node, idAREF, argc, INT2FIX(flag));
@ -2786,7 +2789,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
ID method_id = pm_constant_id_lookup(scope_node, index_operator_write_node->operator);
ADD_SEND(ret, &dummy_line_node, method_id, INT2FIX(1));
pm_compile_index_write_nodes_add_send(popped, ret, iseq, dummy_line_node, argc, flag, boff);
pm_compile_index_write_nodes_add_send(popped, ret, iseq, dummy_line_node, argc, flag, block_offset);
return;
}