Add F: float locals (gforth/SwiftForth-style)

`{: F: x F: y :}` now declares float-typed locals that live on the float
stack. `x x F* y y F* F+ FSQRT` writes real float code without manual
FSTACK juggling — previously WAFER had a 100%-compliant float wordset
but no way to name intermediate float values.

New IR ops `ForthFLocalGet(n)` / `ForthFLocalSet(n)` alongside the
existing int-local ops. Each kind has its own index namespace so mixed
declarations like `{: n F: f :}` compose cleanly. Codegen allocates f64
WASM locals after the existing f64 scratch pair; the fsp-bridge logic
mirrors the existing FDup/FSwap path.

Outer interpreter tracks a parallel `compiling_local_kinds` alongside
`compiling_locals` (keeps the 18 existing touch-points unchanged) and
extends `{:` to recognize `F:` as a per-next-name type marker. `TO` and
name resolution branch on kind to pick Int vs Float get/set ops.

Four tests: classic hypot, TO round-trip, mixed int/float args, and
uninitialized float via `|`. Inline-inhibit for the new ops added to
optimizer and is_promotable so they don't sneak into contexts that
would collide with the caller's WASM locals.
This commit is contained in:
2026-04-15 21:29:01 +02:00
parent 6771f5d46b
commit 1a8f27b5bd
4 changed files with 196 additions and 35 deletions
+5 -1
View File
@@ -633,7 +633,11 @@ fn contains_call_to(ops: &[IrOp], target: WordId) -> bool {
fn contains_exit(ops: &[IrOp]) -> bool {
for op in ops {
match op {
IrOp::Exit | IrOp::ForthLocalGet(_) | IrOp::ForthLocalSet(_) => return true,
IrOp::Exit
| IrOp::ForthLocalGet(_)
| IrOp::ForthLocalSet(_)
| IrOp::ForthFLocalGet(_)
| IrOp::ForthFLocalSet(_) => return true,
IrOp::If {
then_body,
else_body,