| 75 | |
| 76 | impl<'a, 'b> FunctionCompiler<'a, 'b> { |
| 77 | pub fn new( |
| 78 | builder: &'a mut FunctionBuilder<'b>, |
| 79 | num_variables: usize, |
| 80 | arg_types: &[JitType], |
| 81 | ret_type: Option<JitType>, |
| 82 | entry_block: Block, |
| 83 | ) -> FunctionCompiler<'a, 'b> { |
| 84 | let mut compiler = FunctionCompiler { |
| 85 | builder, |
| 86 | stack: Vec::new(), |
| 87 | variables: vec![None; num_variables].into_boxed_slice(), |
| 88 | label_to_block: HashMap::new(), |
| 89 | sig: JitSig { |
| 90 | args: arg_types.to_vec(), |
| 91 | ret: ret_type, |
| 92 | }, |
| 93 | }; |
| 94 | let params = compiler.builder.func.dfg.block_params(entry_block).to_vec(); |
| 95 | for (i, (ty, val)) in arg_types.iter().zip(params).enumerate() { |
| 96 | compiler |
| 97 | .store_variable( |
| 98 | (i as u32).into(), |
| 99 | JitValue::from_type_and_value(ty.clone(), val), |
| 100 | ) |
| 101 | .unwrap(); |
| 102 | } |
| 103 | compiler |
| 104 | } |
| 105 | |
| 106 | fn pop_multiple(&mut self, count: usize) -> Vec<JitValue> { |
| 107 | let stack_len = self.stack.len(); |