seq_runtime/arithmetic/
peek.rs1use crate::stack::{Stack, peek, pop};
6use crate::value::Value;
7
8#[unsafe(no_mangle)]
11pub unsafe extern "C" fn patch_seq_peek_int_value(stack: Stack) -> i64 {
12 assert!(!stack.is_null(), "peek_int_value: stack is empty");
13
14 let val = unsafe { peek(stack) };
16 match val {
17 Value::Int(i) => i,
18 other => panic!("peek_int_value: expected Int on stack, got {:?}", other),
19 }
20}
21
22#[unsafe(no_mangle)]
27pub unsafe extern "C" fn patch_seq_peek_bool_value(stack: Stack) -> bool {
28 assert!(!stack.is_null(), "peek_bool_value: stack is empty");
29
30 let val = unsafe { peek(stack) };
31 match val {
32 Value::Bool(b) => b,
33 other => panic!("peek_bool_value: expected Bool on stack, got {:?}", other),
34 }
35}
36
37#[unsafe(no_mangle)]
47pub unsafe extern "C" fn patch_seq_pop_stack(stack: Stack) -> Stack {
48 assert!(!stack.is_null(), "pop_stack: stack is empty");
49 let (rest, _value) = unsafe { pop(stack) };
50 rest
51}