Expand description
Runtime helper functions emitted into the WASM module.
These provide the value-manipulation primitives that expression and
statement codegen builds upon. Every function is registered during module
assembly (in compiler.rs) and referenced by its function index.
Structs§
- Data
Segment Tracker - Tracks data-segment offsets for well-known constant strings.
Constants§
- RT_
ALLOC - Bump-allocate
sizebytes; returns pointer. - RT_
CHECK_ NAN - NaN check + trap:
check_nan(val_ptr: i32) -> i32— traps if NaN, returns val_ptr - RT_
FUNC_ COUNT - Total number of runtime helper functions.
- RT_
MEMCMP - Byte-by-byte memory comparison:
memcmp(ptr_a: i32, ptr_b: i32, len: i32) -> i32Returns 1 if all bytes match, 0 otherwise. - RT_
VAL_ ACTION_ REF - Create an ACTION_REF value;
val_action_ref(action_id: i32) -> i32 - RT_
VAL_ ADD - Arithmetic: add two numbers;
val_add(a: i32, b: i32) -> i32 - RT_
VAL_ BOOL - Create a BOOL value;
val_bool(b: i32) -> i32 - RT_
VAL_ DIV val_div(a: i32, b: i32) -> i32— traps on /0 and NaN- RT_
VAL_ EQ - Compare two values for structural equality;
val_eq(a: i32, b: i32) -> i32 - RT_
VAL_ GE - RT_
VAL_ GET_ NUMBER - Read the f64 payload from a NUMBER value;
val_get_number(ptr: i32) -> f64We return the raw bits as (i32, i32) or just store to a scratch global. Actually WASM does support f64 on the value stack, so we can return f64. But our function type table only has i32 returns. We’ll add a special type. - RT_
VAL_ GET_ W1 - Read the i32 payload word-1;
val_get_w1(ptr: i32) -> i32 - RT_
VAL_ GET_ W2 - Read the i32 payload word-2;
val_get_w2(ptr: i32) -> i32 - RT_
VAL_ GT - RT_
VAL_ LE - RT_
VAL_ LIST - Create a LIST value;
val_list(arr_ptr: i32, count: i32) -> i32 - RT_
VAL_ LIST_ GET - List index access:
val_list_get(list_ptr: i32, index: i32) -> i32 - RT_
VAL_ LT - Comparisons returning BOOL value ptr:
val_lt(a, b) -> i32,val_le,val_gt,val_ge - RT_
VAL_ MOD val_mod(a: i32, b: i32) -> i32- RT_
VAL_ MUL val_mul(a: i32, b: i32) -> i32- RT_
VAL_ NEG val_neg(a: i32) -> i32— unary negate- RT_
VAL_ NIL - Create a NIL value on the heap; returns pointer.
- RT_
VAL_ NOT val_not(a: i32) -> i32— logical not (bool)- RT_
VAL_ NUMBER - Create a NUMBER value from an f64; returns pointer.
- RT_
VAL_ RECORD - Create a RECORD value;
val_record(entries_ptr: i32, count: i32) -> i32 - RT_
VAL_ RECORD_ GET - Record field access:
val_record_get(rec_ptr: i32, key_ptr: i32, key_len: i32) -> i32 - RT_
VAL_ STRING - Create a STRING value;
val_string(data_ptr: i32, len: i32) -> i32 - RT_
VAL_ STRING_ CONCAT - Concatenate two STRING values;
val_string_concat(a: i32, b: i32) -> i32 - RT_
VAL_ SUB val_sub(a: i32, b: i32) -> i32- RT_
VAL_ TAG - Read the tag of a value;
val_tag(ptr: i32) -> i32 - RT_
VAL_ TO_ STRING - Convert a value to its string representation for interpolation.
val_to_string(ptr: i32) -> i32(returns a STRING value ptr) - RT_
VAL_ VARIANT - Create a VARIANT value;
val_variant(id: i32, data_ptr: i32) -> i32
Functions§
- emit_
alloc - Emit the
alloc(size: i32) -> i32function. - emit_
check_ nan - Emit
check_nan(val_ptr: i32) -> i32— traps if NUMBER value is NaN. - emit_
memcmp - Emit
memcmp(ptr_a: i32, ptr_b: i32, len: i32) -> i32— byte-by-byte comparison. - emit_
val_ action_ ref - Emit
val_action_ref(action_id: i32) -> i32. - emit_
val_ add - emit_
val_ bool - Emit
val_bool(b: i32) -> i32. - emit_
val_ div - Emit
val_div— with division-by-zero and NaN trap guards. - emit_
val_ eq - Emit
val_eq(a: i32, b: i32) -> i32— structural equality, returns bool value ptr. - emit_
val_ ge - emit_
val_ get_ number - Emit
val_get_number(ptr: i32) -> i32. - emit_
val_ get_ w1 - Emit
val_get_w1(ptr: i32) -> i32. - emit_
val_ get_ w2 - Emit
val_get_w2(ptr: i32) -> i32. - emit_
val_ gt - emit_
val_ le - emit_
val_ list - Emit
val_list(arr_ptr: i32, count: i32) -> i32. - emit_
val_ list_ get - Emit
val_list_get(list_ptr, index) -> i32. - emit_
val_ lt - emit_
val_ mod - Emit
val_mod(a, b) -> i32— f64 remainder. - emit_
val_ mul - emit_
val_ neg - Emit
val_neg(a: i32) -> i32— unary negate. - emit_
val_ nil - Emit
val_nil() -> i32. - emit_
val_ not - Emit
val_not(a: i32) -> i32— logical not (bool). - emit_
val_ number - Emit
val_number(n_bits_lo: i32, n_bits_hi: i32) -> i32. - emit_
val_ record - Emit
val_record(entries_ptr: i32, count: i32) -> i32. - emit_
val_ record_ get - Emit
val_record_get(rec_ptr, key_ptr, key_len) -> i32. - emit_
val_ string - Emit
val_string(data_ptr: i32, len: i32) -> i32. - emit_
val_ string_ concat - Emit
val_string_concat(a: i32, b: i32) -> i32. - emit_
val_ sub - emit_
val_ tag - Emit
val_tag(ptr: i32) -> i32— reads the tag word. - emit_
val_ to_ string - Emit
val_to_string(ptr: i32) -> i32— converts any value to a STRING value. - emit_
val_ variant - Emit
val_variant(id: i32, data_ptr: i32) -> i32. - rt_
func_ idx - Compute the absolute WASM function index of a runtime helper.