Struct rustpython_compiler::CodeObject
source · pub struct CodeObject<C = ConstantData>where
C: Constant,{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 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]>>,
pub constants: Box<[C]>,
pub names: Box<[<C as Constant>::Name]>,
pub varnames: Box<[<C as Constant>::Name]>,
pub cellvars: Box<[<C as Constant>::Name]>,
pub freevars: Box<[<C as Constant>::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 as Constant>::Name
§first_line_number: Option<OneIndexed>
§max_stackdepth: u32
§obj_name: <C as Constant>::Name
§cell2arg: Option<Box<[i32]>>
§constants: Box<[C]>
§names: Box<[<C as Constant>::Name]>
§varnames: Box<[<C as Constant>::Name]>
§cellvars: Box<[<C as Constant>::Name]>
§freevars: Box<[<C as Constant>::Name]>
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>
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>(
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>
impl<C> 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> 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,
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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>
Converts
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>
Converts
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