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

Method return_value

crates/jit/src/instructions.rs:328–351  ·  view source on GitHub ↗
(&mut self, val: JitValue)

Source from the content-addressed store, hash-verified

326 }
327
328 fn return_value(&mut self, val: JitValue) -> Result<(), JitCompileError> {
329 if let Some(ref ty) = self.sig.ret {
330 // If the signature has a return type, enforce it
331 if val.to_jit_type().as_ref() != Some(ty) {
332 return Err(JitCompileError::NotSupported);
333 }
334 } else {
335 // First time we see a return, define it in the signature
336 let ty = val.to_jit_type().ok_or(JitCompileError::NotSupported)?;
337 self.sig.ret = Some(ty.clone());
338 self.builder
339 .func
340 .signature
341 .returns
342 .push(AbiParam::new(ty.to_cranelift()));
343 }
344
345 // If this is e.g. an Int, Float, or Bool we have a Cranelift `Value`.
346 // If we have JitValue::None or .Tuple(...) but can't handle that, error out (or handle differently).
347 let cr_val = val.into_value().ok_or(JitCompileError::NotSupported)?;
348
349 self.builder.ins().return_(&[cr_val]);
350 Ok(())
351 }
352
353 pub fn add_instruction<C: bytecode::Constant>(
354 &mut self,

Callers 1

add_instructionMethod · 0.80

Calls 10

newFunction · 0.85
to_jit_typeMethod · 0.80
to_craneliftMethod · 0.80
into_valueMethod · 0.80
insMethod · 0.80
SomeClass · 0.50
ErrClass · 0.50
as_refMethod · 0.45
cloneMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected