Skip to main content

execute_instruction

Function execute_instruction 

Source
pub fn execute_instruction<M, I, V, Ty, Info, S>(
    module: &LocalModule<I, V, Ty, Info>,
    machine: &mut M,
    instruction_override: Option<&I>,
) -> Result<()>
where M: HasProgram<Program = ExecutionState<S>> + Dispatch<LocalModule<I, V, Ty, Info>, Instruction = I>,
Expand description

Fetch and dispatch one instruction with the standard PC and error semantics.

Requires a runnable invocation with an active frame. Fetch checks the PC against module.code, then advances it before calling the authored dispatch. On a dispatch error, halt, or suspension, the PC is restored to the fetched position. Other stack, frame, and device mutations are retained.

instruction_override replaces the fetched instruction for this dispatch only. The PC must still address a valid module instruction. The debugger uses this to execute a gutter breakpoint’s displaced instruction without removing the installed trap. Pass None for ordinary instruction fetching.

This helper does not acquire the execution guard itself. Custom runners should call it inside run and supply the invocation’s original module.

§Errors

Rejects a non-runnable invocation, missing frame, invalid PC, or PC overflow, and propagates dispatch errors.