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: u32A pointer to the current block.
Implementations§
Source§impl Function
The functionality behind the Function struct.
impl Function
The functionality behind the Function struct.
Sourcepub fn create_block(&mut self) -> Block
pub fn create_block(&mut self) -> Block
Creates a new code block. To use this code block, you must first switch to it.
Sourcepub fn switch_to_block(&mut self, block: Block)
pub fn switch_to_block(&mut self, block: Block)
Switches the current block to the selected block.
Sourcepub fn iconst_boolean(&mut self, val: bool) -> Value
pub fn iconst_boolean(&mut self, val: bool) -> Value
Creates a new SSA boolean. Uses the Boolean instruction
behind the scenes.
Sourcepub fn iconst_integer(&mut self, val: i64) -> Value
pub fn iconst_integer(&mut self, val: i64) -> Value
Creates a new SSA integer. Uses the Byte instruction
behind the scenes.
Sourcepub fn iconst_float(&mut self, val: f64) -> Value
pub fn iconst_float(&mut self, val: f64) -> Value
Creates a new SSA float. Uses the Float instruction
behind the scenes.
Sourcepub fn iboolean_add(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn boolean_add(&mut self, l: Value, r: Value)
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.
Sourcepub fn iboolean_sub(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn boolean_sub(&mut self, l: Value, r: Value)
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.
Sourcepub fn ibyte_add(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn byte_add(&mut self, l: Value, r: Value)
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.
Sourcepub fn ibyte_sub(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn byte_sub(&mut self, l: Value, r: Value)
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.
Sourcepub fn ibyte_mul(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn byte_mul(&mut self, l: Value, r: Value)
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.
Sourcepub fn ibyte_div(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn byte_div(&mut self, l: Value, r: Value)
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.
Sourcepub fn ibyte_mod(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn integer_mod(&mut self, l: Value, r: Value)
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.
Sourcepub fn iint_add(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn int_add(&mut self, l: Value, r: Value)
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.
Sourcepub fn iint_sub(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn int_sub(&mut self, l: Value, r: Value)
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.
Sourcepub fn iint_mul(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn int_mul(&mut self, l: Value, r: Value)
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.
Sourcepub fn iint_div(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn int_div(&mut self, l: Value, r: Value)
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.
Sourcepub fn iint_mod(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn int_mod(&mut self, l: Value, r: Value)
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.
Sourcepub fn ifloat_add(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn float_add(&mut self, l: Value, r: Value)
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.
Sourcepub fn ifloat_sub(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn float_sub(&mut self, l: Value, r: Value)
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.
Sourcepub fn ifloat_mul(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn float_mul(&mut self, l: Value, r: Value)
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.
Sourcepub fn ifloat_div(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn float_div(&mut self, l: Value, r: Value)
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.
Sourcepub fn ifloat_mod(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn float_mod(&mut self, l: Value, r: Value)
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.
Sourcepub fn icast_boolean(&mut self, l: Value) -> Value
pub fn icast_boolean(&mut self, l: Value) -> Value
Sourcepub fn cast_boolean(&mut self, l: Value)
pub fn cast_boolean(&mut self, l: Value)
Sourcepub fn icast_byte(&mut self, l: Value) -> Value
pub fn icast_byte(&mut self, l: Value) -> Value
Sourcepub fn icast_float(&mut self, l: Value) -> Value
pub fn icast_float(&mut self, l: Value) -> Value
Sourcepub fn cast_float(&mut self, l: Value)
pub fn cast_float(&mut self, l: Value)
Sourcepub fn ineg_boolean(&mut self, l: Value) -> Value
pub fn ineg_boolean(&mut self, l: Value) -> Value
Sourcepub fn neg_boolean(&mut self, l: Value)
pub fn neg_boolean(&mut self, l: Value)
Sourcepub fn ineg_float(&mut self, l: Value) -> Value
pub fn ineg_float(&mut self, l: Value) -> Value
Sourcepub fn iload(&mut self, l: Value, offset: i64) -> Value
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.
Sourcepub fn load(&mut self, l: Value, offset: i64)
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.
Sourcepub fn store(&mut self, l: Value, r: Value, offset: i64)
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.
Sourcepub fn iheap_size(&mut self) -> Value
pub fn iheap_size(&mut self) -> Value
Yields the amount of allocated heap memory as an integer.
Sourcepub fn realloc_section(&mut self, l: Value, r: Value)
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)
Sourcepub fn isection_addr(&mut self, l: Value) -> Value
pub fn isection_addr(&mut self, l: Value) -> Value
Sourcepub fn section_addr(&mut self, l: Value)
pub fn section_addr(&mut self, l: Value)
Sourcepub fn section_shift_left(&mut self, l: Value, r: Value)
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)
Sourcepub fn section_shift_right(&mut self, l: Value, r: Value)
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)
Sourcepub fn free_and_shift(&mut self, l: Value)
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)
Sourcepub fn iequal(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn equal(&mut self, l: Value, r: Value)
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.
Sourcepub fn igreater(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn greater(&mut self, l: Value, r: Value)
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.
Sourcepub fn iless(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn less(&mut self, l: Value, r: Value)
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.
Sourcepub fn igreater_or_equal(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn greater_or_eqal(&mut self, l: Value, r: Value)
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.
Sourcepub fn iless_or_equal(&mut self, l: Value, r: Value) -> Value
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.
Sourcepub fn less_or_equal(&mut self, l: Value, r: Value)
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.