Add SP@ IR op, replace SOURCE/DEPTH/PICK with Forth (Phase 7)

New IrOp::SpFetch pushes the current data-stack pointer value, enabling
Forth-level stack introspection. This unblocks:

- DEPTH: `: DEPTH 5440 SP@ - 2 RSHIFT ;` (DATA_STACK_TOP - sp) / 4
- PICK: `: PICK 1+ CELLS SP@ + @ ;` direct memory read
- SOURCE: `: SOURCE 64 24 @ ;` reads INPUT_BUFFER_BASE + SYSVAR_NUM_TIB
- FALIGNED, SFALIGNED, DFALIGNED: address alignment (shadowed in boot.fth)

DEPTH and PICK are now compiled to native WASM — faster than the previous
host-function dispatch through call_indirect + Rust closure + mutex.

Removed ~109 lines of Rust. All 426 tests pass.
This commit is contained in:
2026-04-07 15:53:05 +02:00
parent d30670ebf7
commit b2378e34be
4 changed files with 48 additions and 109 deletions
+2
View File
@@ -133,6 +133,8 @@ pub enum IrOp {
// -- System --
/// Execute word by function table index: ( xt -- )
Execute,
/// Push the current data-stack pointer: ( -- addr )
SpFetch,
// -- Float stack manipulation --
/// Float duplicate: ( F: r -- r r )