Enum UsonicInstr

Source
#[non_exhaustive]
pub enum UsonicInstr {
Show 16 variants CkNxIRo, CkNxIAo, CkNxORo, CkNxOAo, LdW, LdIRo, LdIAo, LdORo, LdOAo, LdIW, LdIL, LdIT, RstIRo, RstIAo, RstORo, RstOAo,
}
Expand description

The instruction set uses iterator semantics and not random access semantic to correspond to the RISC type of the machine and not to add assumptions about abilities to access the operation state randomly. Operation state is always iterated, such that not a single state element can be missed (as long as the iterator runs to the end).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

CkNxIRo

Checks whether there is a next destructible memory cell in the contract state listed in the operation input and sets CO register accordingly.

§

CkNxIAo

Checks whether there is a next immutable memory cell in the contract state listed in the operation input and sets CO register accordingly.

§

CkNxORo

Checks whether there is a next destructible memory cell defined by the operation and sets CO register accordingly.

§

CkNxOAo

Checks whether there is a next immutable memory cell defined by the operation and sets CO register accordingly.

§

LdW

Load operation witness [StateValue] to EA-ED registers.

§

LdIRo

Load next [StateValue] from the current destructible memory cell input to EA-ED registers.

If the next state value is absent, sets CO to a failed state. Otherwise, resets CO.

§

LdIAo

Load next [StateValue] from the current immutable memory cell input to EA-ED registers.

If the next state value is absent, sets CO to a failed state. Otherwise, resets CO.

§

LdORo

Load next [StateValue] from the current destructible memory cell output to EA-ED registers.

If the next state value is absent, sets CO to a failed state. Otherwise, resets CO.

§

LdOAo

Load next [StateValue] from the current immutable memory cell output to EA-ED registers.

If the next state value is absent, sets CO to a failed state. Otherwise, resets CO.

§

LdIW

Load destructible input witness [StateValue] for the current input number (determined by the value in UI register) to EA-ED registers.

The operation is idempotent.

Does not update the value of UI register.

If the input matching UI index is absent, sets CO to a failed state. Otherwise, resets CO.

§

LdIL

Load a lock conditions value for the current input number (determined by the value in UI register) to EA-ED registers.

The operation is idempotent.

Does not update the value of UI register.

If the input matching UI index is absent, sets CO to a failed state. Otherwise, resets CO.

§

LdIT

Load a destructible input authorization token [AuthToken] for the current input number (determined by the value in UI register) to EA register.

The operation also sets EB to either 0 (if a custom lock script is not present) or 1, if it is present.

The operation is idempotent.

Does not update the value of UI register.

If the input matching UI index is absent, sets CO to a failed state. Otherwise, resets CO.

§

RstIRo

Resets iterator over the input destructible memory cells by setting the corresponding UI value to zero.

Does not affect the value of CO or CK registers.

§

RstIAo

Resets iterator over the input immutable memory cells by setting the corresponding UI value to zero.

Does not affect the value of CO or CK registers.

§

RstORo

Resets iterator over the output destructible memory cells by setting the corresponding UI value to zero.

Does not affect the value of CO or CK registers.

§

RstOAo

Resets iterator over the output immutable memory cells by setting the corresponding UI value to zero.

Does not affect the value of CO or CK registers.

Trait Implementations§

Source§

impl<Id> Bytecode<Id> for UsonicInstr
where Id: SiteId,

Source§

fn op_range() -> RangeInclusive<u8>

Returns the range of instruction bytecodes covered by a set of operations.
Source§

fn opcode_byte(&self) -> u8

Returns byte representing instruction code (without its arguments).
Source§

fn code_byte_len(&self) -> u16

Returns the number of bytes used by the instruction and its arguments when serialized into the code segment.
Source§

fn external_ref(&self) -> Option<Id>

If the instruction calls or references any external program, returns a reference to it.
Source§

fn encode_operands<W>( &self, _writer: &mut W, ) -> Result<(), <W as BytecodeWrite<Id>>::Error>
where W: BytecodeWrite<Id>,

Writes an instruction operands as bytecode, omitting opcode byte.
Source§

fn decode_operands<R>( _reader: &mut R, opcode: u8, ) -> Result<UsonicInstr, CodeEofError>

Reads an instruction operands from bytecode, provided the opcode byte.
Source§

fn encode_instr<W>( &self, writer: &mut W, ) -> Result<(), <W as BytecodeWrite<Id>>::Error>
where W: BytecodeWrite<Id>,

Write an instruction as bytecode.
Source§

fn decode_instr<R>(reader: &mut R) -> Result<Self, CodeEofError>
where Self: Sized, R: BytecodeRead<Id>,

Reads an instruction from bytecode.
Source§

impl Clone for UsonicInstr

Source§

fn clone(&self) -> UsonicInstr

Returns a duplicate 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 UsonicInstr

Source§

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

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

impl Display for UsonicInstr

Source§

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

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

impl<Id> From<UsonicInstr> for Instr<Id>
where Id: SiteId,

Source§

fn from(v: UsonicInstr) -> Instr<Id>

Converts to this type from the input type.
Source§

impl Hash for UsonicInstr

Source§

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

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<Id> Instruction<Id> for UsonicInstr
where Id: SiteId,

Source§

const ISA_EXT: &'static [&'static str]

The names of the ISA extension set these instructions cover.
Source§

type Core = UsonicCore

Extensions to the AluVM core unit provided by this instruction set.
Source§

type Context<'ctx> = VmContext<'ctx>

Context: external data which are accessible to the ISA.
Source§

fn is_goto_target(&self) -> bool

Whether the instruction can be used as a goto-target.
Source§

fn local_goto_pos(&mut self) -> GotoTarget<'_>

If an instruction is a jump operation inside the library, it should return its goto target position number.
Source§

fn remote_goto_pos(&mut self) -> Option<&mut Site<Id>>

If an instruction is a jump operation into an external library, it should return its remote target.
Source§

fn src_regs(&self) -> BTreeSet<RegE>

List of registers which value is taken into account by the instruction.
Source§

fn dst_regs(&self) -> BTreeSet<RegE>

List of registers which value may be changed by the instruction.
Source§

fn op_data_bytes(&self) -> u16

The size of the data coming as an instruction operand (i.e., except data coming from registers or read from outside the instruction operands).
Source§

fn ext_data_bytes(&self) -> u16

The size of the data read by the instruction from outside the registers (except data coming as a parameter).
Source§

fn exec( &self, _site: Site<Id>, core: &mut Core<Id, <UsonicInstr as Instruction<Id>>::Core>, context: &<UsonicInstr as Instruction<Id>>::Context<'_>, ) -> ExecStep<Site<Id>>

Executes the given instruction taking all registers as input and output. Read more
Source§

fn isa_ext() -> Confined<BTreeSet<IsaId>, amplify::::collection::confinement::TinyOrdSet::{constant#0}, amplify::::collection::confinement::TinyOrdSet::{constant#1}>

Convert the set of ISA extensions from Self::ISA_EXT into a set of IsaId.
Source§

fn regs(&self) -> BTreeSet<<Self::Core as CoreExt>::Reg>

Lists all registers which are used by the instruction.
Source§

fn src_reg_bytes(&self) -> u16

The number of bytes in the source registers.
Source§

fn dst_reg_bytes(&self) -> u16

The number of bytes in the destination registers.
Source§

fn base_complexity(&self) -> u64

Computes base (non-adjusted) complexity of the instruction. Read more
Source§

fn complexity(&self) -> u64

Returns computational complexity of the instruction. Read more
Source§

impl PartialEq for UsonicInstr

Source§

fn eq(&self, other: &UsonicInstr) -> 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 Copy for UsonicInstr

Source§

impl Eq for UsonicInstr

Source§

impl StructuralPartialEq for UsonicInstr

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Same for T

Source§

type Output = T

Should always be Self
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<T> VerifyEq for T
where T: Eq,

Source§

fn verify_eq(&self, other: &T) -> bool

Verifies commit-equivalence of two instances of the same type.