annotate mc-tree.c @ 135:4cfd24d1b929 power-pc-fix

fix power-pc basic test
author kono
date Sun, 04 May 2003 10:30:52 +0900
parents f94ca1168520
children da2e3f2d127d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
0529f5abe9d0 *** empty log message ***
kono
parents: 0
diff changeset
1 /* Micro-C tree print routine */
0529f5abe9d0 *** empty log message ***
kono
parents: 0
diff changeset
2 /* $Id$ */
0529f5abe9d0 *** empty log message ***
kono
parents: 0
diff changeset
3
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
4 #define EXTERN /**/
d35df41eac69 Initial revision
kono
parents:
diff changeset
5 #include "mc.h"
d35df41eac69 Initial revision
kono
parents:
diff changeset
6
d35df41eac69 Initial revision
kono
parents:
diff changeset
7 typedef
d35df41eac69 Initial revision
kono
parents:
diff changeset
8 struct tree_node {
d35df41eac69 Initial revision
kono
parents:
diff changeset
9 int tree_type;
d35df41eac69 Initial revision
kono
parents:
diff changeset
10 char *tree_name;
d35df41eac69 Initial revision
kono
parents:
diff changeset
11 char *tree_args;
d35df41eac69 Initial revision
kono
parents:
diff changeset
12 } tree_node_type;
d35df41eac69 Initial revision
kono
parents:
diff changeset
13
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
14 extern void tree_print(int e);
254a0c576114 argument type list
kono
parents: 50
diff changeset
15 extern void tree_parse(int e);
254a0c576114 argument type list
kono
parents: 50
diff changeset
16 extern void tree_print_t(int e,int t);
254a0c576114 argument type list
kono
parents: 50
diff changeset
17 static tree_node_type * find_node(int e);
254a0c576114 argument type list
kono
parents: 50
diff changeset
18 extern void type_print(int type,NMTBL *n,FILE *out);
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
19 extern void type_print1(int type,NMTBL *n,FILE *out,int cont);
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
20 extern void sym_print(int type,FILE *out);
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
21
254a0c576114 argument type list
kono
parents: 50
diff changeset
22 /* ascendant order for binary search */
254a0c576114 argument type list
kono
parents: 50
diff changeset
23
18
df7fa8cee67b pass -Wall
kono
parents: 1
diff changeset
24 static
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
25 tree_node_type tree_nodes[] = {
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
26 {(-45),"...",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
27 {(-44),"lmacro",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
28 {(-43),"fmacro",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
29 {(-42),"konst",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
30 {(-41),"defined",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
31 {(-40),"environment",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
32 {(-39),"code",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
33 {(-38),"register",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
34 {(-37),"void",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
35 {(-36),"extern",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
36 {(-35),"short",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
37 {(-34),"long",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
38 {(-33),"type",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
39 {(-32),"sizeof",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
40 {(-31),"typedef",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
41 {(-30),"flabel",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
42 {(-29),"blabel",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
43 {(-28),"macro",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
44 {(-27),"string",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
45 {(-26),"ident",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
46 {(-25),"field",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
47 {(-24),"tag",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
48 {(-23),"reserve",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
49 {(-22),"default",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
50 {(-21),"case",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
51 {(-20),"switch",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
52 {(-19),"while",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
53 {(-18),"do",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
54 {(-17),"for",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
55 {(-16),"else",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
56 {(-15),"if",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
57 {(-14),"continue",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
58 {(-13),"break",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
59 {(-12),"return",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
60 {(-11),"goto",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
61 {(-10),"static",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
62 {(-9),"empty",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
63 {(-8),"function","t"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
64 {(-7),"union",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
65 {(-6),"struct","vt"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
66 {(-5),"array","tv"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
67 {(-4),"pointer","t"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
68 {(-3),"unsigned",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
69 {(-2),"char",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
70 {(-1),"int",""},
37
412ad2e6c2a2 struct copy
kono
parents: 33
diff changeset
71
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
72 {1,"gvar","vs"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
73 {2,"rgvar","vs"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
74 {3,"crgvar","vs"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
75 {4,"lvar","v"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
76 {5,"rlvar","v"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
77 {6,"crlvar","v"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
78 {7,"const","v"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
79 {8,"fname","n"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
80 {9,"*","e"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
81 {10,"rindirect","e"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
82 {11,"crindirect","e"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
83 {12,"&","e"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
84 {13,"-","e"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
85 {14,"!","e"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
86 {15,"~","e"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
87 {16,"++",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
88 {17,"postinc","e"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
89 {18,"preinc","e"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
90 {19,"cpostinc","e"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
91 {20,"cpreinc","e"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
92 {21,"--",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
93 {22,"cpostdec","e"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
94 {23,"cpredec","e"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
95 {24,"*","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
96 {25,"*","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
97 {26,"/","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
98 {27,"/","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
99 {28,"%","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
100 {29,"%","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
101 {30,"+","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
102 {31,"-","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
103 {32,">>","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
104 {33,">>","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
105 {34,"<<","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
106 {35,"<<","ee"},
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
107 {36,">","ee"},
dba8d111b7a0 c output
kono
parents: 68
diff changeset
108 {37,">","ee"},
dba8d111b7a0 c output
kono
parents: 68
diff changeset
109 {38,">=","ee"},
dba8d111b7a0 c output
kono
parents: 68
diff changeset
110 {39,">=","ee"},
dba8d111b7a0 c output
kono
parents: 68
diff changeset
111 {40,"<","ee"},
dba8d111b7a0 c output
kono
parents: 68
diff changeset
112 {41,"<","ee"},
dba8d111b7a0 c output
kono
parents: 68
diff changeset
113 {42,"<=","ee"},
dba8d111b7a0 c output
kono
parents: 68
diff changeset
114 {43,"<=","ee"},
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
115 {44,"==","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
116 {45,"!=","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
117 {46,"&","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
118 {47,"^","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
119 {48,"|","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
120 {49,"&&","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
121 {50,"||","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
122 {51,"cond","eee"},
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
123 {52," = ","ee"},
dba8d111b7a0 c output
kono
parents: 68
diff changeset
124 {53," = ","ee"},
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
125 {54,"assop","eev"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
126 {55,"cassop","eev"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
127 {56,",","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
128 {57,"(",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
129 {58,")",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
130 {59,"[",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
131 {60,"]",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
132 {61,"{",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
133 {62,"}",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
134 {63,":","ee"},
254a0c576114 argument type list
kono
parents: 50
diff changeset
135 {64,";",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
136 {65,".",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
137 {66,"->",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
138 {67,"cname",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
139 {68,"sass",""},
254a0c576114 argument type list
kono
parents: 50
diff changeset
140 {69,"rstruct",""},
81
f94ca1168520 float first try...
kono
parents: 75
diff changeset
141 {00,"=",""},
f94ca1168520 float first try...
kono
parents: 75
diff changeset
142 {AS+24,"*=","ee"},
f94ca1168520 float first try...
kono
parents: 75
diff changeset
143 {AS+25,"*=","ee"},
f94ca1168520 float first try...
kono
parents: 75
diff changeset
144 {AS+26,"/=","ee"},
f94ca1168520 float first try...
kono
parents: 75
diff changeset
145 {AS+27,"/=","ee"},
f94ca1168520 float first try...
kono
parents: 75
diff changeset
146 {AS+28,"%=","ee"},
f94ca1168520 float first try...
kono
parents: 75
diff changeset
147 {AS+29,"%=","ee"},
f94ca1168520 float first try...
kono
parents: 75
diff changeset
148 {AS+30,"+=","ee"},
f94ca1168520 float first try...
kono
parents: 75
diff changeset
149 {AS+31,"-=","ee"},
f94ca1168520 float first try...
kono
parents: 75
diff changeset
150 {AS+32,">>=","ee"},
f94ca1168520 float first try...
kono
parents: 75
diff changeset
151 {AS+33,">>=","ee"},
f94ca1168520 float first try...
kono
parents: 75
diff changeset
152 {AS+34,"<<=","ee"},
f94ca1168520 float first try...
kono
parents: 75
diff changeset
153 {AS+35,"<<=","ee"},
f94ca1168520 float first try...
kono
parents: 75
diff changeset
154 {AS+46,"&=","ee"},
f94ca1168520 float first try...
kono
parents: 75
diff changeset
155 {AS+47,"^=","ee"},
f94ca1168520 float first try...
kono
parents: 75
diff changeset
156 {AS+48,"|=","ee"},
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
157 };
d35df41eac69 Initial revision
kono
parents:
diff changeset
158
18
df7fa8cee67b pass -Wall
kono
parents: 1
diff changeset
159 void
50
kono
parents: 37
diff changeset
160 tree_print_t(int e,int t)
kono
parents: 37
diff changeset
161 {
kono
parents: 37
diff changeset
162 printf("# type: ");
kono
parents: 37
diff changeset
163 tree_print(t);
kono
parents: 37
diff changeset
164 printf("expr: ");
kono
parents: 37
diff changeset
165 tree_print(e);
kono
parents: 37
diff changeset
166 printf("\n");
kono
parents: 37
diff changeset
167 }
kono
parents: 37
diff changeset
168
kono
parents: 37
diff changeset
169 void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
170 tree_print(int e)
d35df41eac69 Initial revision
kono
parents:
diff changeset
171 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
172 printf("* generate code on type:\n* ");
d35df41eac69 Initial revision
kono
parents:
diff changeset
173 tree_parse(type);
d35df41eac69 Initial revision
kono
parents:
diff changeset
174 printf("\n* expr:\n* ");
d35df41eac69 Initial revision
kono
parents:
diff changeset
175 tree_parse(e);
d35df41eac69 Initial revision
kono
parents:
diff changeset
176 printf("\n");
d35df41eac69 Initial revision
kono
parents:
diff changeset
177 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
178
18
df7fa8cee67b pass -Wall
kono
parents: 1
diff changeset
179 static
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
180 int tree_level;
d35df41eac69 Initial revision
kono
parents:
diff changeset
181
18
df7fa8cee67b pass -Wall
kono
parents: 1
diff changeset
182 void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
183 tree_parse(int e)
d35df41eac69 Initial revision
kono
parents:
diff changeset
184 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
185 tree_node_type *t;
d35df41eac69 Initial revision
kono
parents:
diff changeset
186 int i,j;
d35df41eac69 Initial revision
kono
parents:
diff changeset
187 char *s;
d35df41eac69 Initial revision
kono
parents:
diff changeset
188
d35df41eac69 Initial revision
kono
parents:
diff changeset
189 if(e<0) {
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
190 t=find_node(e);
254a0c576114 argument type list
kono
parents: 50
diff changeset
191 if(t->tree_type==e) {
254a0c576114 argument type list
kono
parents: 50
diff changeset
192 for(j=0;j<tree_level;j++) putchar(' ');
254a0c576114 argument type list
kono
parents: 50
diff changeset
193 printf("list(%s)",t->tree_name);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
194 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
195 } else {
d35df41eac69 Initial revision
kono
parents:
diff changeset
196 i = car(e);
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
197 t=find_node(e);
254a0c576114 argument type list
kono
parents: 50
diff changeset
198 if(t->tree_type==i) {
254a0c576114 argument type list
kono
parents: 50
diff changeset
199 tree_level++;
254a0c576114 argument type list
kono
parents: 50
diff changeset
200 for(j=0;j<tree_level;j++) putchar(' ');
254a0c576114 argument type list
kono
parents: 50
diff changeset
201 printf("list(%s",t->tree_name);
254a0c576114 argument type list
kono
parents: 50
diff changeset
202 for(i=1,s=t->tree_args;*s;s++,i++) {
254a0c576114 argument type list
kono
parents: 50
diff changeset
203 switch(*s) {
254a0c576114 argument type list
kono
parents: 50
diff changeset
204 case 'e':
254a0c576114 argument type list
kono
parents: 50
diff changeset
205 case 't':
254a0c576114 argument type list
kono
parents: 50
diff changeset
206 printf(",\n*");
254a0c576114 argument type list
kono
parents: 50
diff changeset
207 tree_parse(heap[e+i]); break;
254a0c576114 argument type list
kono
parents: 50
diff changeset
208 case 'v':
254a0c576114 argument type list
kono
parents: 50
diff changeset
209 printf(",%d",heap[e+i]); break;
254a0c576114 argument type list
kono
parents: 50
diff changeset
210 case 'n':
254a0c576114 argument type list
kono
parents: 50
diff changeset
211 printf(",%s",((NMTBL *)heap[e+i])->nm); break;
254a0c576114 argument type list
kono
parents: 50
diff changeset
212 case 's':
254a0c576114 argument type list
kono
parents: 50
diff changeset
213 printf(",%s",(char *)heap[e+i]); break;
254a0c576114 argument type list
kono
parents: 50
diff changeset
214 case 'i':
254a0c576114 argument type list
kono
parents: 50
diff changeset
215 printf(",%d",heap[e+i]); break;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
216 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
217 }
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
218 tree_level--;
254a0c576114 argument type list
kono
parents: 50
diff changeset
219 printf(")");
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
220 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
221 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
222 }
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
223
254a0c576114 argument type list
kono
parents: 50
diff changeset
224 tree_node_type *
254a0c576114 argument type list
kono
parents: 50
diff changeset
225 find_node(int e) {
254a0c576114 argument type list
kono
parents: 50
diff changeset
226 int e1,e2;
254a0c576114 argument type list
kono
parents: 50
diff changeset
227 int first=0;
254a0c576114 argument type list
kono
parents: 50
diff changeset
228 int last=sizeof(tree_nodes)/sizeof(tree_node_type);
254a0c576114 argument type list
kono
parents: 50
diff changeset
229 e2=-1;
254a0c576114 argument type list
kono
parents: 50
diff changeset
230 while (first!=last) {
254a0c576114 argument type list
kono
parents: 50
diff changeset
231 e1 = (first+last)/2;
254a0c576114 argument type list
kono
parents: 50
diff changeset
232 if(e2==e1)
254a0c576114 argument type list
kono
parents: 50
diff changeset
233 return 0;
254a0c576114 argument type list
kono
parents: 50
diff changeset
234 e2=e1;
254a0c576114 argument type list
kono
parents: 50
diff changeset
235 if (tree_nodes[e1].tree_type>e)
254a0c576114 argument type list
kono
parents: 50
diff changeset
236 last = e1;
254a0c576114 argument type list
kono
parents: 50
diff changeset
237 else if (tree_nodes[e1].tree_type==e)
254a0c576114 argument type list
kono
parents: 50
diff changeset
238 break;
254a0c576114 argument type list
kono
parents: 50
diff changeset
239 else if (tree_nodes[e1].tree_type<e)
254a0c576114 argument type list
kono
parents: 50
diff changeset
240 first = e1;
254a0c576114 argument type list
kono
parents: 50
diff changeset
241 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
242 return &tree_nodes[e1];
254a0c576114 argument type list
kono
parents: 50
diff changeset
243 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
244
254a0c576114 argument type list
kono
parents: 50
diff changeset
245 void struct_type_print(int type,FILE *out)
254a0c576114 argument type list
kono
parents: 50
diff changeset
246 {
254a0c576114 argument type list
kono
parents: 50
diff changeset
247 NMTBL *n;
254a0c576114 argument type list
kono
parents: 50
diff changeset
248 int tags;
254a0c576114 argument type list
kono
parents: 50
diff changeset
249 if((n=(NMTBL*)cadddr(type))) {
254a0c576114 argument type list
kono
parents: 50
diff changeset
250 fprintf(out,"%s ",n->nm);
254a0c576114 argument type list
kono
parents: 50
diff changeset
251 return;
254a0c576114 argument type list
kono
parents: 50
diff changeset
252 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
253 if((tags=caddr(type))) {
254a0c576114 argument type list
kono
parents: 50
diff changeset
254 fprintf(out,"{");
254a0c576114 argument type list
kono
parents: 50
diff changeset
255 while(tags) {
254a0c576114 argument type list
kono
parents: 50
diff changeset
256 n=(NMTBL*)caddr(tags);
254a0c576114 argument type list
kono
parents: 50
diff changeset
257 type_print(car(tags),n,out);
254a0c576114 argument type list
kono
parents: 50
diff changeset
258 fprintf(out,";");
254a0c576114 argument type list
kono
parents: 50
diff changeset
259 tags = cadr(tags);
254a0c576114 argument type list
kono
parents: 50
diff changeset
260 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
261 fprintf(out,"}");
254a0c576114 argument type list
kono
parents: 50
diff changeset
262 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
263 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
264
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
265 void function_type_print1(int type,NMTBL *n,FILE *out,int cont)
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
266 {
254a0c576114 argument type list
kono
parents: 50
diff changeset
267 int args;
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
268 type_print1(cadr(type),0,out,cont);
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
269 if(n) fprintf(out," %s",n->nm);
254a0c576114 argument type list
kono
parents: 50
diff changeset
270 fprintf(out,"(");
254a0c576114 argument type list
kono
parents: 50
diff changeset
271 if((args=caddr(type))) {
254a0c576114 argument type list
kono
parents: 50
diff changeset
272 while (args) {
254a0c576114 argument type list
kono
parents: 50
diff changeset
273 type_print(car(args),0,out);
254a0c576114 argument type list
kono
parents: 50
diff changeset
274 args=cadr(args);
254a0c576114 argument type list
kono
parents: 50
diff changeset
275 if (args) fprintf(out,",");
254a0c576114 argument type list
kono
parents: 50
diff changeset
276 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
277 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
278 fprintf(out,")");
254a0c576114 argument type list
kono
parents: 50
diff changeset
279 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
280
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
281 void function_type_print(int type,NMTBL *n,FILE *out)
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
282 {
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
283 function_type_print1(type,n,out,0);
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
284 }
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
285
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
286 void sym_print(int sym,FILE *out)
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
287 {
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
288 tree_node_type *tn;
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
289 if (!(tn=find_node(sym))) { error(-1); return; }
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
290 fprintf(out,"%s",tn->tree_name);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
291 }
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
292
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
293 NMTBL *
72
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
294 typedef_search(t,type)
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
295 {
2e84590720a6 typedef name
kono
parents: 69
diff changeset
296 while(t) {
2e84590720a6 typedef name
kono
parents: 69
diff changeset
297 if (((NMTBL*)car(t))->ty==type)
2e84590720a6 typedef name
kono
parents: 69
diff changeset
298 return (NMTBL*)car(t);
2e84590720a6 typedef name
kono
parents: 69
diff changeset
299 t=cadr(t);
2e84590720a6 typedef name
kono
parents: 69
diff changeset
300 }
2e84590720a6 typedef name
kono
parents: 69
diff changeset
301 return 0;
2e84590720a6 typedef name
kono
parents: 69
diff changeset
302 }
2e84590720a6 typedef name
kono
parents: 69
diff changeset
303
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
304 void type_print1(int type,NMTBL *n,FILE *out,int cont)
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
305 {
254a0c576114 argument type list
kono
parents: 50
diff changeset
306 int t;
254a0c576114 argument type list
kono
parents: 50
diff changeset
307 tree_node_type *tn;
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
308 NMTBL *td;
72
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
309 int args;
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
310
75
92dcf107a837 c code output
kono
parents: 74
diff changeset
311 if(type>0&&(td=typedef_search(typedefed,type))) {
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
312 if (!cont)
72
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
313 fprintf(out,"%s ",td->nm);
75
92dcf107a837 c code output
kono
parents: 74
diff changeset
314 } else if(type>0&&(td=typedef_search(gtypedefed,type))) {
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
315 if (!cont)
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
316 fprintf(out,"%s ",td->nm);
2e84590720a6 typedef name
kono
parents: 69
diff changeset
317 } else if (type<0) {
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
318 t=type;
254a0c576114 argument type list
kono
parents: 50
diff changeset
319 if (!(tn=find_node(t))) { error(-1); return; }
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
320 if (!cont)
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
321 fprintf(out,"%s ",tn->tree_name);
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
322 } else if ((t=car(type))) {
254a0c576114 argument type list
kono
parents: 50
diff changeset
323 if (!(tn=find_node(t))) { error(-1); return; }
254a0c576114 argument type list
kono
parents: 50
diff changeset
324 if(t==STRUCT||t==UNION) {
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
325 if (!cont) {
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
326 fprintf(out,"%s ",tn->tree_name);
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
327 struct_type_print(type,out);
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
328 }
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
329 } else if(t==CODE) {
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
330 if (!cont) {
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
331 fprintf(out,"%s ",tn->tree_name);
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
332 }
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
333 function_type_print1(type,n,out,cont);
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
334 return;
254a0c576114 argument type list
kono
parents: 50
diff changeset
335 } else if(t==FUNCTION) {
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
336 function_type_print1(type,n,out,cont);
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
337 return;
254a0c576114 argument type list
kono
parents: 50
diff changeset
338 } else if(t==ARRAY) {
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
339 type_print1(cadr(type),n,out,cont);
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
340 if (caddr(type))
2e84590720a6 typedef name
kono
parents: 69
diff changeset
341 fprintf(out,"[%d]",caddr(type));
2e84590720a6 typedef name
kono
parents: 69
diff changeset
342 else
2e84590720a6 typedef name
kono
parents: 69
diff changeset
343 fprintf(out,"[]");
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
344 return;
254a0c576114 argument type list
kono
parents: 50
diff changeset
345 } else if(t==POINTER) {
254a0c576114 argument type list
kono
parents: 50
diff changeset
346 t=cadr(type);
254a0c576114 argument type list
kono
parents: 50
diff changeset
347 if(car(t)==FUNCTION) {
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
348 type_print1(cadr(t),0,out,cont);
72
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
349 fprintf(out,"(*");
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
350 if(n) fprintf(out,"%s",n->nm);
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
351 fprintf(out,")");
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
352 fprintf(out,"(");
72
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
353 if((args=caddr(t))) {
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
354 while (args) {
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
355 type_print(car(args),0,out);
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
356 args=cadr(args);
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
357 if (args) fprintf(out,",");
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
358 }
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
359 }
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
360 fprintf(out,")");
72
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
361 return;
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
362 } else if(car(t)==ARRAY) {
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
363 fprintf(out,"(*");
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
364 type_print(cadr(t),n,out);
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
365 if (caddr(type))
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
366 fprintf(out,")[%d]",caddr(type));
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
367 else
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
368 fprintf(out,")[]");
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
369 return;
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
370 } else {
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
371 type_print1(t,0,out,cont);
72
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
372 fprintf(out,"*");
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
373 }
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
374 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
375 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
376 if(n) fprintf(out,"%s",n->nm);
254a0c576114 argument type list
kono
parents: 50
diff changeset
377 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
378
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
379 void type_print(int type,NMTBL *n,FILE *out)
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
380 {
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
381 type_print1(type,n,out,0);
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
382 }
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
383
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
384 /* end */