Skip to main content

RT_VAL_NUMBER

Constant RT_VAL_NUMBER 

Source
pub const RT_VAL_NUMBER: u32 = 2;
Expand description

Create a NUMBER value from an f64; returns pointer.

val_number(n: f64) -> i32 — note: declared as (i32, i32) low/high Actually we pass the f64 via two i32 halves and reinterpret. Simpler approach: pass as i64 bits, but WASM MVP has i64. Simplest: store the f64 directly using f64.store. We’ll use a helper that takes no args on the WASM stack — the caller pushes the f64 onto memory via f64.store beforehand.

Actually, let’s keep it simple: val_number() allocates a cell, and the caller writes tag + f64 into that cell. We provide a helper: make_number(bits_hi: i32, bits_lo: i32) -> i32 Or even simpler: emit inline alloc + store in expr.rs.

For the runtime we only expose alloc and the constructor helpers.