pub struct Frame { /* private fields */ }Expand description
Python-visible frame object. Currently always wraps an InterpreterFrame.
Analogous to CPython’s PyFrameObject.
Implementations§
Source§impl Frame
impl Frame
Sourcepub unsafe fn fastlocals(&self) -> &[Option<PyObjectRef>]
pub unsafe fn fastlocals(&self) -> &[Option<PyObjectRef>]
Access fastlocals immutably.
§Safety
Caller must ensure no concurrent mutable access (frame not executing, or called from the same thread during trace callback).
Sourcepub unsafe fn fastlocals_mut(&self) -> &mut [Option<PyObjectRef>]
pub unsafe fn fastlocals_mut(&self) -> &mut [Option<PyObjectRef>]
Sourcepub fn set_generator(&self, generator: &PyObject)
pub fn set_generator(&self, generator: &PyObject)
Store a borrowed back-reference to the owning generator/coroutine. The caller must ensure the generator outlives the frame.
Sourcepub fn clear_generator(&self)
pub fn clear_generator(&self)
Clear the generator back-reference. Called when the generator is finalized.
pub fn current_location(&self) -> SourceLocation
Sourcepub fn previous_frame(&self) -> *const Frame
pub fn previous_frame(&self) -> *const Frame
Get the previous frame pointer for signal-safe traceback walking.
pub fn lasti(&self) -> u32
pub fn set_lasti(&self, val: u32)
Sourcepub fn locals_to_fast(&self, vm: &VirtualMachine) -> PyResult<()>
pub fn locals_to_fast(&self, vm: &VirtualMachine) -> PyResult<()>
Sync locals dict back to fastlocals. Called before generator/coroutine resume to apply any modifications made via f_locals.
pub fn locals(&self, vm: &VirtualMachine) -> PyResult<ArgMapping>
Trait Implementations§
Source§impl Deref for Frame
impl Deref for Frame
Source§fn deref(&self) -> &InterpreterFrame
fn deref(&self) -> &InterpreterFrame
Transparent access to InterpreterFrame fields.
§Safety argument
Immutable fields (code, globals, builtins, func_obj, locals) are safe
to access at any time. Atomic/mutex fields (lasti, trace, owner, etc.)
provide their own synchronization. Mutable fields (localsplus, prev_line)
are only mutated during single-threaded execution via with_exec.
Source§type Target = InterpreterFrame
type Target = InterpreterFrame
Source§impl MaybeTraverse for Frame
impl MaybeTraverse for Frame
Source§const HAS_TRAVERSE: bool = true
const HAS_TRAVERSE: bool = true
Source§const HAS_CLEAR: bool = true
const HAS_CLEAR: bool = true
fn try_traverse(&self, tracer_fn: &mut TraverseFn<'_>)
fn try_clear(&mut self, out: &mut Vec<PyObjectRef>)
Source§impl PyClassDef for Frame
impl PyClassDef for Frame
const NAME: &'static str = "frame"
const MODULE_NAME: Option<&'static str> = None
const TP_NAME: &'static str = "frame"
const DOC: Option<&'static str>
const BASICSIZE: usize
const UNHASHABLE: bool = false
type Base = PyBaseObject
const ITEMSIZE: usize = 0
Source§impl PyClassImpl for Frame
impl PyClassImpl for Frame
const TP_FLAGS: PyTypeFlags
const METHOD_DEFS: &'static [PyMethodDef]
fn impl_extend_class(ctx: &'static Context, class: &'static Py<PyType>)
fn extend_slots(slots: &mut PyTypeSlots)
fn extend_class(ctx: &'static Context, class: &'static Py<PyType>)where
Self: Sized,
fn make_static_type() -> PyTypeRefwhere
Self: StaticType + Sized,
fn make_slots() -> PyTypeSlots
Source§impl PyPayload for Frame
impl PyPayload for Frame
fn class(ctx: &Context) -> &'static Py<PyType>
const PAYLOAD_TYPE_ID: TypeId = _
fn try_downcast_from(obj: &PyObject, vm: &VirtualMachine) -> PyResult<()>
Source§const HAS_FREELIST: bool = false
const HAS_FREELIST: bool = false
Source§const MAX_FREELIST: usize = 0
const MAX_FREELIST: usize = 0
Source§unsafe fn freelist_push(_obj: *mut PyObject) -> bool
unsafe fn freelist_push(_obj: *mut PyObject) -> bool
Source§unsafe fn freelist_pop(_payload: &Self) -> Option<NonNull<PyObject>>
unsafe fn freelist_pop(_payload: &Self) -> Option<NonNull<PyObject>>
ref_count, gc_bits, and payload. Read morefn into_pyobject(self, vm: &VirtualMachine) -> PyObjectRefwhere
Self: Debug,
fn _into_ref(self, cls: PyTypeRef, ctx: &Context) -> PyRef<Self>where
Self: Debug,
fn into_exact_ref(self, ctx: &Context) -> PyRefExact<Self>where
Self: Debug,
fn into_ref(self, ctx: &Context) -> PyRef<Self>where
Self: Debug,
fn into_ref_with_type(
self,
vm: &VirtualMachine,
cls: PyTypeRef,
) -> PyResult<PyRef<Self>>where
Self: Debug,
Source§impl Representable for Frame
impl Representable for Frame
fn repr(_zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyStrRef>
fn repr_str(_zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<String>
fn slot_repr(zelf: &PyObject, vm: &VirtualMachine) -> PyResult<PyRef<PyStr>>
fn repr_wtf8(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<Wtf8Buf>
const __OWN_METHOD_DEFS: &'static [PyMethodDef] = _
fn __extend_py_class(ctx: &'static Context, class: &'static Py<PyType>)
fn __extend_slots(slots: &mut PyTypeSlots)
Source§impl StaticType for Frame
impl StaticType for Frame
fn static_cell() -> &'static StaticCell<PyTypeRef>
fn static_metaclass() -> &'static Py<PyType>
fn static_baseclass() -> &'static Py<PyType>
fn static_type() -> &'static Py<PyType>
fn init_manually(typ: PyTypeRef) -> &'static Py<PyType>
fn init_builtin_type() -> &'static Py<PyType>where
Self: PyClassImpl,
fn create_static_type() -> PyTypeRefwhere
Self: PyClassImpl,
Source§impl Traverse for Frame
impl Traverse for Frame
Source§fn traverse(&self, tracer_fn: &mut TraverseFn<'_>)
fn traverse(&self, tracer_fn: &mut TraverseFn<'_>)
traverse() with caution! Following those guideline so traverse doesn’t cause memory error!: Read moreSource§fn clear(&mut self, _out: &mut Vec<PyObjectRef>)
fn clear(&mut self, _out: &mut Vec<PyObjectRef>)
Auto Trait Implementations§
impl !Freeze for Frame
impl !RefUnwindSafe for Frame
impl !Send for Frame
impl !Sync for Frame
impl Unpin for Frame
impl UnsafeUnpin for Frame
impl !UnwindSafe for Frame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more