Files
linguist/samples/Forth/block.fth
Baptiste Fontaine 055743f886 More Forth samples.
2013-02-18 00:21:46 +01:00

43 lines
671 B
Forth

( Block words. )
variable blk
variable current-block
: block ( n -- addr )
current-block ! 0 ;
: buffer ( n -- addr )
current-block ! 0 ;
\ evaluate (extended semantics)
\ flush ( -- )
: load ( ... n -- ... )
dup current-block !
blk !
save-input
0 >in !
blk @ block ''source ! 1024 ''#source !
( interpret )
restore-input ;
\ save-buffers ( -- )
\ update ( -- )
( Block extension words. )
\ empty-buffers ( -- )
variable scr
: list ( n -- )
dup scr !
dup current-block !
block 1024 bounds do i @ emit loop ;
\ refill (extended semantics)
: thru ( x y -- ) +1 swap do i load loop ;
\ \ (extended semantics)