Implement R_NOTE instruction

It corresponds to the !== operator.
This commit is contained in:
kichikuou
2022-12-04 17:14:19 +09:00
parent 592e7c3f9f
commit f78013b70b
2 changed files with 27 additions and 0 deletions
+8
View File
@@ -851,6 +851,14 @@ static enum opcode execute_instruction(enum opcode opcode)
stack_push(lhs_page == rhs_page && lhs_var == rhs_var ? 1 : 0);
break;
}
case R_NOTE: {
int rhs_var = stack_pop().i;
int rhs_page = stack_pop().i;
int lhs_var = stack_pop().i;
int lhs_page = stack_pop().i;
stack_push(lhs_page == rhs_page && lhs_var == rhs_var ? 0 : 1);
break;
}
case NEW: {
union vm_value v;
create_struct(stack_pop().i, &v);
+19
View File
@@ -97,6 +97,24 @@ void set_page_ref(int v)
gi <- v;
}
void test_ref_compare(void)
{
int i;
int j;
ref int rn;
ref int ri = i;
ref int rj = j;
test_bool("NULL === NULL", rn === NULL, true);
test_bool("NULL !== NULL", rn !== NULL, false);
test_bool("ri === NULL", ri === NULL, false);
test_bool("ri !== NULL", ri !== NULL, true);
test_bool("ri === ri", ri === ri, true);
test_bool("ri !== ri", ri !== ri, false);
test_bool("ri === rj", ri === rj, false);
test_bool("ri !== rj", ri !== rj, true);
}
void func_stack2(void)
{
func_stack1();
@@ -140,6 +158,7 @@ void test_lang(void)
func_stack2();
'message1';
'message2';
test_ref_compare();
}
int msg_count = 0;