Struct yksom::vm::function::Function [−][src]
pub struct Function { /* fields omitted */ }
The VM’s underlying notion of a SOM function. SOM has two types of functions: methods and
blocks. Roughly speaking, methods have names, may reference primitives, but can’t be nested;
blocks are anonymous, can’t reference primitives, but can be nested. Although at a SOM level
methods and blocks are separate types, they share nearly everything that makes them
function-esque, so to avoid having two separate internal representations, both methods and
blocks store Function
s.
The main complication in representation is that a Function
can reference a SOM primitive,
which is a very different type of Function
to a non-primitive. Rather than have two types of
Function
, we store both together: the Function::is_primitive() can be used to differentiate
the two.
Implementations
impl Function
[src]
pub fn new_bytecode(
vm: &VM,
num_params: usize,
num_vars: usize,
bytecode_off: usize,
bytecode_end: Option<usize>,
max_stack: usize,
upvar_defs: Vec<UpVarDef>,
block_funcs: Vec<Gc<Function>>
) -> Function
[src]
vm: &VM,
num_params: usize,
num_vars: usize,
bytecode_off: usize,
bytecode_end: Option<usize>,
max_stack: usize,
upvar_defs: Vec<UpVarDef>,
block_funcs: Vec<Gc<Function>>
) -> Function
pub fn new_primitive(
vm: &VM,
num_params: usize,
primitive: Primitive
) -> Function
[src]
vm: &VM,
num_params: usize,
primitive: Primitive
) -> Function
pub fn is_primitive(&self) -> bool
[src]
Is this Function
a SOM primitive?
pub fn primitive(&self) -> Primitive
[src]
If this Function
is a SOM primitive, return the Primitive
. Calling this function
without first having confirmed that this Function
is a SOM primitive is undefined
behaviour.
pub fn num_params(&self) -> usize
[src]
pub fn holder(&self) -> Val
[src]
pub fn set_holder(&self, vm: &VM, class: Val)
[src]
Set this function, and recursively all its nested functions, holder.
pub fn containing_method(&self) -> Gc<Method>
[src]
pub fn set_containing_method(&self, meth: Gc<Method>)
[src]
pub fn num_vars(&self) -> usize
[src]
If this Function
is not a SOM primitive, return its number of local variables. Calling
this function without first having confirmed that this Function
is not a SOM primitive is
undefined behaviour.
pub fn bytecode_off(&self) -> usize
[src]
If this Function
is not a SOM primitive, return the start of its bytecode. Calling this
function without first having confirmed that this Function
is not a SOM primitive is
undefined behaviour.
pub fn bytecode_end(&self) -> usize
[src]
If this Function
is not a SOM primitive, and if this Function
represents a block,
return the end of its bytecode. Calling this function without first having confirmed that
this Function
is not a SOM primitive and that it is a block is undefined behaviour.
pub fn max_stack(&self) -> usize
[src]
If this Function
is not a SOM primitive, return the maximum number of SOM stack entries
it requires. Calling this function without first having confirmed that this Function
is
not a SOM primitive is undefined behaviour.
pub fn block_func(&self, idx: usize) -> Gc<Function>
[src]
pub fn upvar_defs(&self) -> &Vec<UpVarDef>
[src]
pub fn block_funcs(&self) -> &Vec<Gc<Function>>
[src]
Trait Implementations
Auto Trait Implementations
impl !NoTrace for Function
impl !RefUnwindSafe for Function
impl Send for Function
impl !Sync for Function
impl Unpin for Function
impl !UnwindSafe for Function
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>,