Expand description
PEPL WASM code generator: compiles a verified AST to .wasm binary.
§Architecture
The code generator takes a validated pepl_types::ast::Program and
produces a self-contained .wasm module. The generated module follows
the PEPL host-integration contract:
§Imports
env.host_call(cap_id, fn_id, args_ptr) → result_ptrenv.log(ptr, len)env.trap(ptr, len)
§Exports
init(gas_limit)— initialise state to defaultsdispatch_action(action_id, args_ptr) → result_ptrrender(view_id) → surface_ptrget_state() → state_ptralloc(size) → ptrmemory— linear memory- (conditional)
update(dt_ptr),handle_event(event_ptr)
§Value Representation
Every PEPL value is a heap-allocated 12-byte cell:
[tag: i32, payload: 8 bytes]. See types for tag constants.
Re-exports§
pub use compiler::compile;pub use compiler::compile_with_source_map;pub use error::CodegenError;pub use error::CodegenResult;pub use source_map::SourceMap;
Modules§
- compiler
- Main WASM module assembler.
- error
- Codegen error types.
- expr
- Expression code generation.
- gas
- Gas-metering instrumentation.
- runtime
- Runtime helper functions emitted into the WASM module.
- source_
map - Source mapping — WASM function index → PEPL source location.
- space
- Space-level code generation.
- stmt
- Statement code generation.
- test_
codegen - Test block codegen — compiles PEPL
tests { }blocks to WASM functions. - types
- WASM value-representation constants and memory layout.