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

Function get_jit_value

crates/vm/src/builtins/function/jit.rs:130–147  ·  view source on GitHub ↗
(vm: &VirtualMachine, obj: &PyObject)

Source from the content-addressed store, hash-verified

128}
129
130fn get_jit_value(vm: &VirtualMachine, obj: &PyObject) -> Result<AbiValue, ArgsError> {
131 // This does exact type checks as subclasses of int/float can't be passed to jitted functions
132 let cls = obj.class();
133 if cls.is(vm.ctx.types.int_type) {
134 int::get_value(obj)
135 .to_i64()
136 .map(AbiValue::Int)
137 .ok_or(ArgsError::IntOverflow)
138 } else if cls.is(vm.ctx.types.float_type) {
139 Ok(AbiValue::Float(
140 obj.downcast_ref::<float::PyFloat>().unwrap().to_f64(),
141 ))
142 } else if cls.is(vm.ctx.types.bool_type) {
143 Ok(AbiValue::Bool(bool_::get_value(obj)))
144 } else {
145 Err(ArgsError::NonJitType)
146 }
147}
148
149/// Like `fill_locals_from_args` but to populate arguments for calling a jit function.
150/// This also doesn't do full error handling but instead return None if anything is wrong. In

Callers 1

get_jit_argsFunction · 0.85

Calls 9

BoolClass · 0.85
isMethod · 0.80
to_f64Method · 0.80
get_valueFunction · 0.50
FloatClass · 0.50
ErrClass · 0.50
classMethod · 0.45
mapMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected