wasm_interp: implement select instruction

This commit is contained in:
Brian Carroll 2022-11-27 09:23:28 +00:00
parent 9e7a92574d
commit ae2e561945
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0
2 changed files with 63 additions and 3 deletions

View file

@ -418,7 +418,14 @@ impl<'a> ExecutionState<'a> {
DROP => {
self.value_stack.pop();
}
SELECT => todo!("{:?} @ {:#x}", op_code, file_offset),
SELECT => {
let c = self.value_stack.pop_i32();
let val2 = self.value_stack.pop();
let val1 = self.value_stack.pop();
assert_eq!(ValueType::from(val1), ValueType::from(val2));
let result = if c != 0 { val1 } else { val2 };
self.value_stack.push(result);
}
GETLOCAL => {
let index = self.fetch_immediate_u32(module);
let value = self.call_stack.get_local(index);