Remove unnecessary Option

This commit is contained in:
Brian Carroll 2021-09-18 14:46:09 +01:00
parent c3b5ac6c82
commit 65446ce1e8
3 changed files with 36 additions and 43 deletions

View file

@ -119,20 +119,23 @@ impl<'a> WasmBackend<'a> {
fn finalize(&mut self, return_type: Option<ValueType>) -> FunctionDefinition {
let mut final_instructions = Vec::with_capacity(self.instructions.len() + 10);
allocate_stack_frame(
&mut final_instructions,
self.stack_memory,
self.stack_frame_pointer,
);
if self.stack_memory > 0 {
allocate_stack_frame(
&mut final_instructions,
self.stack_memory,
self.stack_frame_pointer.unwrap(),
);
}
final_instructions.extend(self.instructions.drain(0..));
free_stack_frame(
&mut final_instructions,
self.stack_memory,
self.stack_frame_pointer,
);
if self.stack_memory > 0 {
free_stack_frame(
&mut final_instructions,
self.stack_memory,
self.stack_frame_pointer.unwrap(),
);
}
final_instructions.push(Instruction::End);
let signature_builder = if let Some(t) = return_type {