| 300 | } |
| 301 | |
| 302 | fn prepare_const<C: bytecode::Constant>( |
| 303 | &mut self, |
| 304 | constant: BorrowedConstant<'_, C>, |
| 305 | ) -> Result<JitValue, JitCompileError> { |
| 306 | let value = match constant { |
| 307 | BorrowedConstant::Integer { value } => { |
| 308 | let val = self.builder.ins().iconst( |
| 309 | types::I64, |
| 310 | value.to_i64().ok_or(JitCompileError::NotSupported)?, |
| 311 | ); |
| 312 | JitValue::Int(val) |
| 313 | } |
| 314 | BorrowedConstant::Float { value } => { |
| 315 | let val = self.builder.ins().f64const(value); |
| 316 | JitValue::Float(val) |
| 317 | } |
| 318 | BorrowedConstant::Boolean { value } => { |
| 319 | let val = self.builder.ins().iconst(types::I8, value as i64); |
| 320 | JitValue::Bool(val) |
| 321 | } |
| 322 | BorrowedConstant::None => JitValue::None, |
| 323 | _ => return Err(JitCompileError::NotSupported), |
| 324 | }; |
| 325 | Ok(value) |
| 326 | } |
| 327 | |
| 328 | fn return_value(&mut self, val: JitValue) -> Result<(), JitCompileError> { |
| 329 | if let Some(ref ty) = self.sig.ret { |