Mercurial > hg > CbC > old > device
comparison mc-tree.c @ 72:3b5d293cea36
type def etc
author | kono |
---|---|
date | Mon, 24 Feb 2003 16:04:30 +0900 |
parents | 2e84590720a6 |
children | 6de658ae384c |
comparison
equal
deleted
inserted
replaced
71:be313430f90b | 72:3b5d293cea36 |
---|---|
283 if (!(tn=find_node(sym))) { error(-1); return; } | 283 if (!(tn=find_node(sym))) { error(-1); return; } |
284 fprintf(out,"%s",tn->tree_name); | 284 fprintf(out,"%s",tn->tree_name); |
285 } | 285 } |
286 | 286 |
287 NMTBL * | 287 NMTBL * |
288 typedef_search(type) | 288 typedef_search(t,type) |
289 { | 289 { |
290 int t = typedefed; | |
291 while(t) { | 290 while(t) { |
292 if (((NMTBL*)car(t))->ty==type) | 291 if (((NMTBL*)car(t))->ty==type) |
293 return (NMTBL*)car(t); | 292 return (NMTBL*)car(t); |
294 t=cadr(t); | 293 t=cadr(t); |
295 } | 294 } |
299 void type_print(int type,NMTBL *n,FILE *out) | 298 void type_print(int type,NMTBL *n,FILE *out) |
300 { | 299 { |
301 int t; | 300 int t; |
302 tree_node_type *tn; | 301 tree_node_type *tn; |
303 NMTBL *td; | 302 NMTBL *td; |
304 | 303 int args; |
305 if(typedefed && (td=typedef_search(type))) { | 304 |
305 if((td=typedef_search(typedefed,type))) { | |
306 fprintf(out,"%s ",td->nm); | |
307 } else if((td=typedef_search(gtypedefed,type))) { | |
306 fprintf(out,"%s ",td->nm); | 308 fprintf(out,"%s ",td->nm); |
307 } else if (type<0) { | 309 } else if (type<0) { |
308 t=type; | 310 t=type; |
309 if (!(tn=find_node(t))) { error(-1); return; } | 311 if (!(tn=find_node(t))) { error(-1); return; } |
310 fprintf(out,"%s ",tn->tree_name); | 312 fprintf(out,"%s ",tn->tree_name); |
328 fprintf(out,"[]"); | 330 fprintf(out,"[]"); |
329 return; | 331 return; |
330 } else if(t==POINTER) { | 332 } else if(t==POINTER) { |
331 t=cadr(type); | 333 t=cadr(type); |
332 if(car(t)==FUNCTION) { | 334 if(car(t)==FUNCTION) { |
335 type_print(cadr(t),0,out); | |
336 fprintf(out,"(*"); | |
337 if(n) fprintf(out,"%s",n->nm); | |
338 fprintf(out,")"); | |
333 fprintf(out,"("); | 339 fprintf(out,"("); |
340 if((args=caddr(t))) { | |
341 while (args) { | |
342 type_print(car(args),0,out); | |
343 args=cadr(args); | |
344 if (args) fprintf(out,","); | |
345 } | |
346 } | |
347 fprintf(out,")"); | |
348 return; | |
349 } else if(car(t)==ARRAY) { | |
350 fprintf(out,"(*"); | |
351 type_print(cadr(t),n,out); | |
352 if (caddr(type)) | |
353 fprintf(out,")[%d]",caddr(type)); | |
354 else | |
355 fprintf(out,")[]"); | |
356 return; | |
357 } else { | |
334 type_print(t,0,out); | 358 type_print(t,0,out); |
335 fprintf(out,")"); | 359 fprintf(out,"*"); |
336 } else | 360 } |
337 type_print(t,0,out); | |
338 fprintf(out,"*"); | |
339 } | 361 } |
340 } | 362 } |
341 if(n) fprintf(out,"%s",n->nm); | 363 if(n) fprintf(out,"%s",n->nm); |
342 } | 364 } |
343 | 365 |