pub struct Assembler {
buffer: Buffer,
gas: u128,
pub mp: usize,
pub sp: u16,
}
Expand description
Low level assembler implementation for EVM.
Fields§
§buffer: Buffer
Buffer of the assembler.
gas: u128
Gas counter.
This is used to calculate the gas cost of the generated code.
TODO: use a more precise type, eq u256
. (issue-20)
mp: usize
Memory pointer for byte offset.
sp: u16
Stack pointer, maximum MAX_STACK_SIZE
items.
Implementations§
Source§impl Assembler
impl Assembler
Sourcepub fn buffer_mut(&mut self) -> &mut Buffer
pub fn buffer_mut(&mut self) -> &mut Buffer
Mutable buffer of the assembler.
Sourcepub fn increment_gas(&mut self, gas: u128)
pub fn increment_gas(&mut self, gas: u128)
Increment the gas counter.
TODO: use number bigger than u256
for throwing proper errors. (#21)
Sourcepub fn increment_sp(&mut self, items: u16) -> Result<()>
pub fn increment_sp(&mut self, items: u16) -> Result<()>
Increment stack pointer
Sourcepub fn decrement_sp(&mut self, items: u16) -> Result<()>
pub fn decrement_sp(&mut self, items: u16) -> Result<()>
Decrement stack pointer
Sourcepub fn increment_mp(&mut self, offset: usize) -> Result<()>
pub fn increment_mp(&mut self, offset: usize) -> Result<()>
Increment memory pointer
Sourcepub fn decrement_mp(&mut self, offset: usize) -> Result<()>
pub fn decrement_mp(&mut self, offset: usize) -> Result<()>
Decrement memory pointer
Source§impl Assembler
Basic instruction implementations
impl Assembler
Basic instruction implementations
Sourcepub fn _signextend(&mut self) -> Result<()>
pub fn _signextend(&mut self) -> Result<()>
Emit SIGNEXTEND
Sourcepub fn _keccak256(&mut self) -> Result<()>
pub fn _keccak256(&mut self) -> Result<()>
Emit KECCAK256
Sourcepub fn _callvalue(&mut self) -> Result<()>
pub fn _callvalue(&mut self) -> Result<()>
Emit CALLVALUE
Sourcepub fn _calldataload(&mut self) -> Result<()>
pub fn _calldataload(&mut self) -> Result<()>
Emit CALLDATALOAD
Sourcepub fn _calldatasize(&mut self) -> Result<()>
pub fn _calldatasize(&mut self) -> Result<()>
Emit CALLDATASIZE
Sourcepub fn _calldatacopy(&mut self) -> Result<()>
pub fn _calldatacopy(&mut self) -> Result<()>
Emit CALLDATACOPY
Sourcepub fn _extcodesize(&mut self) -> Result<()>
pub fn _extcodesize(&mut self) -> Result<()>
Emit EXTCODESIZE
Sourcepub fn _extcodecopy(&mut self) -> Result<()>
pub fn _extcodecopy(&mut self) -> Result<()>
Emit EXTCODECOPY
Sourcepub fn _returndatasize(&mut self) -> Result<()>
pub fn _returndatasize(&mut self) -> Result<()>
Emit RETURNDATASIZE
Sourcepub fn _returndatacopy(&mut self) -> Result<()>
pub fn _returndatacopy(&mut self) -> Result<()>
Emit RETURNDATACOPY
Sourcepub fn _extcodehash(&mut self) -> Result<()>
pub fn _extcodehash(&mut self) -> Result<()>
Emit EXTCODEHASH
Sourcepub fn _blockhash(&mut self) -> Result<()>
pub fn _blockhash(&mut self) -> Result<()>
Emit BLOCKHASH
Sourcepub fn _timestamp(&mut self) -> Result<()>
pub fn _timestamp(&mut self) -> Result<()>
Emit TIMESTAMP
Sourcepub fn _difficulty(&mut self) -> Result<()>
pub fn _difficulty(&mut self) -> Result<()>
Emit DIFFICULTY
Sourcepub fn _selfbalance(&mut self) -> Result<()>
pub fn _selfbalance(&mut self) -> Result<()>
Emit SELFBALANCE
Sourcepub fn _blobbasefee(&mut self) -> Result<()>
pub fn _blobbasefee(&mut self) -> Result<()>
Emit BLOBBASEFEE
Sourcepub fn _delegatecall(&mut self) -> Result<()>
pub fn _delegatecall(&mut self) -> Result<()>
Emit DELEGATECALL
Sourcepub fn _staticcall(&mut self) -> Result<()>
pub fn _staticcall(&mut self) -> Result<()>
Emit STATICCALL
Sourcepub fn _selfdestruct(&mut self) -> Result<()>
pub fn _selfdestruct(&mut self) -> Result<()>
Emit SELFDESTRUCT