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
impl Instruction
Sourcepub fn destination(&self) -> Option<AddressingMode>
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.
Sourcepub fn sources(&self) -> Vec<AddressingMode>
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.
Sourcepub const fn roll_range(
dest: RollingRecordIndex,
start: AddressingMode,
end: AddressingMode,
) -> Self
pub const fn roll_range( dest: RollingRecordIndex, start: AddressingMode, end: AddressingMode, ) -> Self
Sourcepub const fn roll_standard_dice(
dest: RollingRecordIndex,
count: AddressingMode,
faces: AddressingMode,
) -> Self
pub const fn roll_standard_dice( dest: RollingRecordIndex, count: AddressingMode, faces: AddressingMode, ) -> Self
Sourcepub const fn roll_custom_dice(
dest: RollingRecordIndex,
count: AddressingMode,
faces: Vec<i32>,
) -> Self
pub const fn roll_custom_dice( dest: RollingRecordIndex, count: AddressingMode, faces: Vec<i32>, ) -> Self
Sourcepub const fn drop_lowest(
dest: RollingRecordIndex,
count: AddressingMode,
) -> Self
pub const fn drop_lowest( dest: RollingRecordIndex, count: AddressingMode, ) -> Self
Sourcepub const fn drop_highest(
dest: RollingRecordIndex,
count: AddressingMode,
) -> Self
pub const fn drop_highest( dest: RollingRecordIndex, count: AddressingMode, ) -> Self
Sourcepub const fn sum_rolling_record(
dest: RegisterIndex,
src: RollingRecordIndex,
) -> Self
pub const fn sum_rolling_record( dest: RegisterIndex, src: RollingRecordIndex, ) -> Self
Sourcepub const fn add(
dest: RegisterIndex,
op1: AddressingMode,
op2: AddressingMode,
) -> Self
pub const fn add( dest: RegisterIndex, op1: AddressingMode, op2: AddressingMode, ) -> Self
Sourcepub const fn sub(
dest: RegisterIndex,
op1: AddressingMode,
op2: AddressingMode,
) -> Self
pub const fn sub( dest: RegisterIndex, op1: AddressingMode, op2: AddressingMode, ) -> Self
Sourcepub const fn mul(
dest: RegisterIndex,
op1: AddressingMode,
op2: AddressingMode,
) -> Self
pub const fn mul( dest: RegisterIndex, op1: AddressingMode, op2: AddressingMode, ) -> Self
Sourcepub const fn div(
dest: RegisterIndex,
op1: AddressingMode,
op2: AddressingMode,
) -> Self
pub const fn div( dest: RegisterIndex, op1: AddressingMode, op2: AddressingMode, ) -> Self
Sourcepub const fn mod(
dest: RegisterIndex,
op1: AddressingMode,
op2: AddressingMode,
) -> Self
pub const fn mod( dest: RegisterIndex, op1: AddressingMode, op2: AddressingMode, ) -> Self
Sourcepub const fn exp(
dest: RegisterIndex,
op1: AddressingMode,
op2: AddressingMode,
) -> Self
pub const fn exp( dest: RegisterIndex, op1: AddressingMode, op2: AddressingMode, ) -> Self
Sourcepub const fn neg(dest: RegisterIndex, op: AddressingMode) -> Self
pub const fn neg(dest: RegisterIndex, op: AddressingMode) -> Self
Sourcepub const fn return(src: AddressingMode) -> Self
pub const fn return(src: AddressingMode) -> Self
Trait Implementations§
Source§impl<V, E> CanVisitInstructions<V, E> for Instructionwhere
V: InstructionVisitor<E>,
impl<V, E> CanVisitInstructions<V, E> for Instructionwhere
V: InstructionVisitor<E>,
Source§impl Clone for Instruction
impl Clone for Instruction
Source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Instruction
impl Debug for Instruction
Source§impl<'de> Deserialize<'de> for Instruction
impl<'de> Deserialize<'de> for Instruction
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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
impl Display for Instruction
Source§impl From<Add> for Instruction
impl From<Add> for Instruction
Source§impl From<Div> for Instruction
impl From<Div> for Instruction
Source§impl From<DropHighest> for Instruction
impl From<DropHighest> for Instruction
Source§fn from(inst: DropHighest) -> Self
fn from(inst: DropHighest) -> Self
Converts to this type from the input type.
Source§impl From<DropLowest> for Instruction
impl From<DropLowest> for Instruction
Source§fn from(inst: DropLowest) -> Self
fn from(inst: DropLowest) -> Self
Converts to this type from the input type.
Source§impl From<Exp> for Instruction
impl From<Exp> for Instruction
Source§impl From<Mod> for Instruction
impl From<Mod> for Instruction
Source§impl From<Mul> for Instruction
impl From<Mul> for Instruction
Source§impl From<Neg> for Instruction
impl From<Neg> for Instruction
Source§impl From<Return> for Instruction
impl From<Return> for Instruction
Source§impl From<RollCustomDice> for Instruction
impl From<RollCustomDice> for Instruction
Source§fn from(inst: RollCustomDice) -> Self
fn from(inst: RollCustomDice) -> Self
Converts to this type from the input type.
Source§impl From<RollRange> for Instruction
impl From<RollRange> for Instruction
Source§impl From<RollStandardDice> for Instruction
impl From<RollStandardDice> for Instruction
Source§fn from(inst: RollStandardDice) -> Self
fn from(inst: RollStandardDice) -> Self
Converts to this type from the input type.
Source§impl From<Sub> for Instruction
impl From<Sub> for Instruction
Source§impl From<SumRollingRecord> for Instruction
impl From<SumRollingRecord> for Instruction
Source§fn from(inst: SumRollingRecord) -> Self
fn from(inst: SumRollingRecord) -> Self
Converts to this type from the input type.
Source§impl Hash for Instruction
impl Hash for Instruction
Source§impl PartialEq for Instruction
impl PartialEq for Instruction
Source§impl Serialize for Instruction
impl Serialize for Instruction
Source§impl TryFrom<Instruction> for Add
impl TryFrom<Instruction> for Add
Source§impl TryFrom<Instruction> for Div
impl TryFrom<Instruction> for Div
Source§impl TryFrom<Instruction> for DropHighest
impl TryFrom<Instruction> for DropHighest
Source§impl TryFrom<Instruction> for DropLowest
impl TryFrom<Instruction> for DropLowest
Source§impl TryFrom<Instruction> for Exp
impl TryFrom<Instruction> for Exp
Source§impl TryFrom<Instruction> for Mod
impl TryFrom<Instruction> for Mod
Source§impl TryFrom<Instruction> for Mul
impl TryFrom<Instruction> for Mul
Source§impl TryFrom<Instruction> for Neg
impl TryFrom<Instruction> for Neg
Source§impl TryFrom<Instruction> for Return
impl TryFrom<Instruction> for Return
Source§impl TryFrom<Instruction> for RollCustomDice
impl TryFrom<Instruction> for RollCustomDice
Source§impl TryFrom<Instruction> for RollRange
impl TryFrom<Instruction> for RollRange
Source§impl TryFrom<Instruction> for RollStandardDice
impl TryFrom<Instruction> for RollStandardDice
Source§impl TryFrom<Instruction> for Sub
impl TryFrom<Instruction> for Sub
Source§impl TryFrom<Instruction> for SumRollingRecord
impl TryFrom<Instruction> for SumRollingRecord
impl Eq for Instruction
impl StructuralPartialEq for Instruction
Auto Trait Implementations§
impl Freeze for Instruction
impl RefUnwindSafe for Instruction
impl Send for Instruction
impl Sync for Instruction
impl Unpin for Instruction
impl UnwindSafe for Instruction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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