#[unsafe(no_mangle)]pub unsafe extern "C" fn patch_seq_peek_int_value(stack: Stack) -> i64Expand description
Helper for peeking at the top integer value without popping
Returns the integer value on top of the stack without modifying the stack. Used in conjunction with pop_stack for conditional branching.
Why separate peek and pop? In LLVM IR for conditionals, we need to:
- Extract the integer value to test it (peek_int_value)
- Branch based on that value (icmp + br)
- Free the stack node in both branches (pop_stack)
A combined pop_int_value would leak memory since we’d need the value before branching but couldn’t return the updated stack pointer through both branches. Separating these operations prevents memory leaks.
Stack effect: ( n – n ) returns n
§Safety
Stack must have an Int value on top