brillig::opcodes

Enum BrilligOpcode

Source
pub enum BrilligOpcode<F> {
Show 20 variants BinaryFieldOp { destination: MemoryAddress, op: BinaryFieldOp, lhs: MemoryAddress, rhs: MemoryAddress, }, BinaryIntOp { destination: MemoryAddress, op: BinaryIntOp, bit_size: IntegerBitSize, lhs: MemoryAddress, rhs: MemoryAddress, }, Not { destination: MemoryAddress, source: MemoryAddress, bit_size: IntegerBitSize, }, Cast { destination: MemoryAddress, source: MemoryAddress, bit_size: BitSize, }, JumpIfNot { condition: MemoryAddress, location: Label, }, JumpIf { condition: MemoryAddress, location: Label, }, Jump { location: Label, }, CalldataCopy { destination_address: MemoryAddress, size_address: MemoryAddress, offset_address: MemoryAddress, }, Call { location: Label, }, Const { destination: MemoryAddress, bit_size: BitSize, value: F, }, IndirectConst { destination_pointer: MemoryAddress, bit_size: BitSize, value: F, }, Return, ForeignCall { function: String, destinations: Vec<ValueOrArray>, destination_value_types: Vec<HeapValueType>, inputs: Vec<ValueOrArray>, input_value_types: Vec<HeapValueType>, }, Mov { destination: MemoryAddress, source: MemoryAddress, }, ConditionalMov { destination: MemoryAddress, source_a: MemoryAddress, source_b: MemoryAddress, condition: MemoryAddress, }, Load { destination: MemoryAddress, source_pointer: MemoryAddress, }, Store { destination_pointer: MemoryAddress, source: MemoryAddress, }, BlackBox(BlackBoxOp), Trap { revert_data: HeapVector, }, Stop { return_data: HeapVector, },
}

Variants§

§

BinaryFieldOp

Takes the fields in addresses lhs and rhs Performs the specified binary operation and stores the value in the destination address.

§

BinaryIntOp

Takes the bit_size size integers in addresses lhs and rhs Performs the specified binary operation and stores the value in the destination address.

§

Not

Fields

§destination: MemoryAddress
§

Cast

Fields

§destination: MemoryAddress
§bit_size: BitSize
§

JumpIfNot

Sets the program counter to the value of location if the value at the condition address is zero.

Fields

§condition: MemoryAddress
§location: Label
§

JumpIf

Sets the program counter to the value of location If the value at condition is non-zero

Fields

§condition: MemoryAddress
§location: Label
§

Jump

Sets the program counter to the value of location.

Fields

§location: Label
§

CalldataCopy

Copies calldata after the offset to the specified address and length

Fields

§destination_address: MemoryAddress
§size_address: MemoryAddress
§offset_address: MemoryAddress
§

Call

We don’t support dynamic jumps or calls See https://github.com/ethereum/aleth/issues/3404 for reasoning

Pushes the current program counter to the call stack as to set a return location. Sets the program counter to the value of location.

Fields

§location: Label
§

Const

Stores a constant value with a bit_size in the destination address.

Fields

§destination: MemoryAddress
§bit_size: BitSize
§value: F
§

IndirectConst

Reads the address from destination_pointer, then stores a constant value with a bit_size at that address.

Fields

§destination_pointer: MemoryAddress
§bit_size: BitSize
§value: F
§

Return

Pops the top element from the call stack, which represents the return location, and sets the program counter to that value. This operation is used to return from a function call.

§

ForeignCall

Used to get data from an outside source. Also referred to as an Oracle. However, we don’t use that name as this is intended for things like state tree reads, and shouldn’t be confused with e.g. blockchain price oracles.

Fields

§function: String

Interpreted by caller context, ie this will have different meanings depending on who the caller is.

§destinations: Vec<ValueOrArray>

Destination addresses (may be single values or memory pointers).

§destination_value_types: Vec<HeapValueType>

Destination value types

§inputs: Vec<ValueOrArray>

Input addresses (may be single values or memory pointers).

§input_value_types: Vec<HeapValueType>

Input value types (for heap allocated structures indicates how to retrieve the elements)

§

Mov

Moves the content in the source address to the destination address.

Fields

§destination: MemoryAddress
§

ConditionalMov

destination = condition > 0 ? source_a : source_b

Fields

§destination: MemoryAddress
§source_a: MemoryAddress
§source_b: MemoryAddress
§condition: MemoryAddress
§

Load

Reads the source_pointer to obtain a memory address, then retrieves the data stored at that address and writes it to the destination address.

Fields

§destination: MemoryAddress
§source_pointer: MemoryAddress
§

Store

Reads the destination_pointer to obtain a memory address, then stores the value from the source address at that location.

Fields

§destination_pointer: MemoryAddress
§

BlackBox(BlackBoxOp)

Native functions in the VM. These are equivalent to the black box functions in ACIR.

§

Trap

Used to denote execution failure, halting the VM and returning data specified by a dynamically-sized vector.

Fields

§revert_data: HeapVector
§

Stop

Halts execution and returns data specified by a dynamically-sized vector.

Fields

§return_data: HeapVector

Trait Implementations§

Source§

impl<F: Clone> Clone for BrilligOpcode<F>

Source§

fn clone(&self) -> BrilligOpcode<F>

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<F: Debug> Debug for BrilligOpcode<F>

Source§

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

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

impl<'de, F> Deserialize<'de> for BrilligOpcode<F>
where F: Deserialize<'de>,

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<F: Hash> Hash for BrilligOpcode<F>

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<F: PartialEq> PartialEq for BrilligOpcode<F>

Source§

fn eq(&self, other: &BrilligOpcode<F>) -> 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<F> Serialize for BrilligOpcode<F>
where F: Serialize,

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<F: Eq> Eq for BrilligOpcode<F>

Source§

impl<F> StructuralPartialEq for BrilligOpcode<F>

Auto Trait Implementations§

§

impl<F> Freeze for BrilligOpcode<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for BrilligOpcode<F>
where F: RefUnwindSafe,

§

impl<F> Send for BrilligOpcode<F>
where F: Send,

§

impl<F> Sync for BrilligOpcode<F>
where F: Sync,

§

impl<F> Unpin for BrilligOpcode<F>
where F: Unpin,

§

impl<F> UnwindSafe for BrilligOpcode<F>
where F: UnwindSafe,

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, dst: *mut u8)

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

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

§

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

Checks if this value is equivalent to the given key. 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> 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, 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.
§

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

§

fn vzip(self) -> V

Source§

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