pub trait BodyTransformCtx: Sized {
Show 17 methods
// Required methods
fn get_crate(&self) -> &TranslatedCrate;
fn get_options(&self) -> &TranslateOptions;
fn get_params(&self) -> &GenericParams;
fn get_locals_mut(&mut self) -> &mut Locals;
fn insert_storage_live_stmt(&mut self, local: LocalId);
fn insert_storage_dead_stmt(&mut self, local: LocalId);
fn insert_assn_stmt(&mut self, place: Place, rvalue: Rvalue);
// Provided methods
fn into_fmt(&self) -> FmtCtx<'_> { ... }
fn fresh_var(&mut self, name: Option<String>, ty: Ty) -> Place { ... }
fn rval_to_place(&mut self, rvalue: Rvalue, ty: Ty) -> Place { ... }
fn compute_subslice_end_idx(
&mut self,
len_place: &Place,
last_arg: Operand,
from_end: bool,
) -> Operand { ... }
fn is_sized_type_var(&mut self, ty: &Ty) -> bool { ... }
fn compute_place_metadata(&mut self, place: &Place) -> Operand { ... }
fn borrow(&mut self, place: Place, kind: BorrowKind) -> Rvalue { ... }
fn raw_borrow(&mut self, place: Place, kind: RefKind) -> Rvalue { ... }
fn borrow_to_new_var(
&mut self,
place: Place,
kind: BorrowKind,
name: Option<String>,
) -> Place { ... }
fn raw_borrow_to_new_var(
&mut self,
place: Place,
kind: RefKind,
name: Option<String>,
) -> Place { ... }
}Expand description
A helper trait that captures common operations in body transformation.
Required Methods§
fn get_crate(&self) -> &TranslatedCrate
fn get_options(&self) -> &TranslateOptions
fn get_params(&self) -> &GenericParams
fn get_locals_mut(&mut self) -> &mut Locals
fn insert_storage_live_stmt(&mut self, local: LocalId)
fn insert_storage_dead_stmt(&mut self, local: LocalId)
fn insert_assn_stmt(&mut self, place: Place, rvalue: Rvalue)
Provided Methods§
fn into_fmt(&self) -> FmtCtx<'_>
Sourcefn fresh_var(&mut self, name: Option<String>, ty: Ty) -> Place
fn fresh_var(&mut self, name: Option<String>, ty: Ty) -> Place
Create a local & return the place pointing to it
Sourcefn rval_to_place(&mut self, rvalue: Rvalue, ty: Ty) -> Place
fn rval_to_place(&mut self, rvalue: Rvalue, ty: Ty) -> Place
Assign an rvalue to a place, unless the rvalue is a move in which case we just use the moved place.
Sourcefn compute_subslice_end_idx(
&mut self,
len_place: &Place,
last_arg: Operand,
from_end: bool,
) -> Operand
fn compute_subslice_end_idx( &mut self, len_place: &Place, last_arg: Operand, from_end: bool, ) -> Operand
When from_end is true, we need to compute len(p) - last_arg instead of just using last_arg.
Otherwise, we simply return last_arg.
New local variables are created as needed.
The last_arg is either the offset for Index or the to for Subslice for the projections.
fn is_sized_type_var(&mut self, ty: &Ty) -> bool
Sourcefn compute_place_metadata(&mut self, place: &Place) -> Operand
fn compute_place_metadata(&mut self, place: &Place) -> Operand
Sourcefn borrow(&mut self, place: Place, kind: BorrowKind) -> Rvalue
fn borrow(&mut self, place: Place, kind: BorrowKind) -> Rvalue
Create a & borrow of the place.
Sourcefn raw_borrow(&mut self, place: Place, kind: RefKind) -> Rvalue
fn raw_borrow(&mut self, place: Place, kind: RefKind) -> Rvalue
Create a &raw borrow of the place.
Sourcefn borrow_to_new_var(
&mut self,
place: Place,
kind: BorrowKind,
name: Option<String>,
) -> Place
fn borrow_to_new_var( &mut self, place: Place, kind: BorrowKind, name: Option<String>, ) -> Place
Store a & borrow of the place into a new place.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.