Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions test/yarp/compiler_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ def test_GlobalVariableOperatorWriteNode
test_yarp_eval("$yct = 0; $yct += 1")
end

def test_InstanceVariableTargetNode
test_yarp_eval("class YARP::CompilerTest; @yct, @yct1 = 1; end")
end

def test_InstanceVariableWriteNode
test_yarp_eval("class YARP::CompilerTest; @yct = 1; end")
end
Expand All @@ -151,6 +155,10 @@ def test_InstanceVariableOperatorWriteNode
test_yarp_eval("@yct = 0; @yct += 1")
end

def test_LocalVariableTargetNode
test_yarp_eval("yct, yct1 = 1")
end

def test_LocalVariableWriteNode
test_yarp_eval("yct = 1")
end
Expand Down
18 changes: 18 additions & 0 deletions yarp/yarp_compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,15 @@ yp_compile_node(rb_iseq_t *iseq, const yp_node_t *node, LINK_ANCHOR *const ret,
}
return;
}
case YP_INSTANCE_VARIABLE_TARGET_NODE: {
yp_instance_variable_target_node_t *write_node = (yp_instance_variable_target_node_t *) node;

ID ivar_name = yp_constant_id_lookup(compile_context, write_node->name);
ADD_INSN2(ret, &dummy_line_node, setinstancevariable,
ID2SYM(ivar_name),
get_ivar_ic_value(iseq, ivar_name));
return;
}
case YP_INSTANCE_VARIABLE_WRITE_NODE: {
yp_instance_variable_write_node_t *write_node = (yp_instance_variable_write_node_t *) node;
YP_COMPILE_NOT_POPPED(write_node->value);
Expand Down Expand Up @@ -1559,6 +1568,15 @@ yp_compile_node(rb_iseq_t *iseq, const yp_node_t *node, LINK_ANCHOR *const ret,
}
return;
}
case YP_LOCAL_VARIABLE_TARGET_NODE: {
yp_local_variable_target_node_t *local_write_node = (yp_local_variable_target_node_t *) node;

yp_constant_id_t constant_id = local_write_node->name;
int index = yp_lookup_local_index(iseq, compile_context, constant_id);

ADD_SETLOCAL(ret, &dummy_line_node, (int)index, local_write_node->depth);
return;
}
case YP_LOCAL_VARIABLE_WRITE_NODE: {
yp_local_variable_write_node_t *local_write_node = (yp_local_variable_write_node_t *) node;
YP_COMPILE_NOT_POPPED(local_write_node->value);
Expand Down