Enum Instruction

Source
pub enum Instruction {
Show 14 variants RollRange(RollRange), RollStandardDice(RollStandardDice), RollCustomDice(RollCustomDice), DropLowest(DropLowest), DropHighest(DropHighest), SumRollingRecord(SumRollingRecord), Add(Add), Sub(Sub), Mul(Mul), Div(Div), Mod(Mod), Exp(Exp), Neg(Neg), Return(Return),
}
Expand description

An instruction in the intermediate representation of the dice language.

Variants§

§

RollRange(RollRange)

§

RollStandardDice(RollStandardDice)

§

RollCustomDice(RollCustomDice)

§

DropLowest(DropLowest)

§

DropHighest(DropHighest)

§

SumRollingRecord(SumRollingRecord)

§

Add(Add)

§

Sub(Sub)

§

Mul(Mul)

§

Div(Div)

§

Mod(Mod)

§

Exp(Exp)

§

Neg(Neg)

§

Return(Return)

Implementations§

Source§

impl Instruction

Source

pub fn destination(&self) -> Option<AddressingMode>

Get the destination for the instruction, if any.

§Returns

The destination, or None if the instruction has no destination.

Source

pub fn sources(&self) -> Vec<AddressingMode>

Get the sources for the instruction, if any.

§Returns

The sources, or an empty vector if the instruction has no sources.

Source

pub const fn roll_range( dest: RollingRecordIndex, start: AddressingMode, end: AddressingMode, ) -> Self

Create an instruction to roll a range of dice.

§Parameters
  • dest: The destination rolling record.
  • start: The start of the range.
  • end: The end of the range.
§Returns

The instruction.

Source

pub const fn roll_standard_dice( dest: RollingRecordIndex, count: AddressingMode, faces: AddressingMode, ) -> Self

Create an instruction to roll standard dice.

§Parameters
  • dest: The destination rolling record.
  • count: The number of dice to roll.
  • faces: The number of faces on each die.
§Returns

The instruction.

Source

pub const fn roll_custom_dice( dest: RollingRecordIndex, count: AddressingMode, faces: Vec<i32>, ) -> Self

Create an instruction to roll custom dice.

§Parameters
  • dest: The destination rolling record.
  • count: The number of dice to roll.
  • faces: The number of faces on each die.
§Returns

The instruction.

Source

pub const fn drop_lowest( dest: RollingRecordIndex, count: AddressingMode, ) -> Self

Create an instruction to drop the lowest value from a rolling record.

§Parameters
  • dest: The destination rolling record.
  • count: The number of dice to drop.
§Returns

The instruction.

Source

pub const fn drop_highest( dest: RollingRecordIndex, count: AddressingMode, ) -> Self

Create an instruction to drop the highest value from a rolling record.

§Parameters
  • dest: The destination rolling record.
  • count: The number of dice to drop.
§Returns

The instruction.

Source

pub const fn sum_rolling_record( dest: RegisterIndex, src: RollingRecordIndex, ) -> Self

Create an instruction to sum the values in a rolling record.

§Parameters
  • dest: The destination register.
  • src: The rolling record to sum.
§Returns

The instruction.

Source

pub const fn add( dest: RegisterIndex, op1: AddressingMode, op2: AddressingMode, ) -> Self

Create an instruction to add two values.

§Parameters
  • dest: The destination register.
  • op1: The first operand.
  • op2: The second operand.
§Returns

The instruction.

Source

pub const fn sub( dest: RegisterIndex, op1: AddressingMode, op2: AddressingMode, ) -> Self

Create an instruction to subtract two values.

§Parameters
  • dest: The destination register.
  • op1: The first operand.
  • op2: The second operand.
§Returns

The instruction.

Source

pub const fn mul( dest: RegisterIndex, op1: AddressingMode, op2: AddressingMode, ) -> Self

Create an instruction to multiply two values.

§Parameters
  • dest: The destination register.
  • op1: The first operand.
  • op2: The second operand.
§Returns

The instruction.

Source

pub const fn div( dest: RegisterIndex, op1: AddressingMode, op2: AddressingMode, ) -> Self

Create an instruction to divide two values.

§Parameters
  • dest: The destination register.
  • op1: The first operand.
  • op2: The second operand.
§Returns

The instruction.

Source

pub const fn mod( dest: RegisterIndex, op1: AddressingMode, op2: AddressingMode, ) -> Self

Create an instruction to compute the remainder of two values.

§Parameters
  • dest: The destination register.
  • op1: The first operand.
  • op2: The second operand.
§Returns

The instruction.

Source

pub const fn exp( dest: RegisterIndex, op1: AddressingMode, op2: AddressingMode, ) -> Self

Create an instruction to compute the exponentiation of two values.

§Parameters
  • dest: The destination register.
  • op1: The first operand.
  • op2: The second operand.
§Returns

The instruction.

Source

pub const fn neg(dest: RegisterIndex, op: AddressingMode) -> Self

Create an instruction to negate a value.

§Parameters
  • dest: The destination register.
  • op: The source operand.
§Returns

The instruction.

Source

pub const fn return(src: AddressingMode) -> Self

Create an instruction to return a value from the function.

§Parameters
  • src: The return value.
§Returns

The instruction.

Trait Implementations§

Source§

impl<V, E> CanVisitInstructions<V, E> for Instruction
where V: InstructionVisitor<E>,

Source§

fn visit(&self, visitor: &mut V) -> Result<(), E>

Apply the specified visitor to the receiver. Read more
Source§

impl Clone for Instruction

Source§

fn clone(&self) -> Instruction

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Instruction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Instruction

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Instruction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Add> for Instruction

Source§

fn from(inst: Add) -> Self

Converts to this type from the input type.
Source§

impl From<Div> for Instruction

Source§

fn from(inst: Div) -> Self

Converts to this type from the input type.
Source§

impl From<DropHighest> for Instruction

Source§

fn from(inst: DropHighest) -> Self

Converts to this type from the input type.
Source§

impl From<DropLowest> for Instruction

Source§

fn from(inst: DropLowest) -> Self

Converts to this type from the input type.
Source§

impl From<Exp> for Instruction

Source§

fn from(inst: Exp) -> Self

Converts to this type from the input type.
Source§

impl From<Mod> for Instruction

Source§

fn from(inst: Mod) -> Self

Converts to this type from the input type.
Source§

impl From<Mul> for Instruction

Source§

fn from(inst: Mul) -> Self

Converts to this type from the input type.
Source§

impl From<Neg> for Instruction

Source§

fn from(inst: Neg) -> Self

Converts to this type from the input type.
Source§

impl From<Return> for Instruction

Source§

fn from(inst: Return) -> Self

Converts to this type from the input type.
Source§

impl From<RollCustomDice> for Instruction

Source§

fn from(inst: RollCustomDice) -> Self

Converts to this type from the input type.
Source§

impl From<RollRange> for Instruction

Source§

fn from(inst: RollRange) -> Self

Converts to this type from the input type.
Source§

impl From<RollStandardDice> for Instruction

Source§

fn from(inst: RollStandardDice) -> Self

Converts to this type from the input type.
Source§

impl From<Sub> for Instruction

Source§

fn from(inst: Sub) -> Self

Converts to this type from the input type.
Source§

impl From<SumRollingRecord> for Instruction

Source§

fn from(inst: SumRollingRecord) -> Self

Converts to this type from the input type.
Source§

impl Hash for Instruction

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Instruction

Source§

fn eq(&self, other: &Instruction) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Instruction

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<Instruction> for Add

Source§

type Error = ()

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

fn try_from(inst: Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Instruction> for Div

Source§

type Error = ()

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

fn try_from(inst: Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Instruction> for DropHighest

Source§

type Error = ()

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

fn try_from(inst: Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Instruction> for DropLowest

Source§

type Error = ()

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

fn try_from(inst: Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Instruction> for Exp

Source§

type Error = ()

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

fn try_from(inst: Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Instruction> for Mod

Source§

type Error = ()

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

fn try_from(inst: Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Instruction> for Mul

Source§

type Error = ()

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

fn try_from(inst: Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Instruction> for Neg

Source§

type Error = ()

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

fn try_from(inst: Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Instruction> for Return

Source§

type Error = ()

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

fn try_from(inst: Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Instruction> for RollCustomDice

Source§

type Error = ()

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

fn try_from(inst: Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Instruction> for RollRange

Source§

type Error = ()

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

fn try_from(inst: Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Instruction> for RollStandardDice

Source§

type Error = ()

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

fn try_from(inst: Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Instruction> for Sub

Source§

type Error = ()

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

fn try_from(inst: Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Instruction> for SumRollingRecord

Source§

type Error = ()

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

fn try_from(inst: Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for Instruction

Source§

impl StructuralPartialEq for Instruction

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,