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:
@@ -139,6 +139,10 @@ pub enum IrOp {
|
||||
ForthLocalGet(u32),
|
||||
/// Set Forth local variable N: ( x -- )
|
||||
ForthLocalSet(u32),
|
||||
/// Push float-typed Forth local N: ( F: -- r )
|
||||
ForthFLocalGet(u32),
|
||||
/// Set float-typed Forth local N: ( F: r -- )
|
||||
ForthFLocalSet(u32),
|
||||
|
||||
// -- I/O --
|
||||
/// Output character: ( char -- )
|
||||
|
||||
Reference in New Issue
Block a user