Implement OBJSWAP instruction

This commit is contained in:
Nunuhara Cabbage
2019-12-18 17:09:18 -08:00
parent b12cce78e1
commit 9b2b8965d9
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -196,7 +196,7 @@ const struct instruction instructions[NR_OPCODES] = {
OP(FTOS, 0),
OP(S_MOD, 0),
OP(S_PLUSA2, 0),
OP(OBJSWAP, 0), // TODO
OP(OBJSWAP, 0),
OP(S_ERASE, 0), // TODO
OP(SR_REF2, 0), // TODO
OP(S_ERASE2, 0),
+9
View File
@@ -751,6 +751,15 @@ static void execute_instruction(enum opcode opcode)
heap_ref(stack_pop().i);
break;
}
case OBJSWAP: {
stack_pop(); // type
union vm_value *b = stack_pop_var();
union vm_value *a = stack_pop_var();
union vm_value tmp = *a;
*a = *b;
*b = tmp;
break;
}
//
// --- Control Flow ---
//