MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / pop_stack_n

Method pop_stack_n

aiscript-vm/src/vm/state.rs:1761–1780  ·  view source on GitHub ↗
(&mut self, n: usize)

Source from the content-addressed store, hash-verified

1759 }
1760
1761 fn pop_stack_n(&mut self, n: usize) -> Vec<Value<'gc>> {
1762 if n == 0 {
1763 return Vec::new();
1764 }
1765
1766 // Ensure we don't pop more items than are on the stack
1767 let n = n.min(self.stack_top);
1768
1769 let new_top = self.stack_top - n;
1770 let mut result = Vec::with_capacity(n);
1771
1772 // Copy values from the stack to the result vector
1773 result.extend_from_slice(&self.stack[new_top..self.stack_top]);
1774
1775 // Update the stack top
1776 self.stack_top = new_top;
1777
1778 // No need to reverse as we're copying from bottom to top
1779 result
1780 }
1781
1782 #[cfg(feature = "debug")]
1783 pub fn print_stack(&self) {

Callers 2

dispatch_nextMethod · 0.80
call_valueMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected