Struct rustpython_vm::compiler::core::bytecode::CodeObject
source · pub struct CodeObject<C = ConstantData>where
C: Constant,{Show 16 fields
pub instructions: Box<[CodeUnit], Global>,
pub locations: Box<[SourceLocation], Global>,
pub flags: CodeFlags,
pub posonlyarg_count: u32,
pub arg_count: u32,
pub kwonlyarg_count: u32,
pub source_path: <C as Constant>::Name,
pub first_line_number: Option<OneIndexed>,
pub max_stackdepth: u32,
pub obj_name: <C as Constant>::Name,
pub cell2arg: Option<Box<[i32], Global>>,
pub constants: Box<[C], Global>,
pub names: Box<[<C as Constant>::Name], Global>,
pub varnames: Box<[<C as Constant>::Name], Global>,
pub cellvars: Box<[<C as Constant>::Name], Global>,
pub freevars: Box<[<C as Constant>::Name], Global>,
}
Expand description
Primary container of a single code object. Each python function has a code object. Also a module has a code object.
Fields§
§instructions: Box<[CodeUnit], Global>
§locations: Box<[SourceLocation], Global>
§flags: CodeFlags
§posonlyarg_count: u32
§arg_count: u32
§kwonlyarg_count: u32
§source_path: <C as Constant>::Name
§first_line_number: Option<OneIndexed>
§max_stackdepth: u32
§obj_name: <C as Constant>::Name
§cell2arg: Option<Box<[i32], Global>>
§constants: Box<[C], Global>
§names: Box<[<C as Constant>::Name], Global>
§varnames: Box<[<C as Constant>::Name], Global>
§cellvars: Box<[<C as Constant>::Name], Global>
§freevars: Box<[<C as Constant>::Name], Global>
Implementations§
source§impl<C> CodeObject<C>where
C: Constant,
impl<C> CodeObject<C>where C: Constant,
sourcepub fn arg_names(&self) -> Arguments<'_, <C as Constant>::Name>
pub fn arg_names(&self) -> Arguments<'_, <C as Constant>::Name>
Get all arguments of the code object like inspect.getargs
sourcepub fn label_targets(&self) -> BTreeSet<Label, Global>
pub fn label_targets(&self) -> BTreeSet<Label, Global>
Return the labels targeted by the instructions of this CodeObject
sourcepub fn display_expand_code_objects(&self) -> impl Display
pub fn display_expand_code_objects(&self) -> impl Display
Recursively display this CodeObject
sourcepub fn map_bag<Bag>(
self,
bag: Bag
) -> CodeObject<<Bag as ConstantBag>::Constant>where
Bag: ConstantBag,
pub fn map_bag<Bag>( self, bag: Bag ) -> CodeObject<<Bag as ConstantBag>::Constant>where Bag: ConstantBag,
Map this CodeObject to one that holds a Bag::Constant
sourcepub fn map_clone_bag<Bag>(
&self,
bag: &Bag
) -> CodeObject<<Bag as ConstantBag>::Constant>where
Bag: ConstantBag,
pub fn map_clone_bag<Bag>( &self, bag: &Bag ) -> CodeObject<<Bag as ConstantBag>::Constant>where Bag: ConstantBag,
Same as map_bag
but clones self
Trait Implementations§
source§impl<C> Clone for CodeObject<C>where
C: Clone + Constant,
<C as Constant>::Name: Clone,
impl<C> Clone for CodeObject<C>where C: Clone + Constant, <C as Constant>::Name: Clone,
source§fn clone(&self) -> CodeObject<C>
fn clone(&self) -> CodeObject<C>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<C> Debug for CodeObject<C>where
C: Constant,
impl<C> Debug for CodeObject<C>where C: Constant,
source§impl<C> Display for CodeObject<C>where
C: Constant,
impl<C> Display for CodeObject<C>where C: Constant,
source§impl<C> InstrDisplayContext for CodeObject<C>where
C: Constant,
impl<C> InstrDisplayContext for CodeObject<C>where C: Constant,
source§impl ToPyObject for CodeObject
impl ToPyObject for CodeObject
fn to_pyobject(self, vm: &VirtualMachine) -> PyObjectRef
source§impl ToPyObject for CodeObject<Literal>
impl ToPyObject for CodeObject<Literal>
fn to_pyobject(self, vm: &VirtualMachine) -> PyObjectRef
Auto Trait Implementations§
impl<C> RefUnwindSafe for CodeObject<C>where C: RefUnwindSafe, <C as Constant>::Name: RefUnwindSafe,
impl<C> Send for CodeObject<C>where C: Send, <C as Constant>::Name: Send,
impl<C> Sync for CodeObject<C>where C: Sync, <C as Constant>::Name: Sync,
impl<C> Unpin for CodeObject<C>where <C as Constant>::Name: Unpin,
impl<C> UnwindSafe for CodeObject<C>where C: UnwindSafe, <C as Constant>::Name: UnwindSafe,
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
Mutably borrows from an owned value. Read more