pub struct Assembler { /* private fields */ }Expand description
Two-pass assembler for EVM bytecode.
Implementations§
Source§impl Assembler
impl Assembler
Sourcepub fn with_config(config: AssemblerConfig) -> Assembler
pub fn with_config(config: AssemblerConfig) -> Assembler
Creates a new assembler with the given configuration.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears all emitted instructions and local identifiers while retaining allocated storage.
Sourcepub fn new_deferred_const(&mut self) -> DeferredConst
pub fn new_deferred_const(&mut self) -> DeferredConst
Creates a new deferred constant.
Sourcepub fn emit_push(&mut self, value: Uint<256, 4>)
pub fn emit_push(&mut self, value: Uint<256, 4>)
Emits a push instruction with an immediate value.
Sourcepub fn emit_push_label(&mut self, label: Label)
pub fn emit_push_label(&mut self, label: Label)
Emits a push instruction that will be resolved to a label’s offset.
Sourcepub fn emit_push_deferred(&mut self, id: DeferredConst)
pub fn emit_push_deferred(&mut self, id: DeferredConst)
Emits a push instruction for a deferred constant.
Sourcepub fn set_deferred_const(&mut self, id: DeferredConst, value: Uint<256, 4>)
pub fn set_deferred_const(&mut self, id: DeferredConst, value: Uint<256, 4>)
Sets the value of a deferred constant.
Sourcepub fn emit_push_immutable(&mut self, id: u32)
pub fn emit_push_immutable(&mut self, id: u32)
Emits a PUSH32 zero placeholder for the immutable identified by id.
Sourcepub fn define_label(&mut self, label: Label)
pub fn define_label(&mut self, label: Label)
Defines a label and emits a JUMPDEST at the current position.
Sourcepub fn assemble(&mut self) -> AssembledCode
pub fn assemble(&mut self) -> AssembledCode
Assembles the instructions into bytecode. Uses an iterative two-pass algorithm that handles PUSH width changes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Assembler
impl RefUnwindSafe for Assembler
impl Send for Assembler
impl Sync for Assembler
impl Unpin for Assembler
impl UnsafeUnpin 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
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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> ⓘ
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 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> ⓘ
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