(self)
| 14 | |
| 15 | impl Function { |
| 16 | pub fn compile(self) -> CompiledCode { |
| 17 | let mut arg_types = Vec::new(); |
| 18 | for arg in self.code.arg_names().args { |
| 19 | let arg_type = match self.annotations.get(AsRef::<Wtf8>::as_ref(arg.as_str())) { |
| 20 | Some(StackValue::String(annotation)) => match annotation.as_str() { |
| 21 | "int" => JitType::Int, |
| 22 | "float" => JitType::Float, |
| 23 | "bool" => JitType::Bool, |
| 24 | _ => panic!("Unrecognised jit type"), |
| 25 | }, |
| 26 | _ => panic!("Argument have annotation"), |
| 27 | }; |
| 28 | arg_types.push(arg_type); |
| 29 | } |
| 30 | |
| 31 | let ret_type = match self.annotations.get(AsRef::<Wtf8>::as_ref("return")) { |
| 32 | Some(StackValue::String(annotation)) => match annotation.as_str() { |
| 33 | "int" => Some(JitType::Int), |
| 34 | "float" => Some(JitType::Float), |
| 35 | "bool" => Some(JitType::Bool), |
| 36 | _ => panic!("Unrecognised jit type"), |
| 37 | }, |
| 38 | _ => None, |
| 39 | }; |
| 40 | |
| 41 | rustpython_jit::compile(&self.code, &arg_types, ret_type).expect("Compile failure") |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | #[allow(dead_code)] |
no test coverage detected