\ @(#) dump_struct.fth 97/12/10 1.1
\ Dump contents of structure showing values and member names.
\ Copyright 1987 Phil Burk
\ MOD: PLB 9/4/88 Print size too.
\ MOD: PLB 9/9/88 Print U/S , add ADST
\ MOD: PLB 12/6/90 Modified to work with H4th
\ 941109 PLB Converted to pforth. Added RP detection.
\ 090609 PLB Convert >rel to use->rel and ..! to s!
include? task-member.fth member.fth
include? task-c_struct c_struct.fth
: EMIT-TO-COLUMN ( char col -- )
: STACK.NFAS ( fencenfa topnfa -- 0 nfa0 nfa1 ... )
\ Fill stack with nfas of words until fence hit.
BEGIN ( -- 0 n0 n1 ... top )
: DST.DUMP.TYPE ( +-size -- , dump data type, 941109)
: DUMP.MEMBER ( addr member-pfa -- , dump member of structure)
ob.stats ( -- addr offset size )
>r + r> ( -- addr' size )
dup ABS 4 > ( -- addr' size flag )
IF cr 2dup swap . . ABS dump
ELSE tuck @bytes 10 .r ( -- size )
: DUMP.STRUCT ( addr-data addr-structure -- )
>newline swap >r ( -- as , save addr-data for dumping )
\ dup cell+ @ over + \ JForth
dup code> >name swap cell+ @ over + \ HForth
stack.nfas ( fill stack with nfas of members )
WHILE ( continue until non-zero )
dup name> >body r@ swap dump.member
bl 18 emit-to-column id. cr
: DST ( addr <name> -- , dump contents of structure )
IF [compile] literal compile dump.struct
: ADST ( absolute_address -- , dump structure )
use->rel [compile] dst \ mod 090609
$ 12345678 afoo s! along1
-234 afoo .. agoo s! goo_height