pub struct BodyCursor<'a> { /* private fields */ }
Implementations§
Source§impl<'a> BodyCursor<'a>
impl<'a> BodyCursor<'a>
pub fn new(body: &'a mut FunctionBody, loc: CursorLocation) -> Self
pub fn new_at_entry(body: &'a mut FunctionBody) -> Self
pub fn set_loc(&mut self, loc: CursorLocation)
pub fn loc(&self) -> CursorLocation
pub fn next_loc(&self) -> CursorLocation
pub fn prev_loc(&self) -> CursorLocation
pub fn next_block(&self) -> Option<BasicBlockId>
pub fn prev_block(&self) -> Option<BasicBlockId>
pub fn proceed(&mut self)
pub fn back(&mut self)
pub fn body(&self) -> &FunctionBody
pub fn body_mut(&mut self) -> &mut FunctionBody
Sourcepub fn set_to_entry(&mut self)
pub fn set_to_entry(&mut self)
Sets a cursor to an entry block.
Sourcepub fn insert_inst(&mut self, inst: InstId)
pub fn insert_inst(&mut self, inst: InstId)
Insert InstId
to a location where a cursor points.
If you need to store and insert Inst
, use [store_and_insert_inst
].
§Panics
Panics if a cursor points CursorLocation::NoWhere
.
pub fn store_and_insert_inst(&mut self, data: Inst) -> InstId
Sourcepub fn remove_inst(&mut self)
pub fn remove_inst(&mut self)
Remove a current pointed Inst
from a function body. A cursor
proceeds to a next inst.
§Panics
Panics if a cursor doesn’t point CursorLocation::Inst
.
Sourcepub fn remove_block(&mut self)
pub fn remove_block(&mut self)
Remove a current pointed block
and contained insts from a function
body. A cursor proceeds to a next block.
§Panics
Panics if a cursor doesn’t point CursorLocation::Inst
.
Sourcepub fn insert_block(&mut self, block: BasicBlockId)
pub fn insert_block(&mut self, block: BasicBlockId)
Insert BasicBlockId
to a location where a cursor points.
If you need to store and insert BasicBlock
, use
[store_and_insert_block
].
§Panics
Panics if a cursor points CursorLocation::NoWhere
.
pub fn store_and_insert_block(&mut self, block: BasicBlock) -> BasicBlockId
pub fn map_result(&mut self, result: AssignableValue) -> Option<ValueId>
Sourcepub fn expect_inst(&self) -> InstId
pub fn expect_inst(&self) -> InstId
Returns current inst that cursor points.
§Panics
Panics if a cursor doesn’t point CursorLocation::Inst
.
Sourcepub fn expect_block(&self) -> BasicBlockId
pub fn expect_block(&self) -> BasicBlockId
Returns current block that cursor points.
§Panics
Panics if a cursor points CursorLocation::NoWhere
.