vim:ft=forth:ts=2:sw=2:expandtab
variable state
: [ false state ! ; immediate
: ] true state ! ;
: literal postpone lit , ; immediate
: compiling? state @ ;
: interpreting? state @ 0= ;
: si= ( c-addr1 c-addr2 -- f )
dup c@ 1+ begin >r 2dup ci@= r> tuck and while
1- rot 1+ rot 1+ rot
repeat -rot 2drop 0= ;
: find >r latest begin
@ dup if dup link>name r@ si= over visible? and
else r@ swap true
then
until rdrop
dup if
dup link>
swap immediate? not 1 or
then ;
: ' bl word find dup 0= if drop count type space $3F emit else drop then ;
: words latest begin @ ?dup while
dup link>name count type space
repeat ;
: postpone bl word find 0< if literal postpone ,call else ,call then ; immediate
: ['] ' postpone literal ; immediate
: : <builds ,enter hide ] ;
: ; ,exit reveal [ ; immediate
: :noname align latest @ here latest ! ] , here ; immediate
: create <builds ,dodata reveal ;
: constant <builds ,docon align , reveal ;
: variable <builds
ram? @ if ,dodata cell allot
else ,docon align vp dup @ dup , cell+ swap !
then reveal ;
: buffer: <builds
ram? @ if ,dodata allot
else ,docon align vp dup @ dup , rot + swap !
then reveal ;
: defer <builds $46F7 h, 6 allot reveal ; immediate
: defer! swap 1+ swap cell+ i! ;
: is ' $468F4900 over i! defer! ; immediate
: recurse latest @ link> ,call ; immediate
: [char] char postpone literal ; immediate
: s" postpone (s")
[char] " word dup dup c@ 1+ here swap hmove
c@ 1+ allot align ; immediate
: ." postpone s" postpone type ; immediate