1
|
1 /* Micro-C tree print routine */
|
607
|
2
|
|
3 /************************************************************************
|
|
4 ** Copyright (C) 2006 Shinji Kono
|
|
5 ** 連絡先: 琉球大学情報工学科 河野 真治
|
|
6 ** (E-Mail Address: kono@ie.u-ryukyu.ac.jp)
|
|
7 **
|
|
8 ** このソースのいかなる複写,改変,修正も許諾します。ただし、
|
|
9 ** その際には、誰が貢献したを示すこの部分を残すこと。
|
|
10 ** 再配布や雑誌の付録などの問い合わせも必要ありません。
|
|
11 ** 営利利用も上記に反しない範囲で許可します。
|
|
12 ** バイナリの配布の際にはversion messageを保存することを条件とします。
|
|
13 ** このプログラムについては特に何の保証もしない、悪しからず。
|
|
14 **
|
|
15 ** Everyone is permitted to do anything on this program
|
|
16 ** including copying, modifying, improving,
|
|
17 ** as long as you don't try to pretend that you wrote it.
|
|
18 ** i.e., the above copyright notice has to appear in all copies.
|
|
19 ** Binary distribution requires original version messages.
|
|
20 ** You don't have to ask before copying, redistribution or publishing.
|
|
21 ** THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
|
|
22 ***********************************************************************/
|
1
|
23
|
327
|
24 #include <stdio.h>
|
0
|
25 #include "mc.h"
|
327
|
26 #include "mc-parse.h"
|
596
|
27 #include "mc-codegen.h"
|
0
|
28
|
|
29 typedef
|
|
30 struct tree_node {
|
|
31 int tree_type;
|
|
32 char *tree_name;
|
|
33 char *tree_args;
|
|
34 } tree_node_type;
|
|
35
|
67
|
36 extern void tree_print(int e);
|
|
37 extern void tree_parse(int e);
|
|
38 extern void tree_print_t(int e,int t);
|
|
39 static tree_node_type * find_node(int e);
|
|
40 extern void type_print(int type,NMTBL *n,FILE *out);
|
74
|
41 extern void type_print1(int type,NMTBL *n,FILE *out,int cont);
|
68
|
42 extern void sym_print(int type,FILE *out);
|
67
|
43
|
|
44 /* ascendant order for binary search */
|
|
45
|
18
|
46 static
|
0
|
47 tree_node_type tree_nodes[] = {
|
562
|
48 {DOTS,"...",""},
|
|
49 {LMACRO,"lmacro",""},
|
|
50 {FMACRO,"fmacro",""},
|
|
51 {KONST,"const",""},
|
|
52 {DEFINED,"defined",""},
|
|
53 {ENVIRONMENT,"environment",""},
|
|
54 {CODE,"code",""},
|
|
55 {REGISTER,"register",""},
|
609
|
56 {ASM,"__asm__",""},
|
562
|
57 {VOID,"void",""},
|
|
58 {EXTRN,"extern",""},
|
|
59 {SHORT,"short",""},
|
563
|
60 {USHORT,"unsigned short",""},
|
562
|
61 {LONG,"long",""},
|
|
62 {TYPE,"type",""},
|
609
|
63 {VOLATILE,"volatile",""},
|
562
|
64 {SIZEOF,"sizeof",""},
|
|
65 {TYPEDEF,"typedef",""},
|
|
66 {FLABEL,"flabel",""},
|
|
67 {BLABEL,"blabel",""},
|
|
68 {MACRO,"macro",""},
|
|
69 {STRING,"string",""},
|
|
70 {IDENT,"ident",""},
|
|
71 {FIELD,"field",""},
|
|
72 {TAG,"tag",""},
|
|
73 {RESERVE,"reserve",""},
|
|
74 {DEFAULT,"default",""},
|
609
|
75 {ATTRIBUTE,"__attribute__",""},
|
562
|
76 {CASE,"case",""},
|
|
77 {SWITCH,"switch",""},
|
|
78 {WHILE,"while",""},
|
|
79 {DO,"do",""},
|
|
80 {FOR,"for",""},
|
|
81 {ELSE,"else",""},
|
|
82 {IF,"if",""},
|
|
83 {CONTINUE,"continue",""},
|
|
84 {BREAK,"break",""},
|
|
85 {RETURN,"return",""},
|
|
86 {GOTO,"goto",""},
|
|
87 {STATIC,"static",""},
|
|
88 {EMPTY,"empty",""},
|
|
89 {FUNCTION,"function","t"},
|
|
90 {UNION,"union",""},
|
|
91 {STRUCT,"struct","vt"},
|
|
92 {ARRAY,"array","tv"},
|
563
|
93 {POINTER,"*","t"},
|
562
|
94 {UNSIGNED,"unsigned",""},
|
563
|
95 {INLINE,"inline",""},
|
|
96 {SIGNED,"signed",""},
|
562
|
97 {CHAR,"char",""},
|
563
|
98 {UCHAR,"unsigned char",""},
|
562
|
99 {INT,"int",""},
|
563
|
100 {FLOAT,"float",""},
|
|
101 {DOUBLE,"double",""},
|
|
102 {LONGLONG,"long long",""},
|
|
103 {ULONGLONG,"unsigned long long",""},
|
37
|
104
|
562
|
105 {GVAR,"gvar","vs"},
|
|
106 {RGVAR,"rgvar","vs"},
|
|
107 {CRGVAR,"crgvar","vs"},
|
|
108 {LVAR,"lvar","v"},
|
|
109 {RLVAR,"rlvar","v"},
|
|
110 {CRLVAR,"crlvar","v"},
|
|
111 {CONST,"const","v"},
|
|
112 {FNAME,"fname","n"},
|
|
113 {MUL,"*","e"},
|
|
114 {RINDIRECT,"rindirect","e"},
|
|
115 {CRINDIRECT,"crindirect","e"},
|
|
116 {BAND,"&","e"},
|
|
117 {MINUS,"-","e"},
|
|
118 {LNOT,"!","e"},
|
|
119 {BNOT,"~","e"},
|
|
120 {INC,"++",""},
|
|
121 {POSTINC,"postinc","e"},
|
|
122 {PREINC,"preinc","e"},
|
|
123 {CPOSTINC,"cpostinc","e"},
|
|
124 {CPREINC,"cpreinc","e"},
|
|
125 {DEC,"--",""},
|
|
126 {DIV,"/","ee"},
|
|
127 {UDIV,"/","ee"},
|
|
128 {MUL,"*","ee"},
|
|
129 {UMUL,"*","ee"},
|
|
130 {MOD,"%","ee"},
|
|
131 {UMOD,"%","ee"},
|
|
132 {ADD,"+","ee"},
|
|
133 {SUB,"-","ee"},
|
|
134 {RSHIFT,">>","ee"},
|
|
135 {URSHIFT,">>","ee"},
|
|
136 {LSHIFT,"<<","ee"},
|
|
137 {ULSHIFT,"<<","ee"},
|
|
138 {GT,">","ee"},
|
|
139 {UGT,">","ee"},
|
|
140 {GE,">=","ee"},
|
|
141 {UGE,">=","ee"},
|
|
142 {LT,"<","ee"},
|
|
143 {ULT,"<","ee"},
|
|
144 {LE,"<=","ee"},
|
|
145 {ULE,"<=","ee"},
|
|
146 {EQ,"==","ee"},
|
|
147 {NEQ,"!=","ee"},
|
|
148 {BAND,"&","ee"},
|
|
149 {EOR,"^","ee"},
|
|
150 {BOR,"|","ee"},
|
|
151 {LAND,"&&","ee"},
|
|
152 {LOR,"||","ee"},
|
563
|
153 {COND,"?","eee"},
|
|
154 {ASS,"=","ee"},
|
562
|
155 {ASSOP,"assop","eev"},
|
|
156 {CASSOP,"cassop","eev"},
|
|
157 {COMMA,",","ee"},
|
|
158 {LPAR,"(",""},
|
|
159 {RPAR,")",""},
|
|
160 {LBRA,"[",""},
|
|
161 {RBRA,"]",""},
|
|
162 {LC,"{",""},
|
|
163 {RC,"}",""},
|
|
164 {COLON,":","ee"},
|
|
165 {SM,";",""},
|
|
166 {PERIOD,".",""},
|
|
167 {ARROW,"->",""},
|
|
168 {SASS,"sass",""},
|
|
169 {RSTRUCT,"rstruct",""},
|
|
170 {AS+MUL,"*=","ee"},
|
|
171 {AS+UMUL,"*=","ee"},
|
|
172 {AS+DIV,"/=","ee"},
|
|
173 {AS+UDIV,"/=","ee"},
|
|
174 {AS+MOD,"%=","ee"},
|
|
175 {AS+UMOD,"%=","ee"},
|
|
176 {AS+ADD,"+=","ee"},
|
|
177 {AS+MINUS,"-=","ee"},
|
|
178 {AS+RSHIFT,">>=","ee"},
|
|
179 {AS+URSHIFT,">>=","ee"},
|
|
180 {AS+LSHIFT,"<<=","ee"},
|
|
181 {AS+ULSHIFT,"<<=","ee"},
|
|
182 {AS+BAND,"&=","ee"},
|
|
183 {AS+EOR,"^=","ee"},
|
|
184 {AS+BOR,"|=","ee"},
|
0
|
185 };
|
|
186
|
564
|
187 static int
|
|
188 attr_print(int t)
|
|
189 {
|
|
190 while (t>0 && car(t)==ATTRIBUTE) {
|
|
191 switch (caddr(t)) {
|
|
192 case KONST: printf( "const"); break;
|
|
193 case VOLATILE: printf( "volatile"); break;
|
|
194 case RESTRICT: printf( "restrict"); break;
|
|
195 case INLINE: printf( "inline"); break;
|
|
196 }
|
|
197 t = cadr(t);
|
|
198 }
|
|
199 return t;
|
|
200 }
|
|
201
|
18
|
202 void
|
50
|
203 tree_print_t(int e,int t)
|
|
204 {
|
|
205 printf("# type: ");
|
|
206 tree_print(t);
|
|
207 printf("expr: ");
|
|
208 tree_print(e);
|
|
209 printf("\n");
|
|
210 }
|
|
211
|
|
212 void
|
0
|
213 tree_print(int e)
|
|
214 {
|
|
215 printf("* generate code on type:\n* ");
|
|
216 tree_parse(type);
|
|
217 printf("\n* expr:\n* ");
|
|
218 tree_parse(e);
|
|
219 printf("\n");
|
|
220 }
|
|
221
|
18
|
222 static
|
0
|
223 int tree_level;
|
|
224
|
18
|
225 void
|
0
|
226 tree_parse(int e)
|
|
227 {
|
|
228 tree_node_type *t;
|
|
229 int i,j;
|
|
230 char *s;
|
|
231
|
|
232 if(e<0) {
|
67
|
233 t=find_node(e);
|
|
234 if(t->tree_type==e) {
|
|
235 for(j=0;j<tree_level;j++) putchar(' ');
|
|
236 printf("list(%s)",t->tree_name);
|
0
|
237 }
|
|
238 } else {
|
|
239 i = car(e);
|
67
|
240 t=find_node(e);
|
|
241 if(t->tree_type==i) {
|
|
242 tree_level++;
|
|
243 for(j=0;j<tree_level;j++) putchar(' ');
|
|
244 printf("list(%s",t->tree_name);
|
|
245 for(i=1,s=t->tree_args;*s;s++,i++) {
|
|
246 switch(*s) {
|
|
247 case 'e':
|
|
248 case 't':
|
|
249 printf(",\n*");
|
|
250 tree_parse(heap[e+i]); break;
|
|
251 case 'v':
|
|
252 printf(",%d",heap[e+i]); break;
|
|
253 case 'n':
|
|
254 printf(",%s",((NMTBL *)heap[e+i])->nm); break;
|
|
255 case 's':
|
|
256 printf(",%s",(char *)heap[e+i]); break;
|
|
257 case 'i':
|
|
258 printf(",%d",heap[e+i]); break;
|
0
|
259 }
|
|
260 }
|
67
|
261 tree_level--;
|
|
262 printf(")");
|
0
|
263 }
|
|
264 }
|
|
265 }
|
67
|
266
|
|
267 tree_node_type *
|
|
268 find_node(int e) {
|
|
269 int e1,e2;
|
|
270 int first=0;
|
|
271 int last=sizeof(tree_nodes)/sizeof(tree_node_type);
|
563
|
272 // e2=-1;
|
599
|
273 e2=OP(e);
|
563
|
274 e1=0;
|
67
|
275 while (first!=last) {
|
562
|
276 #if 0
|
67
|
277 e1 = (first+last)/2;
|
|
278 if(e2==e1)
|
|
279 return 0;
|
|
280 e2=e1;
|
|
281 if (tree_nodes[e1].tree_type>e)
|
|
282 last = e1;
|
|
283 else if (tree_nodes[e1].tree_type==e)
|
|
284 break;
|
|
285 else if (tree_nodes[e1].tree_type<e)
|
|
286 first = e1;
|
562
|
287 #else
|
563
|
288 if (tree_nodes[first].tree_type==e2)
|
|
289 return &tree_nodes[first];
|
562
|
290 first++;
|
|
291 #endif
|
67
|
292 }
|
563
|
293 fprintf(stderr,"Unknown ID %d [%d]in find note\n",e2,e);
|
67
|
294 return &tree_nodes[e1];
|
|
295 }
|
|
296
|
|
297 void struct_type_print(int type,FILE *out)
|
|
298 {
|
|
299 NMTBL *n;
|
|
300 int tags;
|
|
301 if((n=(NMTBL*)cadddr(type))) {
|
|
302 fprintf(out,"%s ",n->nm);
|
|
303 return;
|
|
304 }
|
|
305 if((tags=caddr(type))) {
|
|
306 fprintf(out,"{");
|
|
307 while(tags) {
|
|
308 n=(NMTBL*)caddr(tags);
|
|
309 type_print(car(tags),n,out);
|
|
310 fprintf(out,";");
|
|
311 tags = cadr(tags);
|
|
312 }
|
|
313 fprintf(out,"}");
|
|
314 }
|
|
315 }
|
|
316
|
74
|
317 void function_type_print1(int type,NMTBL *n,FILE *out,int cont)
|
67
|
318 {
|
|
319 int args;
|
74
|
320 type_print1(cadr(type),0,out,cont);
|
67
|
321 if(n) fprintf(out," %s",n->nm);
|
|
322 fprintf(out,"(");
|
|
323 if((args=caddr(type))) {
|
|
324 while (args) {
|
|
325 type_print(car(args),0,out);
|
|
326 args=cadr(args);
|
|
327 if (args) fprintf(out,",");
|
|
328 }
|
|
329 }
|
|
330 fprintf(out,")");
|
|
331 }
|
|
332
|
74
|
333 void function_type_print(int type,NMTBL *n,FILE *out)
|
|
334 {
|
|
335 function_type_print1(type,n,out,0);
|
|
336 }
|
|
337
|
68
|
338 void sym_print(int sym,FILE *out)
|
|
339 {
|
|
340 tree_node_type *tn;
|
|
341 if (!(tn=find_node(sym))) { error(-1); return; }
|
|
342 fprintf(out,"%s",tn->tree_name);
|
|
343 }
|
|
344
|
70
|
345 NMTBL *
|
468
|
346 typedef_search(int t,int type)
|
70
|
347 {
|
|
348 while(t) {
|
|
349 if (((NMTBL*)car(t))->ty==type)
|
|
350 return (NMTBL*)car(t);
|
|
351 t=cadr(t);
|
|
352 }
|
|
353 return 0;
|
|
354 }
|
|
355
|
564
|
356 static void n_attr_print(int attr, FILE *out)
|
|
357 {
|
|
358 for(;attr;attr=cadr(attr)) {
|
|
359 switch(car(attr)) {
|
|
360 case INLINE: fprintf(out,"inline "); break;
|
|
361 case CONST: fprintf(out,"const "); break;
|
|
362 case VOLATILE: fprintf(out,"const "); break;
|
|
363 case RESTRICT: fprintf(out,"const "); break;
|
|
364 }
|
|
365 }
|
|
366 }
|
|
367
|
74
|
368 void type_print1(int type,NMTBL *n,FILE *out,int cont)
|
67
|
369 {
|
|
370 int t;
|
|
371 tree_node_type *tn;
|
70
|
372 NMTBL *td;
|
72
|
373 int args;
|
70
|
374
|
564
|
375 if (n) {
|
|
376 if (n->attr) n_attr_print(n->attr,out);
|
|
377 while(type>0 && car(type)==ATTRIBUTE) type=cadr(type);
|
|
378 } else
|
|
379 type = attr_print(type);
|
75
|
380 if(type>0&&(td=typedef_search(typedefed,type))) {
|
74
|
381 if (!cont)
|
72
|
382 fprintf(out,"%s ",td->nm);
|
75
|
383 } else if(type>0&&(td=typedef_search(gtypedefed,type))) {
|
74
|
384 if (!cont)
|
70
|
385 fprintf(out,"%s ",td->nm);
|
|
386 } else if (type<0) {
|
67
|
387 t=type;
|
|
388 if (!(tn=find_node(t))) { error(-1); return; }
|
74
|
389 if (!cont)
|
|
390 fprintf(out,"%s ",tn->tree_name);
|
67
|
391 } else if ((t=car(type))) {
|
|
392 if (!(tn=find_node(t))) { error(-1); return; }
|
|
393 if(t==STRUCT||t==UNION) {
|
74
|
394 if (!cont) {
|
|
395 fprintf(out,"%s ",tn->tree_name);
|
|
396 struct_type_print(type,out);
|
|
397 }
|
67
|
398 } else if(t==CODE) {
|
596
|
399 // if (!cont) { fprintf(out,"%s ",tn->tree_name); }
|
74
|
400 function_type_print1(type,n,out,cont);
|
67
|
401 return;
|
|
402 } else if(t==FUNCTION) {
|
74
|
403 function_type_print1(type,n,out,cont);
|
67
|
404 return;
|
|
405 } else if(t==ARRAY) {
|
74
|
406 type_print1(cadr(type),n,out,cont);
|
70
|
407 if (caddr(type))
|
|
408 fprintf(out,"[%d]",caddr(type));
|
|
409 else
|
|
410 fprintf(out,"[]");
|
67
|
411 return;
|
|
412 } else if(t==POINTER) {
|
|
413 t=cadr(type);
|
563
|
414 if(t<0) {
|
|
415 type_print1(t,0,out,cont);
|
|
416 fprintf(out,"*");
|
|
417 } else if(car(t)==FUNCTION) {
|
74
|
418 type_print1(cadr(t),0,out,cont);
|
72
|
419 fprintf(out,"(*");
|
|
420 if(n) fprintf(out,"%s",n->nm);
|
|
421 fprintf(out,")");
|
67
|
422 fprintf(out,"(");
|
72
|
423 if((args=caddr(t))) {
|
|
424 while (args) {
|
|
425 type_print(car(args),0,out);
|
|
426 args=cadr(args);
|
|
427 if (args) fprintf(out,",");
|
|
428 }
|
|
429 }
|
67
|
430 fprintf(out,")");
|
72
|
431 return;
|
596
|
432 } else if(car(t)==CODE) {
|
|
433 type_print1(cadr(t),0,out,cont);
|
|
434 fprintf(out,"(*");
|
|
435 if(n) fprintf(out,"%s",n->nm);
|
|
436 fprintf(out,")");
|
|
437 fprintf(out,"(");
|
|
438 if((args=caddr(t))) {
|
|
439 while (args) {
|
|
440 type_print(car(args),0,out);
|
|
441 args=cadr(args);
|
|
442 if (args) fprintf(out,",");
|
|
443 }
|
|
444 }
|
|
445 fprintf(out,")");
|
|
446 return;
|
72
|
447 } else if(car(t)==ARRAY) {
|
|
448 fprintf(out,"(*");
|
|
449 type_print(cadr(t),n,out);
|
|
450 if (caddr(type))
|
|
451 fprintf(out,")[%d]",caddr(type));
|
|
452 else
|
|
453 fprintf(out,")[]");
|
|
454 return;
|
|
455 } else {
|
74
|
456 type_print1(t,0,out,cont);
|
72
|
457 fprintf(out,"*");
|
|
458 }
|
67
|
459 }
|
|
460 }
|
|
461 if(n) fprintf(out,"%s",n->nm);
|
|
462 }
|
|
463
|
74
|
464 void type_print(int type,NMTBL *n,FILE *out)
|
|
465 {
|
|
466 type_print1(type,n,out,0);
|
|
467 }
|
|
468
|
609
|
469 /*
|
|
470 parse tree を印刷する
|
|
471
|
|
472 正しく括弧とかを付けるアルゴリズムが不明...
|
|
473 先読みして、優先順位を判別する必要があるはず。
|
|
474 */
|
|
475
|
|
476 void
|
|
477 print_expr(int e, FILE *vout)
|
|
478 {
|
|
479 NMTBL *nptr,*n;
|
|
480
|
660
|
481 if (e==0) {
|
|
482 fprintf(vout,"()");
|
|
483 return;
|
|
484 }
|
609
|
485 switch (car(e)%SOP) {
|
|
486 case LVAR:
|
|
487 case RLVAR:
|
|
488 if ((nptr = (NMTBL*)caddr(e))) {
|
|
489 fprintf(vout,"%s",nptr->nm);
|
|
490 } else {
|
|
491 // anonymous variable
|
|
492 fprintf(vout,"_%d",caddr(e));
|
|
493 }
|
|
494 break;
|
|
495 case GVAR:
|
|
496 case RGVAR:
|
|
497 if ((nptr = (NMTBL*)caddr(e))) {
|
|
498 fprintf(vout,"%s",nptr->nm);
|
|
499 } else {
|
|
500 // anonymous variable
|
|
501 fprintf(vout,"_%d",caddr(e));
|
|
502 }
|
|
503 if (cadr(e)) {
|
|
504 // offset
|
|
505 // certainly this is wrong
|
|
506 fprintf(vout,"+%d",caddr(e));
|
|
507 }
|
|
508 break;
|
|
509 case REGISTER:
|
|
510 if ((nptr = (NMTBL*)caddr(e))) {
|
|
511 fprintf(vout,"%s",nptr->nm);
|
|
512 } else {
|
|
513 // anonymous register variable
|
|
514 fprintf(vout,"_%d",caddr(e));
|
|
515 }
|
|
516 break;
|
|
517 case IDENT:
|
|
518 nptr = (NMTBL*)cadr(e);
|
|
519 fprintf(vout,"%s",nptr->nm); break;
|
|
520 case CONST:
|
|
521 switch(car(e)) {
|
|
522 case CONST:
|
|
523 fprintf(vout,"%d",cadr(e)); break;
|
|
524 #if FLOAT_CODE
|
|
525 case FCONST:
|
|
526 fprintf(vout,"%g",dcadr(e)); break;
|
|
527 case DCONST:
|
|
528 fprintf(vout,"%g",dcadr(e)); break;
|
|
529 #endif
|
|
530 #if LONGLONG_CODE
|
|
531 case LCONST:
|
|
532 fprintf(vout,"%lld",lcadr(e)); break;
|
|
533 #endif
|
|
534 }
|
|
535 break;
|
|
536 case ADDRESS:
|
|
537 if (car(cadr(e))!=STRING) {
|
|
538 fprintf(vout,"&");
|
|
539 print_expr(cadr(e),vout);
|
|
540 break;
|
|
541 }
|
|
542 case STRING:
|
|
543 {
|
620
|
544 int c; char *s; int i;
|
|
545 nptr = (NMTBL*)cadr(e); s = nptr->nm;i=nptr->dsp;
|
609
|
546 fprintf(vout,"\"");
|
|
547 while(--i>0) {
|
|
548 c=*s++;
|
|
549 if(c=='\n') fprintf(vout,"\\n");
|
|
550 else if(c=='\r') fprintf(vout,"\\r");
|
|
551 else if(c=='\t') fprintf(vout,"\\t");
|
|
552 else if(c=='\e') fprintf(vout,"\\e");
|
|
553 else if(c=='"') fprintf(vout,"\\\"");
|
|
554 else if(c=='\\') fprintf(vout,"\\\\");
|
|
555 else if(!(' '<=c&&c<=0x7f)) fprintf(vout,"\\%03o",c);
|
|
556 else fprintf(vout,"%c",c);
|
|
557 }
|
|
558 fprintf(vout,"\"");
|
|
559 }
|
|
560 break;
|
|
561 case ARRAY:
|
|
562 print_expr(cadr(e),vout);
|
|
563 fprintf(vout,"[");
|
|
564 print_expr(caddr(e),vout);
|
|
565 fprintf(vout,"]");
|
|
566 break;
|
|
567 case PERIOD:
|
|
568 print_expr(cadr(e),vout);
|
|
569 n = (NMTBL*)caddr(e);
|
|
570 fprintf(vout,".%s",n->nm);
|
|
571 break;
|
|
572 case ARROW:
|
|
573 print_expr(cadr(e),vout);
|
|
574 n = (NMTBL*)caddr(e);
|
|
575 fprintf(vout,"->%s",n->nm);
|
|
576 break;
|
|
577 case INDIRECT:
|
|
578 case RINDIRECT:
|
|
579 fprintf(vout,"*");
|
|
580 print_expr(cadr(e),vout);
|
|
581 break;
|
|
582 case FNAME:
|
|
583 n = (NMTBL*)cadr(e);
|
|
584 fprintf(vout,"%s",n->nm);
|
|
585 break;
|
|
586 case ADD:
|
|
587 fprintf(vout,"(");
|
|
588 print_expr(cadr(e),vout);
|
|
589 fprintf(vout,"+");
|
|
590 print_expr(caddr(e),vout);
|
|
591 fprintf(vout,")");
|
|
592 break;
|
660
|
593 case RSTRUCT:
|
|
594 print_expr(cadr(e),vout);
|
|
595 break;
|
609
|
596 default:
|
|
597 error(-1);
|
|
598 }
|
|
599 }
|
|
600
|
67
|
601 /* end */
|