Mercurial > hg > CbC > old > device
changeset 74:6de658ae384c
*** empty log message ***
author | kono |
---|---|
date | Mon, 24 Feb 2003 17:18:48 +0900 |
parents | 2f613f0ef130 |
children | 92dcf107a837 |
files | conv/c.c mc-tree.c |
diffstat | 2 files changed, 32 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/conv/c.c Mon Feb 24 16:20:05 2003 +0900 +++ b/conv/c.c Mon Feb 24 17:18:48 2003 +0900 @@ -5,6 +5,7 @@ #include "conv/convdef.h" extern void type_print(int type,NMTBL *nptr,FILE *out); +extern void type_print1(int type,NMTBL *nptr,FILE *out,int cont); extern void sym_print(int type,FILE *out); static FILE *vout,*svout; @@ -354,33 +355,7 @@ void return_type_(int t,NMTBL *nptr,int cont){ - if (cont) { - /* type print に cont の機能を持たせるべきだよね - cont の場合は、配列/関数/ポインタまでは無視する(?) - (int(*)) a,*b; みたいな場合は? (えぇ?) - ってことは、context で、どこまで表示したかを覚えて - おく必要がある? もっとも自分で表示してしまった - はずだから、それを覚えていれば良いだけだけどね。 - */ - while (t>0&&car(t)==POINTER) { - fprintf(vout,"*"); - t=cadr(t); - } - if(nptr) fprintf(vout,"%s",nptr->nm); - while (t>0&&car(t)==ARRAY) { - if(caddr(t)==0) - fprintf(vout,"[]"); - else - fprintf(vout,"[%d]",caddr(t)); - t=cadr(t); - } - if (t>0&&car(t)==FUNCTION) { - fprintf(vout,"("); - type_print(cadr(t),0,vout); - fprintf(vout,")"); - } - } else - type_print(t,nptr,vout); + type_print1(t,nptr,vout,cont); } void
--- a/mc-tree.c Mon Feb 24 16:20:05 2003 +0900 +++ b/mc-tree.c Mon Feb 24 17:18:48 2003 +0900 @@ -16,6 +16,7 @@ extern void tree_print_t(int e,int t); static tree_node_type * find_node(int e); extern void type_print(int type,NMTBL *n,FILE *out); +extern void type_print1(int type,NMTBL *n,FILE *out,int cont); extern void sym_print(int type,FILE *out); /* ascendant order for binary search */ @@ -261,10 +262,10 @@ } } -void function_type_print(int type,NMTBL *n,FILE *out) +void function_type_print1(int type,NMTBL *n,FILE *out,int cont) { int args; - type_print(cadr(type),0,out); + type_print1(cadr(type),0,out,cont); if(n) fprintf(out," %s",n->nm); fprintf(out,"("); if((args=caddr(type))) { @@ -277,6 +278,11 @@ fprintf(out,")"); } +void function_type_print(int type,NMTBL *n,FILE *out) +{ + function_type_print1(type,n,out,0); +} + void sym_print(int sym,FILE *out) { tree_node_type *tn; @@ -295,7 +301,7 @@ return 0; } -void type_print(int type,NMTBL *n,FILE *out) +void type_print1(int type,NMTBL *n,FILE *out,int cont) { int t; tree_node_type *tn; @@ -303,27 +309,34 @@ int args; if((td=typedef_search(typedefed,type))) { + if (!cont) fprintf(out,"%s ",td->nm); } else if((td=typedef_search(gtypedefed,type))) { + if (!cont) fprintf(out,"%s ",td->nm); } else if (type<0) { t=type; if (!(tn=find_node(t))) { error(-1); return; } - fprintf(out,"%s ",tn->tree_name); + if (!cont) + fprintf(out,"%s ",tn->tree_name); } else if ((t=car(type))) { if (!(tn=find_node(t))) { error(-1); return; } if(t==STRUCT||t==UNION) { - fprintf(out,"%s ",tn->tree_name); - struct_type_print(type,out); + if (!cont) { + fprintf(out,"%s ",tn->tree_name); + struct_type_print(type,out); + } } else if(t==CODE) { - fprintf(out,"%s ",tn->tree_name); - function_type_print(type,n,out); + if (!cont) { + fprintf(out,"%s ",tn->tree_name); + } + function_type_print1(type,n,out,cont); return; } else if(t==FUNCTION) { - function_type_print(type,n,out); + function_type_print1(type,n,out,cont); return; } else if(t==ARRAY) { - type_print(cadr(type),n,out); + type_print1(cadr(type),n,out,cont); if (caddr(type)) fprintf(out,"[%d]",caddr(type)); else @@ -332,7 +345,7 @@ } else if(t==POINTER) { t=cadr(type); if(car(t)==FUNCTION) { - type_print(cadr(t),0,out); + type_print1(cadr(t),0,out,cont); fprintf(out,"(*"); if(n) fprintf(out,"%s",n->nm); fprintf(out,")"); @@ -355,7 +368,7 @@ fprintf(out,")[]"); return; } else { - type_print(t,0,out); + type_print1(t,0,out,cont); fprintf(out,"*"); } } @@ -363,4 +376,9 @@ if(n) fprintf(out,"%s",n->nm); } +void type_print(int type,NMTBL *n,FILE *out) +{ + type_print1(type,n,out,0); +} + /* end */