Module control_flow

Source
Expand description

§Control Flow Handler

Handles all control flow operations in the VM including jumps, function calls, returns, and exception handling.

§Operations Supported

  • Jumps: jump, jump_if_true, jump_if_false
  • Function Calls: call, return_from_function
  • Scope Management: create_scope, exit_scope
  • Exception Handling: throw, try_catch, finally
  • Loop Control: break_statement, continue_statement
  • Switch Statements: switch_statement, case_statement, default_case

§Control Flow Semantics

  • Jumps: Modify the program counter to change execution flow
  • Function Calls: Set up new execution context with arguments
  • Returns: Restore previous execution context
  • Exception Handling: Manage try-catch-finally blocks

§Usage

use jetcrab::vm::executor::instruction_handlers::ControlFlowHandler;
use jetcrab::vm::executor::traits::{StackOperations, VariableManager};

let mut stack = MyStack::new();
let mut registers = MyRegisters::new();
let mut frame = MyFrame::new();

ControlFlowHandler::jump(&mut stack, &mut registers, 100)?;

Structs§

ControlFlowHandler
Handles control flow operations for the VM