Function parse_asm
pub fn parse_asm(s: &str) -> Result<Vec<u8>, Report>Expand description
Parse EVM assembly from a string into bytecode.
Assembles EVM mnemonics from a string into raw bytecode. Supports:
- Standard EVM opcodes (
ADD,PUSH1 0x42, etc.) - Auto-sized pushes (
PUSH 0x1234picks the smallest encoding) - Labels:
name:defines a label at the current PC,PUSH %name/PUSHn %nameresolves to the label’s byte offset - Comments starting with
; - C-style
#definemacros (textual expansion before parsing), with optional parameters
#define PUSH_TWO(a, b) PUSH $a PUSH $b
entry:
PUSH_TWO(1, 2)
ADD
PUSH %target
JUMP
target:
JUMPDEST
STOP