MCPcopy Index your code
hub / github.com/RustPython/RustPython / compile

Method compile

crates/jit/tests/common.rs:16–42  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

14
15impl 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)]

Callers 4

whlimport.pyFile · 0.45
_microdistlib.pyFile · 0.45
inject_moduleMethod · 0.45
runMethod · 0.45

Calls 7

newFunction · 0.85
arg_namesMethod · 0.80
SomeClass · 0.50
compileFunction · 0.50
getMethod · 0.45
as_strMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected