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:
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user