Struct rustpython_compiler_core::bytecode::CodeObject
source · pub struct CodeObject<C: Constant = ConstantData> {Show 16 fields
pub instructions: Box<[CodeUnit]>,
pub locations: Box<[SourceLocation]>,
pub flags: CodeFlags,
pub posonlyarg_count: u32,
pub arg_count: u32,
pub kwonlyarg_count: u32,
pub source_path: C::Name,
pub first_line_number: Option<OneIndexed>,
pub max_stackdepth: u32,
pub obj_name: C::Name,
pub cell2arg: Option<Box<[i32]>>,
pub constants: Box<[C]>,
pub names: Box<[C::Name]>,
pub varnames: Box<[C::Name]>,
pub cellvars: Box<[C::Name]>,
pub freevars: Box<[C::Name]>,
}
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]>
§locations: Box<[SourceLocation]>
§flags: CodeFlags
§posonlyarg_count: u32
§arg_count: u32
§kwonlyarg_count: u32
§source_path: C::Name
§first_line_number: Option<OneIndexed>
§max_stackdepth: u32
§obj_name: C::Name
§cell2arg: Option<Box<[i32]>>
§constants: Box<[C]>
§names: Box<[C::Name]>
§varnames: Box<[C::Name]>
§cellvars: Box<[C::Name]>
§freevars: Box<[C::Name]>
Implementations§
source§impl<C: Constant> CodeObject<C>
impl<C: Constant> CodeObject<C>
sourcepub fn arg_names(&self) -> Arguments<'_, C::Name>
pub fn arg_names(&self) -> Arguments<'_, C::Name>
Get all arguments of the code object like inspect.getargs
sourcepub fn label_targets(&self) -> BTreeSet<Label>
pub fn label_targets(&self) -> BTreeSet<Label>
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: ConstantBag>(self, bag: Bag) -> CodeObject<Bag::Constant>
pub fn map_bag<Bag: ConstantBag>(self, bag: Bag) -> CodeObject<Bag::Constant>
Map this CodeObject to one that holds a Bag::Constant
sourcepub fn map_clone_bag<Bag: ConstantBag>(
&self,
bag: &Bag
) -> CodeObject<Bag::Constant>
pub fn map_clone_bag<Bag: ConstantBag>( &self, bag: &Bag ) -> CodeObject<Bag::Constant>
Same as map_bag
but clones self
Trait Implementations§
source§impl<C: Clone + Constant> Clone for CodeObject<C>
impl<C: Clone + Constant> Clone for CodeObject<C>
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: Constant> Debug for CodeObject<C>
impl<C: Constant> Debug for CodeObject<C>
source§impl<C: Constant> Display for CodeObject<C>
impl<C: Constant> Display for CodeObject<C>
Auto Trait Implementations§
impl<C> Freeze for CodeObject<C>
impl<C> RefUnwindSafe for CodeObject<C>
impl<C> Send for CodeObject<C>
impl<C> Sync for CodeObject<C>
impl<C> Unpin for CodeObject<C>
impl<C> UnwindSafe for CodeObject<C>
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