Mercurial > hg > CbC > old > device
changeset 563:588bb765b301
*** empty log message ***
author | kono |
---|---|
date | Tue, 10 Jan 2006 10:28:55 +0900 |
parents | 0a156c491f81 |
children | 25f431685d80 |
files | Changes mc-parse.c mc-tree.c |
diffstat | 3 files changed, 77 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Mon Jan 09 20:06:02 2006 +0900 +++ b/Changes Tue Jan 10 10:28:55 2006 +0900 @@ -8122,6 +8122,20 @@ かも。まぁ、今は、inline mode があるから、tree を作ってから 印刷するっていう技もあるけどね。 - - - +bitfield で、丁度、範囲がbyte/word boundary に一致した +時には普通の代入ですむんだけど、それを考慮してない。 +make_mask の時にチェック可能。(まぁ、やる必要ないけどさ) + +あと、if (hoge.bb) とか if (!hoge.bb) ぐらいは処理したい +よね。if (hoge.bb==0x1) とか if (hoge.bb!=0x1) も。 +この場合はshift しないで and または or ですむから。 + +ltosop で、オペランドの一つがint の時もやった方が良いかな。 + +それよりは、64bit対応かな。 + +fdecl, code_decl で、一旦、tree を生成してから、コード生成 +するオプションがあった方が良い。その方が最適化が可能。 +それをdefaultにするべきか? + +inline のst_switch は、もっと賢くあるべき。
--- a/mc-parse.c Mon Jan 09 20:06:02 2006 +0900 +++ b/mc-parse.c Tue Jan 10 10:28:55 2006 +0900 @@ -294,10 +294,45 @@ init(); top_init(); while(getsym(0)) { - if (sym==IDENT) { - printf("%s",nptr->nm); - } else + // how to insert comment and new line? + switch (sym) { + case IDENT: + printf("%s",nptr->nm); break; + case CONST: + printf("%d",symval); break; +#if FLOAT_CODE + case FCONST: + printf("%g",dsymval); break; + case DCONST: + printf("%g",dsymval); break; +#endif +#if LONGLONG_CODE + case LCONST: + printf("%lld",lsymval); break; +#endif + case STRING: + { int c; char *s = nptr->nm; int i=nptr->dsp; + printf("\""); + while(--i>0) { + c=*s++; + if(c=='\n') printf("\\n"); + else if(c=='\r') printf("\\r"); + else if(c=='\t') printf("\\t"); + else if(c=='\e') printf("\\e"); + else if(c=='"') printf("\\\""); + else if(c=='\\') printf("\\\\"); + else if(!(' '<=c&&c<=0x7f)) printf("\\%03o",c); + else printf("%c",c); + } + printf("\""); + } + break; + default: sym_print(sym,stdout); + } + while (ch<=' ') { + putchar(ch); getch(); + } } /* NOT REACHED */ }
--- a/mc-tree.c Mon Jan 09 20:06:02 2006 +0900 +++ b/mc-tree.c Tue Jan 10 10:28:55 2006 +0900 @@ -35,6 +35,7 @@ {VOID,"void",""}, {EXTRN,"extern",""}, {SHORT,"short",""}, + {USHORT,"unsigned short",""}, {LONG,"long",""}, {TYPE,"type",""}, {SIZEOF,"sizeof",""}, @@ -48,6 +49,7 @@ {TAG,"tag",""}, {RESERVE,"reserve",""}, {DEFAULT,"default",""}, + {ATTRIBUTE,"attribute",""}, {CASE,"case",""}, {SWITCH,"switch",""}, {WHILE,"while",""}, @@ -65,10 +67,17 @@ {UNION,"union",""}, {STRUCT,"struct","vt"}, {ARRAY,"array","tv"}, - {POINTER,"pointer","t"}, + {POINTER,"*","t"}, {UNSIGNED,"unsigned",""}, + {INLINE,"inline",""}, + {SIGNED,"signed",""}, {CHAR,"char",""}, + {UCHAR,"unsigned char",""}, {INT,"int",""}, + {FLOAT,"float",""}, + {DOUBLE,"double",""}, + {LONGLONG,"long long",""}, + {ULONGLONG,"unsigned long long",""}, {GVAR,"gvar","vs"}, {RGVAR,"rgvar","vs"}, @@ -118,7 +127,8 @@ {BOR,"|","ee"}, {LAND,"&&","ee"}, {LOR,"||","ee"}, - {COND,"cond","eee"}, + {COND,"?","eee"}, + {ASS,"=","ee"}, {ASSOP,"assop","eev"}, {CASSOP,"cassop","eev"}, {COMMA,",","ee"}, @@ -221,7 +231,9 @@ int e1,e2; int first=0; int last=sizeof(tree_nodes)/sizeof(tree_node_type); - e2=-1; + // e2=-1; + e2=e%200; + e1=0; while (first!=last) { #if 0 e1 = (first+last)/2; @@ -235,11 +247,12 @@ else if (tree_nodes[e1].tree_type<e) first = e1; #else - if (tree_nodes[first].tree_type==e) - break; + if (tree_nodes[first].tree_type==e2) + return &tree_nodes[first]; first++; #endif } +fprintf(stderr,"Unknown ID %d [%d]in find note\n",e2,e); return &tree_nodes[e1]; } @@ -345,7 +358,10 @@ return; } else if(t==POINTER) { t=cadr(type); - if(car(t)==FUNCTION) { + if(t<0) { + type_print1(t,0,out,cont); + fprintf(out,"*"); + } else if(car(t)==FUNCTION) { type_print1(cadr(t),0,out,cont); fprintf(out,"(*"); if(n) fprintf(out,"%s",n->nm);