1 /* dbnode.c - print debug messages for operators for bcc */
3 /* Copyright (C) 1992 Bruce Evans */
14 PRIVATE
char *opname
[LASTOP
- FIRSTOP
+ 1] = /* operator names */
15 { /* order must agree with op.h */
24 "strucelt", "strucptr",
26 "addab", "andab", "divab", "eorab", "modab", "mulab", "orab",
27 "slab", "srab", "subab",
38 "address", "cast", "indirect", "neg",
39 "predec", "preinc", "postdec", "postinc",
40 "func", "list", "rootlist",
42 "ptraddab", "ptradd", "ptrsub",
45 FORWARD
void outindchars
P((int byte
, indn_pt count
));
47 PUBLIC
void dbitem(item
)
48 struct symstruct
*item
;
51 if (item
->storage
== NOSTORAGE
)
54 outstr(item
->name
.namep
+ 2);
56 outshex(item
->offset
.offi
);
60 if (item
->storage
== LOCAL
)
63 if (item
->flags
== TEMP
)
66 outstr(item
->name
.namep
);
69 outindchars('[', item
->indcount
);
70 switch (item
->storage
)
74 if (item
->type
->scalar
& RSCALAR
)
76 else if (item
->type
->scalar
& UNSIGNED
)
77 outuvalue((uvalue_t
) item
->offset
.offv
);
79 outvalue(item
->offset
.offv
);
92 outregname(item
->storage
);
93 if (item
->level
== OFFKLUDGELEVEL
)
96 if (item
->flags
& LABELLED
)
97 outlabel(item
->name
.label
);
99 outccname(item
->name
.namep
);
109 if (item
->flags
& LABELLED
)
110 outlabel(item
->name
.label
);
112 outstr(item
->name
.namep
);
115 outstr("bad storage (");
116 outhex((uoffset_T
) item
->storage
);
120 if (item
->storage
!= CONSTANT
)
122 if (item
->offset
.offi
>= 0)
124 outshex(item
->offset
.offi
);
126 outindchars(']', item
->indcount
);
129 PUBLIC
void dbtype(type
)
130 struct typestruct
*type
;
132 for ( ; type
!= NULL
; type
= type
->nexttype
)
135 switch (type
->constructor
)
139 outhex(type
->typesize
/ type
->nexttype
->typesize
);
151 if (type
->scalar
& UNSIGNED
)
159 PUBLIC
void dbnode(exp
) /* sub-nodes must be leaves */
160 struct nodestruct
*exp
;
165 if (exp
->tag
< FIRSTOP
&& exp
->tag
> LASTOP
)
166 outstr("unknown op");
168 outstr(opname
[exp
->tag
- FIRSTOP
]);
169 if (exp
->right
!= NULL
&& exp
->tag
!= FUNCOP
&&
170 exp
->tag
!= LISTOP
&& exp
->tag
!= ROOTLISTOP
)
172 dbitem(exp
->right
->left
.symptr
);
175 dbitem(exp
->left
.nodeptr
->left
.symptr
);
176 outstr(" (used reg = ");
177 if (reguse
& INDREG0
)
179 if (reguse
& INDREG1
)
181 if (reguse
& INDREG2
)
186 PUBLIC
void dbnodeswap()
189 outnstr("! Debug: expression subtree swapping");
192 PRIVATE
void outindchars(byte
, count
)