Skip to main content

Function

Struct Function 

Source
pub struct Function {
    pub blocks: Vec<FunctionBlock>,
    pub values: Vec<FunctionValue>,
    pub current_block: u32,
}
Expand description

A function for generating Vermilion IR.

Fields§

§blocks: Vec<FunctionBlock>

A list of blocks in the function.

§values: Vec<FunctionValue>

A list of values used by the function.

§current_block: u32

A pointer to the current block.

Implementations§

Source§

impl Function

The functionality behind the Function struct.

Source

pub fn new() -> Self

Creates a new empty function.

Source

pub fn create_block(&mut self) -> Block

Creates a new code block. To use this code block, you must first switch to it.

Source

pub fn switch_to_block(&mut self, block: Block)

Switches the current block to the selected block.

Source

pub fn iconst_boolean(&mut self, val: bool) -> Value

Creates a new SSA boolean. Uses the Boolean instruction behind the scenes.

Source

pub fn iconst_integer(&mut self, val: i64) -> Value

Creates a new SSA integer. Uses the Byte instruction behind the scenes.

Source

pub fn iconst_float(&mut self, val: f64) -> Value

Creates a new SSA float. Uses the Float instruction behind the scenes.

Source

pub fn ipop(&mut self) -> Value

Yields the topmost stack item and removes it from the stack.

Source

pub fn pop(&mut self)

Removes the topmost stack item.

Source

pub fn iclone(&mut self) -> Value

Clones the current topmost stack item and yields it.

Source

pub fn clone(&mut self)

Clones the topmost stack item and pushes it to the stack.

Source

pub fn clear(&mut self)

Clears the stack, so it has no items.

Source

pub fn iboolean_add(&mut self, l: Value, r: Value) -> Value

Adds two booleans together and yields the sum.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn boolean_add(&mut self, l: Value, r: Value)

Adds two booleans together and pushes the sum to the stack.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn iboolean_sub(&mut self, l: Value, r: Value) -> Value

Subtracts two booleans together and yields the sum.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn boolean_sub(&mut self, l: Value, r: Value)

Subtracts two booleans together and pushes the sum to the stack.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn ibyte_add(&mut self, l: Value, r: Value) -> Value

Adds two bytes together and yields the sum.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn byte_add(&mut self, l: Value, r: Value)

Adds two bytes together and pushes the sum to the stack.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn ibyte_sub(&mut self, l: Value, r: Value) -> Value

Subtracts two bytes together and yields the sum.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn byte_sub(&mut self, l: Value, r: Value)

Subtracts two bytes together and pushes the sum to the stack.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn ibyte_mul(&mut self, l: Value, r: Value) -> Value

Multiplies two bytes together and yields the sum.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn byte_mul(&mut self, l: Value, r: Value)

Multiplies two bytes together and pushes the sum to the stack.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn ibyte_div(&mut self, l: Value, r: Value) -> Value

Divides two bytes together and yields the sum.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn byte_div(&mut self, l: Value, r: Value)

Divides two bytes together and pushes the sum to the stack.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn ibyte_mod(&mut self, l: Value, r: Value) -> Value

Divides two bytes together and yields the remainder.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn integer_mod(&mut self, l: Value, r: Value)

Divides two integers together and pushes the remainder to the stack.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn iint_add(&mut self, l: Value, r: Value) -> Value

Adds two integers together and yields the sum.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn int_add(&mut self, l: Value, r: Value)

Adds two integers together and pushes the sum to the stack.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn iint_sub(&mut self, l: Value, r: Value) -> Value

Subtracts two integers together and yields the sum.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn int_sub(&mut self, l: Value, r: Value)

Subtracts two integers together and pushes the sum to the stack.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn iint_mul(&mut self, l: Value, r: Value) -> Value

Multiplies two integers together and yields the sum.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn int_mul(&mut self, l: Value, r: Value)

Multiplies two integers together and pushes the sum to the stack.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn iint_div(&mut self, l: Value, r: Value) -> Value

Divides two integers together and yields the sum.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn int_div(&mut self, l: Value, r: Value)

Divides two integers together and pushes the sum to the stack.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn iint_mod(&mut self, l: Value, r: Value) -> Value

Divides two integers together and yields the remainder.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn int_mod(&mut self, l: Value, r: Value)

Divides two integers together and pushes the remainder to the stack.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn ifloat_add(&mut self, l: Value, r: Value) -> Value

Adds two floats together and yields the sum.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn float_add(&mut self, l: Value, r: Value)

Adds two floats together and pushes the sum to the stack.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn ifloat_sub(&mut self, l: Value, r: Value) -> Value

Subtracts two integers together and yields the sum.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn float_sub(&mut self, l: Value, r: Value)

Subtracts two floats together and pushes the sum to the stack.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn ifloat_mul(&mut self, l: Value, r: Value) -> Value

Multiplies two floats together and yields the sum.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn float_mul(&mut self, l: Value, r: Value)

Multiplies two floats together and pushes the sum to the stack.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn ifloat_div(&mut self, l: Value, r: Value) -> Value

Divides two floats together and yields the sum.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn float_div(&mut self, l: Value, r: Value)

Divides two floats together and pushes the sum to the stack.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn ifloat_mod(&mut self, l: Value, r: Value) -> Value

Divides two floats together and yields the remainder.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn float_mod(&mut self, l: Value, r: Value)

Divides two floats together and pushes the remainder to the stack.

§Arguments
  • l: The left side of the operation.
  • r: The right side of the operation.
Source

pub fn icast_boolean(&mut self, l: Value) -> Value

Converts a value into a boolean and yields it.

§Arguments
  • l: The value to convert.
Source

pub fn cast_boolean(&mut self, l: Value)

Converts a value into a boolean and pushes it to the stack.

§Arguments
  • l: The value to convert.
Source

pub fn icast_byte(&mut self, l: Value) -> Value

Converts a value into a byte and yields it.

§Arguments
  • l: The value to convert.
Source

pub fn cast_byte(&mut self, l: Value)

Converts a value into a byte and pushes it to the stack.

§Arguments
  • l: The value to convert.
Source

pub fn icast_int(&mut self, l: Value) -> Value

Converts a value into an integer and yields it.

§Arguments
  • l: The value to convert.
Source

pub fn cast_int(&mut self, l: Value)

Converts a value into an integer and pushes it to the stack.

§Arguments
  • l: The value to convert.
Source

pub fn icast_float(&mut self, l: Value) -> Value

Converts a value into an float and yields it.

§Arguments
  • l: The value to convert.
Source

pub fn cast_float(&mut self, l: Value)

Converts a value into an float and pushes it to the stack.

§Arguments
  • l: The value to convert.
Source

pub fn ineg_boolean(&mut self, l: Value) -> Value

Negates a boolean and yields it.

§Arguments
  • l: The value to convert.
Source

pub fn neg_boolean(&mut self, l: Value)

Negates a boolean and pushes it to the stack.

§Arguments
  • l: The value to convert.
Source

pub fn ineg_int(&mut self, l: Value) -> Value

Negates an integer and yields it.

§Arguments
  • l: The value to convert.
Source

pub fn neg_byte(&mut self, l: Value)

Negates an integer and pushes it to the stack.

§Arguments
  • l: The value to convert.
Source

pub fn ineg_float(&mut self, l: Value) -> Value

Negates a float and yields it.

§Arguments
  • l: The value to convert.
Source

pub fn neg_float(&mut self, l: Value)

Negates a float and pushes it to the stack.

§Arguments
  • l: The value to convert.
Source

pub fn iload(&mut self, l: Value, offset: i64) -> Value

Loads a byte from memory and yields it. For efficiency, if the offset is 0, the offset calculation is not compiled

§Arguments
  • l: The address to load.
  • offset: The offset to load it from.
Source

pub fn load(&mut self, l: Value, offset: i64)

Loads a byte from memory and pushes it to the stack. For efficiency, if the offset is 0, the offset calculation is not compiled.

§Arguments
  • l: The address to load.
  • offset: The offset to load it from.
Source

pub fn store(&mut self, l: Value, r: Value, offset: i64)

Stores a byte in memory. For efficiency, if the offset is 0, the offset calculation is not compiled.

§Arguments
  • l: The address to write to.
  • r: The byte to write.
  • offset: The offset to load it from.
Source

pub fn realloc(&mut self, l: Value)

Reallocates the heap to the specified size.

§Arguments
  • l: The new size.
Source

pub fn iheap_size(&mut self) -> Value

Yields the amount of allocated heap memory as an integer.

Source

pub fn heap_size(&mut self)

Pushes the amount of allocated heap memory to the stack.

Source

pub fn alloc(&mut self, l: Value)

Allocates a section of memory with the specified ID.

§Arguments
  • l: The ID of the new section. (int)
Source

pub fn realloc_section(&mut self, l: Value, r: Value)

Reallocates a section of memory with the specified ID.

§Arguments
  • l: The ID of the new section. (int)
  • r: The new size of the section. (int)
Source

pub fn isection_addr(&mut self, l: Value) -> Value

Yields the start address of the specified section.

§Arguments
  • l: The section ID to get (int)
Source

pub fn section_addr(&mut self, l: Value)

Pushes the start address of a section to the stack.

§Arguments
  • l: The section ID to get (int)
Source

pub fn section_shift_left(&mut self, l: Value, r: Value)

Shifts a section to the left.

§Arguments
  • l: The section ID to shift. (int)
  • r: The amount of bytes to shift the section by (int)
Source

pub fn section_shift_right(&mut self, l: Value, r: Value)

Shifts a section to the right.

§Arguments
  • l: The section ID to shift. (int)
  • r: The amount of bytes to shift the section by (int)
Source

pub fn free(&mut self, l: Value)

Frees a section and fills it with bytes.

§Arguments
  • l: The section ID to free. (int)
Source

pub fn free_and_shift(&mut self, l: Value)

Frees a section and fills it with bytes, then shifts all of the following sections to fill the free space.

§Arguments
  • l: The section ID to free. (int)
Source

pub fn branch(&mut self, l: Block)

Branches to the specified block.

§Arguments
  • l: The block to branch to.
Source

pub fn brz(&mut self, l: Value)

Branches if the specified boolean is zero.

§Arguments
  • l: The boolean to test
Source

pub fn brnz(&mut self, l: Value)

Branches if the specified boolean is not zero.

§Arguments
  • l: The boolean to test
Source

pub fn iequal(&mut self, l: Value, r: Value) -> Value

Tests if the two operands are exactly equal.

§Arguments
  • l: Left side of the operation.
  • r: Right side of the operation.
Source

pub fn equal(&mut self, l: Value, r: Value)

Branches if the specified boolean is not zero. Pushes the result to the stack.

§Arguments
  • l: Left side of the operation.
  • r: Right side of the operation.
Source

pub fn igreater(&mut self, l: Value, r: Value) -> Value

Tests if the first operand is greater than the second.

§Arguments
  • l: Left side of the operation.
  • r: Right side of the operation.
Source

pub fn greater(&mut self, l: Value, r: Value)

Tests if the first operand is greater than the second. Pushes the result to the stack.

§Arguments
  • l: Left side of the operation.
  • r: Right side of the operation.
Source

pub fn iless(&mut self, l: Value, r: Value) -> Value

Tests if the first operand is greater than the second.

§Arguments
  • l: Left side of the operation.
  • r: Right side of the operation.
Source

pub fn less(&mut self, l: Value, r: Value)

Tests if the first operand is greater than the second. Pushes the result to the stack.

§Arguments
  • l: Left side of the operation.
  • r: Right side of the operation.
Source

pub fn igreater_or_equal(&mut self, l: Value, r: Value) -> Value

Tests if the first operand is greater or equal to the second.

§Arguments
  • l: Left side of the operation.
  • r: Right side of the operation.
Source

pub fn greater_or_eqal(&mut self, l: Value, r: Value)

Tests if the first operand is greater or equal to the second. Pushes the result to the stack.

§Arguments
  • l: Left side of the operation.
  • r: Right side of the operation.
Source

pub fn iless_or_equal(&mut self, l: Value, r: Value) -> Value

Tests if the first operand is less or equal to the second.

§Arguments
  • l: Left side of the operation.
  • r: Right side of the operation.
Source

pub fn less_or_equal(&mut self, l: Value, r: Value)

Tests if the first operand is less or equal to the second. Pushes the result to the stack.

§Arguments
  • l: Left side of the operation.
  • r: Right side of the operation.
Source

pub fn call(&mut self, name: String, args: &[Value])

Calls a function.

§Arguments
  • name: Name of the function to call.
  • args: The arguments of the function call.
Source

pub fn return_(&mut self, args: &[Value])

Returns from a function call.

§Arguments
  • args: The arguments to return.

Trait Implementations§

Source§

impl Clone for Function

Source§

fn clone(&self) -> Function

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.