/// When we call a function or await a thunk, we leave the calling
/// frame on the stack; when the result comes back, we need to store it
/// in the expected place and jump to the next basic block. Given the resulting
/// value `value`, this function examines the top stack frame, stores the
/// value where it needs to go, and adjusts the PC so that stepping can continue.
///
/// # Panics
///
/// Panics if there is no top frame or it is not awaiting the return of a call
/// or await.
When we call a function or await a thunk, we leave the calling
frame on the stack; when the result comes back, we need to store it
in the expected place and jump to the next basic block. Given the resulting
value `value`, this function examines the top stack frame, stores the
value where it needs to go, and adjusts the PC so that stepping can continue.
When we call a function or await a thunk we leave the calling frame on the stack ; when the result comes back we need to store it in the expected place and jump to the next basic block . Given the resulting value ` value ` this function examines the top stack frame stores the value where it needs to go and adjusts the PC so that stepping can continue .
fn resume_with(&mut self, value: Value) -> eyre::Result<()> {
        let Some(top) = self.machine.top_frame() else {
            unreachable!("no calling frame")
        };
        // Otherwise, this function was invoked from `top`. We have to store the return
        // value into the location where `top` expects it.
        let top_table = &top.pc.bir.data(self.db).tables;
        let top_basic_block_data = &top_table[top.pc.basic_block];
        assert_eq!(
            top.pc.statement,
            top_basic_block_data.statements.len(),
            "calling frame should be at a terminator"
        );
        let TerminatorData::Assign(top_place, _, top_basic_block) = &top_table[top_basic_block_data.terminator] else {
            unreachable!("calling frame should be at an assign terminator")
        };
        let new_pc = top.pc.move_to_block(*top_basic_block);
        self.assign_place(top_table, *top_place, value)?;
        self.machine.set_pc(new_pc);
        Ok(())
    }
fn resume_with ( & mut self , value : Value ) -> eyre :: Result < ( ) > { let Some ( top ) = self . machine . top_frame ( ) else { unreachable ! ( " " ) } ; // Otherwise, this function was invoked from `top`. We have to store the return // value into the location where `top` expects it. let top_table = & top . pc . bir . data ( self . db ) . tables ; let top_basic_block_data = & top_table [ top . pc . basic_block ] ; assert_eq ! ( top pc statement top_basic_block_data statements len ( ) " " ) ; let TerminatorData :: Assign ( top_place , _ , top_basic_block ) = & top_table [ top_basic_block_data . terminator ] else { unreachable ! ( " " ) } ; let new_pc = top . pc . move_to_block ( * top_basic_block ) ; self . assign_place ( top_table , * top_place , value ) ? ; self . machine . set_pc ( new_pc ) ; Ok ( ( ) ) }
When we call a function or await a thunk, we leave the calling
frame on the stack; when the result comes back, we need to store it
in the expected place and jump to the next basic block.
When we call a function or await a thunk we leave the calling frame on the stack ; when the result comes back we need to store it in the expected place and jump to the next basic block .
&mut self
value
Value
panics
Panics if there is no top frame or it is not awaiting the return of a call
or await.
Panics if there is no top frame or it is not awaiting the return of a call or await .