1 \ @(#) dump_struct.fth 97/12/10 1.1
2 \ Dump contents of structure showing values and member names.
5 \ Copyright 1987 Phil Burk
8 \ MOD: PLB 9/4/88 Print size too.
9 \ MOD: PLB 9/9/88 Print U/S , add ADST
10 \ MOD: PLB 12/6/90 Modified to work with H4th
11 \ 941109 PLB Converted to pforth. Added RP detection.
13 include? task-member member.fth
14 include? task-c_struct c_struct.fth
18 : EMIT-TO-COLUMN ( char col -- )
19 out @ - 0 max 80 min 0
25 : STACK.NFAS ( fencenfa topnfa -- 0 nfa0 nfa1 ... )
26 \ Fill stack with nfas of words until fence hit.
28 0 r> ( set terminator )
29 BEGIN ( -- 0 n0 n1 ... top )
32 \ dup n>link @ \ JForth
38 : DST.DUMP.TYPE ( +-size -- , dump data type, 941109)
53 : DUMP.MEMBER ( addr member-pfa -- , dump member of structure)
54 ob.stats ( -- addr offset size )
55 >r + r> ( -- addr' size )
56 dup ABS 4 > ( -- addr' size flag )
57 IF cr 2dup swap . . ABS dump
58 ELSE tuck @bytes 10 .r ( -- size )
59 3 spaces dst.dump.type
64 : DUMP.STRUCT ( addr-data addr-structure -- )
65 >newline swap >r ( -- as , save addr-data for dumping )
66 \ dup cell+ @ over + \ JForth
67 dup code> >name swap cell+ @ over + \ HForth
68 stack.nfas ( fill stack with nfas of members )
71 WHILE ( continue until non-zero )
72 dup name> >body r@ swap dump.member
73 bl 18 emit-to-column id. cr
78 : DST ( addr <name> -- , dump contents of structure )
81 IF [compile] literal compile dump.struct
86 : ADST ( absolute_address -- , dump structure )
90 \ For Testing Purposes
108 $ 12345678 afoo ..! along1
109 $ -665 afoo ..! ashort1
112 -234 afoo .. agoo ..! goo_height