Replace ALLOT/comma/C-comma/ALIGN + float alignment with Forth (Phase 8)

Move memory allocation words to boot.fth:
- ALLOT: `: ALLOT HERE + 12 ! ;`
- , (comma): `: , HERE ! 1 CELLS ALLOT ;`
- C, : `: C, HERE C! 1 ALLOT ;`
- ALIGN: `: ALIGN HERE ALIGNED 12 ! ;`
- FALIGN, SFALIGN, DFALIGN: float-aligned variants

These write directly to WASM memory[SYSVAR_HERE]. The Rust side picks up
Forth-side HERE changes via refresh_user_here() which now reads both
here_cell (for Rust host functions) and memory[12] (for Forth words),
taking the maximum to ensure no allocation is lost.

Removed 222 lines of Rust. All 426 tests pass.
This commit is contained in:
2026-04-07 15:59:16 +02:00
parent b2378e34be
commit d0991c58f6
2 changed files with 40 additions and 222 deletions
+21
View File
@@ -160,6 +160,18 @@
\ ALIGNED is already an IR primitive in the compiler.
\ ALLOT ( n -- ) advance HERE by n bytes
: ALLOT HERE + 12 ! ;
\ , ( x -- ) store cell at HERE, advance by cell
: , HERE ! 1 CELLS ALLOT ;
\ C, ( char -- ) store byte at HERE, advance by 1
: C, HERE C! 1 ALLOT ;
\ ALIGN ( -- ) align HERE to cell boundary
: ALIGN HERE ALIGNED 12 ! ;
\ ---------------------------------------------------------------
\ Phase 5: I/O, pictured numeric output, formatted output
\ ---------------------------------------------------------------
@@ -275,4 +287,13 @@
\ DFALIGNED ( addr -- addr ) align to 8-byte double-float boundary
: DFALIGNED 7 + -8 AND ;
\ FALIGN ( -- ) align HERE to 8-byte float boundary
: FALIGN HERE FALIGNED 12 ! ;
\ SFALIGN ( -- ) align HERE to 4-byte single-float boundary
: SFALIGN ALIGN ;
\ DFALIGN ( -- ) align HERE to 8-byte double-float boundary
: DFALIGN FALIGN ;
\ .S keeps its Rust host function (complex stack introspection).