Skip to main content

encode_soft_core_full

Function encode_soft_core_full 

Source
pub fn encode_soft_core_full(
    program: &CompiledProgram,
) -> Result<Vec<u32>, String>
Expand description

Assemble a whole compiled program (from crate::vm::Compiler::compile_for_chip) into full soft-core imem words. TWO-PASS: pass 1 lays out Main then every function body, computing each code index’s imem word offset (a Call and a wide LoadConst occupy two words); pass 2 emits the words, resolving every Jump/branch/iter target and callee entry through that pc→imem map. Err if the program uses an op with no chip lowering (floats, Text, closures, CRDTs, channels, …) or overflows an operand field.

The full-core image (width = 32). Because the value datapath auto-promotes to BigInt on overflow and over-i32 constants are carried in full by op 222 at every width, the emitted words are IDENTICAL at 32 and 64 — the width no longer changes the encoding. Pass an explicit width to encode_soft_core_full_w.