Expand description
WASM value-representation constants and memory layout.
Every PEPL value is stored on the linear-memory heap as a 12-byte cell:
offset+0 : i32 — tag (see TAG_* constants)
offset+4 : 8 bytes — payload (interpretation depends on tag)§Payload layouts
| Tag | Bytes 4..8 (word-1) | Bytes 8..12 (word-2) |
|---|---|---|
| NIL | 0 | 0 |
| NUMBER | f64 occupies all 8 bytes (little-endian) | |
| BOOL | i32 (0 = false, 1 = true) | 0 (padding) |
| STRING | i32 data-offset | i32 byte-length |
| LIST | i32 array-offset | i32 element-count |
| RECORD | i32 entries-offset | i32 field-count |
| VARIANT | i32 variant-id | i32 data-ptr (record) |
| LAMBDA | i32 func-index | i32 closure-ptr |
| COLOR | i32 rgba-packed | 0 (padding) |
| ACTION_REF | i32 action-id | 0 (padding) |
Constants§
- COMPILER_
VERSION - Compiler version embedded in the custom section.
- CUSTOM_
SECTION_ NAME - Custom section name for PEPL metadata.
- GLOBAL_
GAS - Gas counter — incremented on each tick.
- GLOBAL_
GAS_ LIMIT - Gas limit — set at init, trap when exceeded.
- GLOBAL_
HEAP_ PTR - Heap allocation pointer — next free byte in linear memory.
- GLOBAL_
STATE_ PTR - Pointer to the state record value.
- HEAP_
START - Heap starts after the data segment region. We reserve the first 4 KiB for static data (string constants, etc.).
- IMPORT_
COUNT - Number of imported functions (offset for locally-defined function indices).
- IMPORT_
GET_ TIMESTAMP env.get_timestamp() -> i64— deterministic event timestamp (milliseconds).- IMPORT_
HOST_ CALL env.host_call(cap_id: i32, fn_id: i32, args_ptr: i32) -> i32- IMPORT_
LOG env.log(ptr: i32, len: i32)- IMPORT_
TRAP env.trap(ptr: i32, len: i32)— aborts execution with a message.- INITIAL_
MEMORY_ PAGES - Initial linear memory size in pages (64 KiB each).
- MAX_
MEMORY_ PAGES - Maximum linear memory pages (16 MiB).
- TAG_
ACTION_ REF - TAG_
BOOL - TAG_
COLOR - TAG_
LAMBDA - TAG_
LIST - TAG_NIL
- TAG_
NUMBER - TAG_
RECORD - TAG_
STRING - TAG_
VARIANT - TYPE_
COUNT - Total number of fixed type signatures.
- TYPE_
F64_ I32 (f64) -> i32- TYPE_
I32X2_ I32 (i32, i32) -> i32- TYPE_
I32X2_ VOID (i32, i32) -> ()- TYPE_
I32X3_ I32 (i32, i32, i32) -> i32- TYPE_
I32X3_ VOID (i32, i32, i32) -> ()- TYPE_
I32_ F64_ VOID (i32, f64) -> ()- TYPE_
I32_ I32 (i32) -> i32- TYPE_
I32_ VOID (i32) -> ()- TYPE_
VOID_ I32 () -> i32- TYPE_
VOID_ I64 () -> i64- TYPE_
VOID_ VOID () -> ()- VALUE_
SIZE - Size of a single PEPL value cell on the heap (bytes).