summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Valentine-House <matt@eightbitraptor.com>2023-09-19 14:46:30 +0100
committerMatt Valentine-House <matt@eightbitraptor.com>2023-09-19 19:52:32 +0100
commit7dee7e611661c335321c2bb8e6b4738ab9f7c2fd (patch)
tree20a3c0139ce18b37a535d6ce22c7a401f62aa165
parent901d0b41254cfc41b337d755e9512ff78f51cbe2 (diff)
[YARP] Implement GlobalVariableTargetNode
-rw-r--r--test/yarp/compiler_test.rb4
-rw-r--r--yarp/yarp_compiler.c7
2 files changed, 11 insertions, 0 deletions
diff --git a/test/yarp/compiler_test.rb b/test/yarp/compiler_test.rb
index fdcc85eedd..07e2473283 100644
--- a/test/yarp/compiler_test.rb
+++ b/test/yarp/compiler_test.rb
@@ -137,6 +137,10 @@ module YARP
# test_yarp_eval("YARP::YCT = 1")
end
+ def test_GlobalVariableTargetNode
+ test_yarp_eval("$yct, $yct1 = 1")
+ end
+
def test_GlobalVariableWriteNode
test_yarp_eval("$yct = 1")
end
diff --git a/yarp/yarp_compiler.c b/yarp/yarp_compiler.c
index 07707abf3a..fbd9ccbb17 100644
--- a/yarp/yarp_compiler.c
+++ b/yarp/yarp_compiler.c
@@ -1213,6 +1213,13 @@ yp_compile_node(rb_iseq_t *iseq, const yp_node_t *node, LINK_ANCHOR *const ret,
}
return;
}
+ case YP_GLOBAL_VARIABLE_TARGET_NODE: {
+ yp_global_variable_target_node_t *write_node = (yp_global_variable_target_node_t *) node;
+
+ ID ivar_name = yp_constant_id_lookup(compile_context, write_node->name);
+ ADD_INSN1(ret, &dummy_line_node, setglobal, ID2SYM(ivar_name));
+ return;
+ }
case YP_GLOBAL_VARIABLE_WRITE_NODE: {
yp_global_variable_write_node_t *write_node = (yp_global_variable_write_node_t *) node;
YP_COMPILE_NOT_POPPED(write_node->value);