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>

source

pub fn arg_names(&self) -> Arguments<'_, C::Name>

Get all arguments of the code object like inspect.getargs

source

pub fn label_targets(&self) -> BTreeSet<Label>

Return the labels targeted by the instructions of this CodeObject

source

pub fn display_expand_code_objects(&self) -> impl Display + '_

Recursively display this CodeObject

source

pub fn map_bag<Bag: ConstantBag>(self, bag: Bag) -> CodeObject<Bag::Constant>

Map this CodeObject to one that holds a Bag::Constant

source

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>
where C::Name: Clone,

source§

fn clone(&self) -> CodeObject<C>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<C: Constant> Debug for CodeObject<C>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<C: Constant> Display for CodeObject<C>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<C: Constant> InstrDisplayContext for CodeObject<C>

§

type Constant = C

source§

fn get_constant(&self, i: usize) -> &C

source§

fn get_name(&self, i: usize) -> &str

source§

fn get_varname(&self, i: usize) -> &str

source§

fn get_cell_name(&self, i: usize) -> &str

Auto Trait Implementations§

§

impl<C> Freeze for CodeObject<C>
where <C as Constant>::Name: Freeze,

§

impl<C> RefUnwindSafe for CodeObject<C>

§

impl<C> Send for CodeObject<C>
where <C as Constant>::Name: Send, C: Send,

§

impl<C> Sync for CodeObject<C>
where <C as Constant>::Name: Sync, C: Sync,

§

impl<C> Unpin for CodeObject<C>
where <C as Constant>::Name: Unpin,

§

impl<C> UnwindSafe for CodeObject<C>
where <C as Constant>::Name: UnwindSafe, C: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> ExactFrom<T> for U
where U: TryFrom<T>,

source§

fn exact_from(value: T) -> U

source§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

source§

fn exact_into(self) -> U

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

source§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

source§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

source§

impl<T> ToDebugString for T
where T: Debug,

source§

fn to_debug_string(&self) -> String

Returns the String produced by Ts Debug implementation.

§Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

source§

fn wrapping_into(self) -> U