pub struct Assembler {
buffer: Buffer,
gas: u128,
pub mp: usize,
pub sp: u8,
}
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: u8
Stack pointer, maximum 1024 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: u8) -> Result<()>
pub fn increment_sp(&mut self, items: u8) -> Result<()>
Increment stack pointer
sourcepub fn decrement_sp(&mut self, items: u8) -> Result<()>
pub fn decrement_sp(&mut self, items: u8) -> 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
impl Assembler
Basic instruction implementations
sourcepub fn _signextend(&mut self) -> Result<()>
pub fn _signextend(&mut self) -> Result<()>
Emit SIGNEXTEND
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 _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 _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
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Assembler
impl Send for Assembler
impl Sync for Assembler
impl Unpin for Assembler
impl UnwindSafe for Assembler
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