(
&mut self,
vm: &VirtualMachine,
attr: bytecode::MakeFunctionFlag,
)
| 6989 | } |
| 6990 | |
| 6991 | fn execute_set_function_attribute( |
| 6992 | &mut self, |
| 6993 | vm: &VirtualMachine, |
| 6994 | attr: bytecode::MakeFunctionFlag, |
| 6995 | ) -> FrameResult { |
| 6996 | // SET_FUNCTION_ATTRIBUTE sets attributes on a function |
| 6997 | // Stack: [..., attr_value, func] -> [..., func] |
| 6998 | // Stack order: func is at -1, attr_value is at -2 |
| 6999 | |
| 7000 | let func = self.pop_value_opt(); |
| 7001 | let attr_value = expect_unchecked(self.replace_top(func), "attr_value must not be null"); |
| 7002 | |
| 7003 | let func = self.top_value(); |
| 7004 | // Get the function reference and call the new method |
| 7005 | let func_ref = func |
| 7006 | .downcast_ref_if_exact::<PyFunction>(vm) |
| 7007 | .expect("SET_FUNCTION_ATTRIBUTE expects function on stack"); |
| 7008 | |
| 7009 | let payload: &PyFunction = func_ref.payload(); |
| 7010 | // SetFunctionAttribute always follows MakeFunction, so at this point |
| 7011 | // there are no other references to func. It is therefore safe to treat it as mutable. |
| 7012 | unsafe { |
| 7013 | let payload_ptr = payload as *const PyFunction as *mut PyFunction; |
| 7014 | (*payload_ptr).set_function_attribute(attr, attr_value, vm)?; |
| 7015 | }; |
| 7016 | |
| 7017 | Ok(None) |
| 7018 | } |
| 7019 | |
| 7020 | #[cfg_attr(feature = "flame-it", flame("Frame"))] |
| 7021 | fn execute_bin_op(&mut self, vm: &VirtualMachine, op: bytecode::BinaryOperator) -> FrameResult { |
no test coverage detected