pub struct Body {
pub blocks: Vec<BasicBlock>,
pub(super) locals: Vec<LocalDecl>,
pub(super) arg_count: usize,
pub var_debug_info: Vec<VarDebugInfo>,
pub(super) spread_arg: Option<Local>,
pub span: Span,
}
Expand description
The SMIR representation of a single function.
Fields§
§blocks: Vec<BasicBlock>
§locals: Vec<LocalDecl>
Declarations of locals within the function.
The first local is the return value pointer, followed by arg_count
locals for the function arguments, followed by any user-declared
variables and temporaries.
arg_count: usize
The number of arguments this function takes.
var_debug_info: Vec<VarDebugInfo>
Debug information pertaining to user variables, including captures.
spread_arg: Option<Local>
Mark an argument (which must be a tuple) as getting passed as its individual components.
This is used for the “rust-call” ABI such as closures.
span: Span
The span that covers the entire function body.
Implementations§
Source§impl Body
impl Body
Sourcepub fn new(
blocks: Vec<BasicBlock>,
locals: Vec<LocalDecl>,
arg_count: usize,
var_debug_info: Vec<VarDebugInfo>,
spread_arg: Option<Local>,
span: Span,
) -> Self
pub fn new( blocks: Vec<BasicBlock>, locals: Vec<LocalDecl>, arg_count: usize, var_debug_info: Vec<VarDebugInfo>, spread_arg: Option<Local>, span: Span, ) -> Self
Constructs a Body
.
A constructor is required to build a Body
from outside the crate
because the arg_count
and locals
fields are private.
Sourcepub fn arg_locals(&self) -> &[LocalDecl]
pub fn arg_locals(&self) -> &[LocalDecl]
Locals in self
that correspond to this function’s arguments.
Sourcepub fn inner_locals(&self) -> &[LocalDecl]
pub fn inner_locals(&self) -> &[LocalDecl]
Inner locals for this function. These are the locals that are neither the return local nor the argument locals.
Sourcepub fn locals(&self) -> &[LocalDecl]
pub fn locals(&self) -> &[LocalDecl]
Convenience function to get all the locals in this function.
Locals are typically accessed via the more specific methods ret_local
,
arg_locals
, and inner_locals
.
Sourcepub fn local_decl(&self, local: Local) -> Option<&LocalDecl>
pub fn local_decl(&self, local: Local) -> Option<&LocalDecl>
Get the local declaration for this local.
Sourcepub fn local_decls(&self) -> impl Iterator<Item = (Local, &LocalDecl)>
pub fn local_decls(&self) -> impl Iterator<Item = (Local, &LocalDecl)>
Get an iterator for all local declarations.
Sourcepub fn dump<W: Write>(&self, w: &mut W, fn_name: &str) -> Result<()>
pub fn dump<W: Write>(&self, w: &mut W, fn_name: &str) -> Result<()>
Emit the body using the provided name for the signature.
pub fn spread_arg(&self) -> Option<Local>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Body
impl RefUnwindSafe for Body
impl Send for Body
impl Sync for Body
impl Unpin for Body
impl UnwindSafe for Body
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 104 bytes