diff options
author | Jemma Issroff <jemmaissroff@gmail.com> | 2023-10-25 12:58:45 -0300 |
---|---|---|
committer | Jemma Issroff <jemmaissroff@gmail.com> | 2023-10-26 07:15:35 -0300 |
commit | 8e5744588f9e04273f4c37268c9954c9174be671 (patch) | |
tree | 42fdecb038ce8b2099251574d74e34f26ae248a0 /prism_compile.c | |
parent | 68a81b44e3907f2ceb4dc3864e65b565c42d1c63 (diff) |
[PRISM] Implement CallOperatorWriteNode
Diffstat (limited to 'prism_compile.c')
-rw-r--r-- | prism_compile.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/prism_compile.c b/prism_compile.c index 59a7d10fed..0514e0c47b 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -735,7 +735,7 @@ pm_compile_call_and_or_write_node(bool and_node, pm_node_t *receiver, pm_node_t * receiver in the case of a call, the parent constant in the case of a constant * path). */ - static uint8_t +static uint8_t pm_compile_multi_write_lhs(rb_iseq_t *iseq, NODE dummy_line_node, const pm_node_t *node, LINK_ANCHOR *const ret, pm_scope_node_t *scope_node, uint8_t pushed, bool nested) { switch (PM_NODE_TYPE(node)) { @@ -1261,6 +1261,39 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, return; } + case PM_CALL_OPERATOR_WRITE_NODE: { + pm_call_operator_write_node_t *call_operator_write_node = (pm_call_operator_write_node_t*) node; + + NODE dummy_line_node = generate_dummy_line_node(lineno, lineno); + + int flag = 0; + + if (PM_NODE_TYPE_P(call_operator_write_node->receiver, PM_SELF_NODE)) { + flag = VM_CALL_FCALL; + } + + PM_COMPILE(call_operator_write_node->receiver); + + ID write_name_id = pm_constant_id_lookup(scope_node, call_operator_write_node->write_name); + ID read_name_id = pm_constant_id_lookup(scope_node, call_operator_write_node->read_name); + ID operator_id = pm_constant_id_lookup(scope_node, call_operator_write_node->operator); + ADD_INSN(ret, &dummy_line_node, dup); + + ADD_SEND_WITH_FLAG(ret, &dummy_line_node, read_name_id, INT2FIX(0), INT2FIX(flag)); + + PM_COMPILE(call_operator_write_node->value); + ADD_SEND(ret, &dummy_line_node, operator_id, INT2FIX(1)); + + if (!popped) { + PM_SWAP; + ADD_INSN1(ret, &dummy_line_node, topn, INT2FIX(1)); + } + + ADD_SEND_WITH_FLAG(ret, &dummy_line_node, write_name_id, INT2FIX(1), INT2FIX(flag)); + ADD_INSN(ret, &dummy_line_node, pop); + + return; + } case PM_CLASS_NODE: { pm_class_node_t *class_node = (pm_class_node_t *)node; pm_scope_node_t next_scope_node; |