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.
Fields
destination: MemoryAddress
op: BinaryIntOp
bit_size: IntegerBitSize
lhs: MemoryAddress
rhs: MemoryAddress
Not
Cast
JumpIfNot
Sets the program counter to the value of location
if
the value at the condition
address is zero.
JumpIf
Sets the program counter to the value of location
If the value at condition
is non-zero
Jump
Sets the program counter to the value of location
.
CalldataCopy
Copies calldata after the offset to the specified address and length
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
.
Const
Stores a constant value
with a bit_size
in the destination
address.
IndirectConst
Reads the address from destination_pointer
, then stores a constant value
with a bit_size
at that address.
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.
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.
Store
Reads the destination_pointer
to obtain a memory address, then stores the value
from the source
address at that location.
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>
impl<F: Clone> Clone for BrilligOpcode<F>
Source§fn clone(&self) -> BrilligOpcode<F>
fn clone(&self) -> BrilligOpcode<F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<F: Debug> Debug for BrilligOpcode<F>
impl<F: Debug> Debug for BrilligOpcode<F>
Source§impl<'de, F> Deserialize<'de> for BrilligOpcode<F>where
F: Deserialize<'de>,
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>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<F: Hash> Hash for BrilligOpcode<F>
impl<F: Hash> Hash for BrilligOpcode<F>
Source§impl<F: PartialEq> PartialEq for BrilligOpcode<F>
impl<F: PartialEq> PartialEq for BrilligOpcode<F>
Source§impl<F> Serialize for BrilligOpcode<F>where
F: Serialize,
impl<F> Serialize for BrilligOpcode<F>where
F: Serialize,
impl<F: Eq> Eq for BrilligOpcode<F>
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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
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>
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>
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