Module codegen

Module codegen 

Source
Expand description

Yul Code Generation Module

Generates NeoVM bytecode from Yul AST. This module handles the translation of high-level Yul constructs to low-level NeoVM instructions.

§Output

  • CompilationResult - Complete compilation output including bytecode, ABI, manifest, and debug information

§Code Generation Pipeline

  1. AST traversal and instruction emission
  2. Label resolution and jump patching
  3. Optimization passes
  4. Final bytecode assembly

Structs§

CodeGenerator
Code generator for Yul AST to NeoVM bytecode
CompilationResult
Result of compiling Yul source to NeoVM bytecode
FunctionMeta
Metadata for a compiled function, collected during bytecode generation.
LoopContext
Loop context for break/continue tracking
VariableInfo
Variable information for code generation

Constants§

INIT_MARKER_LEN
Length of the init marker prepended to bytecode (PUSHDATA1 + len + b“init“).

Functions§

emit_ldloc 🔒
Emit LDLOC instruction with proper index encoding NeoVM uses 0x10-0x13 for indices 0-3, or 0x14 + index for larger indices
emit_stloc 🔒
Emit STLOC instruction with proper index encoding NeoVM uses 0x0C-0x0F for indices 0-3, or 0x14 + index for larger indices
interop_id_bytes
Compute the 4-byte interop ID for a Neo syscall name This is used to identify syscalls in NeoVM bytecode