pub struct Assembly { /* private fields */ }
Expand description
A structured representation of an EVM bytecode contract which is either a legacy contract, or an EVM Object Format (EOF) compatiable contract. Regardless of whether it is legacy or not, a contract is divided into one or more sections. A section is either a code section or a data section. For EOF contracts, the data section should also come last. However, for legacy contracts, they can be interleaved.
Implementations§
source§impl Assembly
impl Assembly
pub fn from_legacy_bytes(bytes: &[u8]) -> Assembly
sourcepub fn from_eof_bytes(bytes: &[u8]) -> Result<Assembly, DecodingError>
pub fn from_eof_bytes(bytes: &[u8]) -> Result<Assembly, DecodingError>
A decoded EOF byte sequence (see EIP3540). This provides a gateway for disassembling EOF contracts into assembly language and back again.
§Examples
use evmil::bytecode::Assembly;
use evmil::util::FromHexString;
// EOF bytecode contract
let hex = "0xef00010100040200010001030000000000000000";
// Conversion into bytes
let bytes = hex.from_hex_string().unwrap();
// Decode EOF bytecode (assuming no errors)
let eof = Assembly::from_eof_bytes(&bytes).unwrap();
// Check that section contains one instruction
// assert_eq!(eof.sections.len(),1);
pub fn empty() -> Self
pub fn new(sections: Vec<StructuredSection>) -> Self
pub fn iter(&self) -> Iter<'_, StructuredSection> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, StructuredSection> ⓘ
sourcepub fn add(&mut self, section: StructuredSection)
pub fn add(&mut self, section: StructuredSection)
Add a new section to this bytecode container
Trait Implementations§
source§impl<'a> IntoIterator for &'a Assembly
impl<'a> IntoIterator for &'a Assembly
source§impl<'a> IntoIterator for &'a mut Assembly
impl<'a> IntoIterator for &'a mut Assembly
source§impl PartialEq for Assembly
impl PartialEq for Assembly
source§impl TryFrom<&[Term]> for Assembly
impl TryFrom<&[Term]> for Assembly
Translate a sequence of IL statements into EVM bytecode, or fail with an error.
source§impl<const N: usize> TryFrom<&[Term; N]> for Assembly
impl<const N: usize> TryFrom<&[Term; N]> for Assembly
Translate a sequence of IL statements into EVM bytecode, or fail with an error.
impl StructuralPartialEq for Assembly
Auto Trait Implementations§
impl Freeze for Assembly
impl RefUnwindSafe for Assembly
impl Send for Assembly
impl Sync for Assembly
impl Unpin for Assembly
impl UnwindSafe for Assembly
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