retroforth/interface/stack-comments.retro
crc 6335f78231 add extended sigil:( to save stack comments, d:describe
FossilOrigin-Name: dc80974119af1d3120f710c6c37be0616d2003233bffe4389ca82f9fe3d611d9
2024-09-09 12:49:56 +00:00

24 lines
804 B
Forth

Add stack comments to existing words (from retro.muri,
retro.forth, interface/ll.retro, and interface/dedup.retro).
Words defined in the others will make use of the extended
comment format this introduces to add them inline.
~~~
{{
:save (s-) n:inc s:chop here swap s:keep &drop compile:call #2 + d:last.name n:dec store ;
:stack-comment? (s-sf) dup #0 s:fetch $: eq? ;
---reveal---
:sigil:(
stack-comment? [ compiling? &save &drop choose ] &drop choose ;
immediate
}}
:d:describe (:s-)
d:lookup nl
dup 'Name:____ s:put d:name s:put nl
dup 'Address:_ s:put d:xt fetch n:put nl
dup 'Class:___ s:put d:class fetch n:put nl
dup 'Source:__ s:put d:source fetch dup n:-zero? &s:put &drop choose nl
dup 'Stack:___ s:put d:stack fetch dup n:-zero? &s:put &drop choose nl
drop ;
~~~