Struct yksom::vm::somstack::SOMStack [−][src]
pub struct SOMStack { /* fields omitted */ }
A contiguous stack of SOM values. This stack does minimal or no checking on important
operations and users must ensure that they obey the constraints on each function herein, or
undefined behaviour will occur. Note also that UpVar
s store interior pointers into this
stack: it must not, therefore, ever be moved in memory.
The basic layout of the stack is as a series of function frames growing from the beginning of the stack upwards. On a 64-bit machine, a function frame looks roughly like:
0 : <arg 0>
…
The compiler and VM treat <arg 0> as special: it always contains a reference to self
(hence
all functions have 1 extra parameter over those specified by the user). Functions are expected
to be called with their arguments already in place on the stack, and the stack pointer pointing
to after the arguments but before the variables (i.e. the function will then set up its
variables however it wants). Similarly, when a function is returned, the return value is
expected to be placed where <arg 0> was originally found (i.e. at the end of the previous
function’s working stack).
Implementations
impl SOMStack
[src]
pub fn new() -> Gc<Self>
[src]
pub fn is_empty(self: Gc<Self>) -> bool
[src]
Returns true
if the stack contains no elements.
pub fn len(self: Gc<Self>) -> usize
[src]
Returns the number of elements in the stack.
pub fn remaining_capacity(self: Gc<Self>) -> usize
[src]
Returns the number of elements the stack can store before running out of room.
pub unsafe fn addr_of(self: Gc<Self>, n: usize) -> Gc<Val>
[src]
pub fn peek(self: Gc<Self>) -> Val
[src]
Returns the top-most value of the stack without removing it. If the stack is empty, calling this function will lead to undefined behaviour.
pub fn peek_at(self: Gc<Self>, off: usize) -> Val
[src]
Peeks at a value n
items from the top of the stack.
pub fn peek_n(self: Gc<Self>, n: usize) -> Val
[src]
Peeks at a value n
items from the top of the stack.
pub fn pop(self: Gc<Self>) -> Val
[src]
Pops the top-most value of the stack and returns it. If the stack is empty, calling this function will lead to undefined behaviour.
pub fn pop_n(self: Gc<Self>, n: usize) -> Val
[src]
Pops the top-most value of the stack and returns it. If the stack is empty, calling this function will lead to undefined behaviour.
pub fn push(self: Gc<Self>, v: Val)
[src]
Push v
onto the end of the stack. You must previously have checked (using
SOMStack::remaining_capacity
) that there is room for this value: if there is not,
undefined behaviour will occur.
pub fn set(self: Gc<Self>, n: usize, v: Val)
[src]
pub fn split_off(self: Gc<Self>, at: usize) -> Val
[src]
Splits the collection into two at the given index.
Returns a newly allocated NormalArray
containing the elements in the range [at, len).
After the call, the SOM stack will be left containing the elements [0, at) with its
previous capacity unchanged.
pub fn truncate(self: Gc<Self>, len: usize)
[src]
Shortens the stack, keeping the first len elements and dropping the rest.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for SOMStack
impl Send for SOMStack
impl !Sync for SOMStack
impl Unpin for SOMStack
impl UnwindSafe for SOMStack
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,