Skip to main content

build_bytecode

Function build_bytecode 

Source
pub fn build_bytecode(
    source: String,
    filename: &str,
    resolver: &ImportResolver,
) -> Result<Vec<u8>, String>
Expand description

Compiles a .cdl source string to a .cdlb bytecode artifact.

The artifact captures the whole program: every imported workspace .cdl module is linked into the single serialized image, so the resulting .cdlb runs under candela-vm with no source tree present. Dynamic-library imports and host blocks are captured as recipes (logical name + symbol + signature) that the VM re-binds by name at load time, never as embedded binary bytes.

Every fully annotated function is compiled at its declared parameter types before the image is built, so a body error fails the build even in a function main never calls, instead of dropping that function silently.

resolver says where a library import reads from, the same as it does for a run from source, so a program that depends on packages builds into an artifact that carries them.

ยงErrors

Returns an error string if serialization fails. A compile diagnostic travels by the error funnel, not through this Result.