Skip to main content

Module compiler

Module compiler 

Source
Expand description

Lower the JavaScript AST to fusevm::Chunk.

Native fusevm ops carry arithmetic (+ - * / % **), the relational comparisons (< <= > >=) and boolean short-circuit so the JIT can trace them; the strict numeric hook (host) supplies JS semantics for non-numeric operands (string concat, coercion). Everything JS-specific — name access, member/index access, calls, object/array construction, iteration — lowers to a CallBuiltin that lands in builtins.rs.

Conditions are normalized through the TRUTHY builtin before a native JumpIfFalse, because JS truthiness differs from fusevm’s default numeric truthiness. Compiler-internal name strings travel as native Value::Str constants; JS-level strings are always heap objects built by MKSTR.

Structs§

Compiler
Program
A compiled program: the top-level chunk plus the function template table and the try-block table.

Functions§

compile
Compile a parsed program.
rebase_program
Rebase every func-id and try-id reference so its ids sit above those already loaded on the host (needed only for incremental loading; a no-op for a single run).