Skip to main content

Crate pepl_codegen

Crate pepl_codegen 

Source
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_ptr
  • env.log(ptr, len)
  • env.trap(ptr, len)

§Exports

  • init(gas_limit) — initialise state to defaults
  • dispatch_action(action_id, args_ptr) → result_ptr
  • render(view_id) → surface_ptr
  • get_state() → state_ptr
  • alloc(size) → ptr
  • memory — 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.