00001 #
00002
00003
00004
00005
00006 # include "parm.h"
00007 # include <stdio.h>
00008 # include "stformats.h"
00009 # include "ststructs.mh"
00010 # include "is_ptr.h"
00011 # include "../pass4/sigs.h"
00012 # define VERBOSE VERBOSE
00013
00014
00015 # define NCOLS 2
00016
00017
00018
00019
00020
00021 prtree(p)
00022 NODE *p;
00023 {
00024 putchar('\n');
00025 prtr1(p,0);
00026 putchar('\n');
00027 }
00028
00029
00030
00031
00032
00033
00034 prtr1(arg,col)
00035 NODE * arg;
00036 int col;
00037 {
00038 register unsigned * p = (unsigned *)arg;
00039 register char * fmtpointer;
00040
00041
00042 moveto(col);
00043
00044 if (p == NIL) {
00045 printf("NIL");
00046 return;
00047 }
00048 if (p == (unsigned *)ERR_SIG) {
00049 printf("ERR_SIG");
00050 return;
00051 }
00052
00053
00054 if (!is_good((NODE *)p)) {
00055 dbgmsg("\nprtree: bad NODE pointer: p=%x\n",p);
00056 abort();
00057 }
00058
00059
00060
00061 printf("0x%x %s ", p, kindname(arg -> kind));
00062
00063
00064 if ((arg -> kind == LETTERID || arg -> kind == OPRID
00065 || arg -> kind == QSTR || arg -> kind == UQSTR)
00066 &&arg -> sel_type != NIL) {
00067 if (arg -> sel_type -> kind == LETTERID) {
00068 printf("(seld %s) ",
00069 getname(arg -> sel_type -> id_str_table_index));
00070 } else {
00071 printf("(seld) ");
00072 }
00073 }
00074
00075
00076 if ( is_list(arg) ) {
00077 maplist(q, arg, { putchar('\n'); prtr1(q, col + NCOLS); } );
00078 return;
00079 }
00080
00081
00082 fmtpointer = typedescr[((arg -> kind) * 2) + 1];
00083 while ( * fmtpointer ) {
00084 switch( * fmtpointer ) {
00085 case 'a':
00086 putchar('\n');
00087 moveto(col+NCOLS);
00088 printf("-> 0x%x", *p);
00089 break;
00090
00091 case 'c':
00092 putchar('\n');
00093 moveto(col+NCOLS);
00094 if (*p == NIL) {
00095 printf("EMPTY");
00096 } else {
00097 char *s = *(char **)p;
00098 int i;
00099 for (i = 0; i < 15 && *s != '\0'; i++, s++) {
00100 if (*s >= 32 && *s < 127) {
00101 printf("%c", *s);
00102 } else {
00103 printf("?");
00104 }
00105 }
00106 }
00107 break;
00108
00109 case 'i':
00110 putchar('\n');
00111 moveto(col+NCOLS);
00112 printf("%d", *p);
00113 break;
00114
00115 case 'l':
00116 # ifdef VERBOSE
00117 findvl(*p);
00118 printf("file: %s line: %d", getname(getfn()), getrl());
00119 # endif
00120 break;
00121
00122 case 'p':
00123 putchar('\n');
00124 if(is_ptr(*p)) {
00125 prtr1(*p,col + NCOLS);
00126 } else {
00127 moveto(col+NCOLS);
00128 printf("%d", *p);
00129 }
00130 break;
00131
00132 case 's':
00133 putchar('\n');
00134 moveto(col+NCOLS);
00135 if ( *p == -1 ) {
00136 printf("surrounding local type identifier");
00137 } else if (*p < -1) {
00138 printf("%d", *p);
00139 } else {
00140 printf("%s", getname(*p));
00141 }
00142 break;
00143
00144 case 'u':
00145 putchar('\n');
00146 moveto(col+NCOLS);
00147 printf("%u", *p);
00148 break;
00149
00150 case 'v':
00151 putchar('\n');
00152 moveto(col+NCOLS);
00153 printf("%x", *p);
00154 break;
00155
00156 case 'x':
00157 break;
00158
00159
00160 default:
00161 dbgmsg("\nprtree: format error: format= %c\n",
00162 *fmtpointer);
00163 }
00164 fmtpointer++; p++;
00165 }
00166 }
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 moveto(i)
00178 { int j;
00179
00180 for ( j = 0; j != i; j++ )
00181 putchar(' ');
00182 }