Fix bugs in Ret statement

This commit is contained in:
Brian Carroll 2021-11-12 13:23:09 +00:00
parent daf6771bf5
commit 33109006c2

View file

@ -294,9 +294,10 @@ impl<'a> WasmBackend<'a> {
_ => {
self.storage.load_symbols(&mut self.code_builder, &[*sym]);
self.code_builder.br(self.block_depth); // jump to end of function (for stack frame pop)
}
}
// jump to the "stack frame pop" code at the end of the function
self.code_builder.br(self.block_depth - 1);
Ok(())
}
@ -321,7 +322,7 @@ impl<'a> WasmBackend<'a> {
cond_storage,
);
// create (number_of_branches - 1) new blocks.
// create a block for each branch except the default
for _ in 0..branches.len() {
self.start_block(BlockType::NoResult)
}