MCPcopy Index your code
hub / github.com/RustPython/RustPython / stack_swap

Function stack_swap

crates/vm/src/builtins/frame.rs:81–88  ·  view source on GitHub ↗
(stack: i64, n: u32)

Source from the content-addressed store, hash-verified

79 }
80
81 fn stack_swap(stack: i64, n: u32) -> i64 {
82 debug_assert!(n >= 1);
83 let to_swap = peek(stack, n);
84 let top = top_of_stack(stack);
85 let shift = BITS_PER_BLOCK * (n - 1);
86 let replaced_low = (stack & !(MASK << shift)) | (top << shift);
87 (replaced_low & !MASK) | to_swap
88 }
89
90 fn pop_to_level(mut stack: i64, level: u32) -> i64 {
91 if level == 0 {

Callers 1

mark_stacksFunction · 0.85

Calls 2

peekFunction · 0.85
top_of_stackFunction · 0.85

Tested by

no test coverage detected