pub struct MirBuilder { /* private fields */ }Expand description
Builder for constructing a MIR function from AST.
Implementations§
Source§impl MirBuilder
impl MirBuilder
pub fn new(name: String, span: Span) -> Self
Sourcepub fn alloc_local(&mut self, name: String, type_info: LocalTypeInfo) -> SlotId
pub fn alloc_local(&mut self, name: String, type_info: LocalTypeInfo) -> SlotId
Allocate a new local variable slot.
Sourcepub fn add_param(&mut self, name: String, type_info: LocalTypeInfo) -> SlotId
pub fn add_param(&mut self, name: String, type_info: LocalTypeInfo) -> SlotId
Register a parameter slot.
Sourcepub fn next_point(&mut self) -> Point
pub fn next_point(&mut self) -> Point
Allocate a new program point.
Sourcepub fn new_block(&mut self) -> BasicBlockId
pub fn new_block(&mut self) -> BasicBlockId
Create a new basic block and return its ID.
Sourcepub fn push_stmt(&mut self, kind: StatementKind, span: Span)
pub fn push_stmt(&mut self, kind: StatementKind, span: Span)
Push a statement into the current block.
Sourcepub fn finish_block(&mut self, terminator_kind: TerminatorKind, span: Span)
pub fn finish_block(&mut self, terminator_kind: TerminatorKind, span: Span)
Finish the current block with a terminator and switch to a new block.
Sourcepub fn start_block(&mut self, id: BasicBlockId)
pub fn start_block(&mut self, id: BasicBlockId)
Start building a new block (after finishing the previous one).
Sourcepub fn build(self) -> MirFunction
pub fn build(self) -> MirFunction
Finalize and produce the MIR function.
Auto Trait Implementations§
impl Freeze for MirBuilder
impl RefUnwindSafe for MirBuilder
impl Send for MirBuilder
impl Sync for MirBuilder
impl Unpin for MirBuilder
impl UnsafeUnpin for MirBuilder
impl UnwindSafe for MirBuilder
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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