1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! NeoVM Bytecode Generation Module
//!
//! Converts the intermediate representation (IR) to NeoVM bytecode. This module
//! handles the low-level emission of NeoVM opcodes and manages function dispatch,
//! storage operations, and syscall generation.
//!
//! # Architecture
//!
//! The bytecode generator works in several phases:
//! 1. **Function dispatch** - Generates entry point with method selector routing
//! 2. **IR lowering** - Converts IR instructions to NeoVM opcodes
//! 3. **Optimization** - Applies peephole optimizations to reduce bytecode size
//! 4. **Patching** - Resolves function call targets and jump addresses
//!
//! # NeoVM Opcodes
//!
//! Key opcodes used:
//! - `0x00-0x20` - Push operations (PUSH0, PUSHINT8, etc.)
//! - `0x40` - RET (return from function)
//! - `0x41` - SYSCALL (invoke system call)
//! - `0x45-0x4D` - Control flow (JMP, JMPIF, CALL, etc.)
//!
//! # Storage Model
//!
//! Storage keys are computed using SHA-256 hashing of variable names and
//! mapping keys, following Neo N3 storage conventions.
use VisibilityKind;
use ;
use ;
use NatspecDoc;
use BigInt;
use ;
use HashMap;
include!;
include!;
include!;
include!;
include!;
include!;
pub