Mercurial > hg > CbC > old > device
changeset 703:874adc2528f9
strinit fix on parse mode (half done)
author | kono |
---|---|
date | Tue, 23 Oct 2007 16:19:09 +0900 |
parents | 8eadf0db2970 |
children | 6e6dc2d644ed |
files | .gdbinit mc-codegen.c mc-inline.c mc-parse.c |
diffstat | 4 files changed, 32 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/.gdbinit Tue Oct 23 14:30:59 2007 +0900 +++ b/.gdbinit Tue Oct 23 16:19:09 2007 +0900 @@ -16,10 +16,11 @@ # r -s test/tmp7.c # r -s test/tmp6.c # r -s test/call.c -r -s test/static.c +# r -s test/static.c +# r -s test/tmpa.c # r -s test/code-gen-all.c # r -s mc-code-powerpc.c -# r -s test/strinit.c +r -s test/strinit.c # r -s test/arg.c # r -s -DINLINE=inline test/strinit.c # r -s test/fact-a.c
--- a/mc-codegen.c Tue Oct 23 14:30:59 2007 +0900 +++ b/mc-codegen.c Tue Oct 23 16:19:09 2007 +0900 @@ -160,7 +160,7 @@ error(-1); // return (parse = list3(ST_COMP,parse,e1)); } - if (!control && !IS_STATEMENT(car(e1))) return VOID; + if (!e1 ||(!control && !IS_STATEMENT(car(e1)))) return VOID; for(;e1;e1=e2) { code_gexpr(e1); @@ -3666,17 +3666,25 @@ static int gen_decl_data_list(int v,int init,int target_type,int offset) { - int type0 = cadr(target_type); /* type of element */ + int type0 = caddr(target_type); /* list of fields */ int e; for(; init; init = cadr(init)) { + if (car(init)==DECL_DATA) { + // casted initilizer + e = cadr(init); // value + if (!e) continue; // {...,} case + offset = gen_decl_data0(v,caddr(init),e,offset); + continue; + } // ordered data if (car(init)!=DECL_DATA_LIST) { error(-1); } e = caddr(init); if (!e) continue; // {...,} case - offset = gen_decl_data0(v,type0,e,offset); + offset = gen_decl_data0(v,car(type0),e,offset); + type0 = cadr(type0); } return offset; } @@ -3698,7 +3706,7 @@ offset = gen_decl_data_array(v,e,target_type,offset); break; default: - t = caddr(init); // type of source + type = t = caddr(init); // type of source // e = rvalue_t(e,t); offset=assign_data(e,t,v,offset); }
--- a/mc-inline.c Tue Oct 23 14:30:59 2007 +0900 +++ b/mc-inline.c Tue Oct 23 16:19:09 2007 +0900 @@ -825,19 +825,24 @@ int type0 = caddr(target_type); /* list of fields */ int e; - for(; init; init = cadr(init)) { - int e1 = init; - if (car(e1)==DECL_DATA) { + for(; init; init = cadr(init),type0 = cadr(type0)) { + if (car(init)==DECL_DATA) { // casted initilizer ? + //error(-1); + e = cadr(init); // value + if (!e) continue; // {...,} case + e = pexpr(e); + offset = pdecl_data(var,caddr(init),e,offset); continue; } // ordered data - if (car(e1)!=DECL_DATA_LIST) { + if (car(init)!=DECL_DATA_LIST) { error(-1); } - e = pexpr(caddr(e1)); + e = caddr(init); + if (!e) continue; // {...,} case + e = pexpr(e); offset = pdecl_data(var,car(type0),e,offset); - type0 = cadr(type0); } return offset; } @@ -1455,9 +1460,8 @@ return list3(DECL_DATA,pexpr(e2),caddr(e1)); case DECL_DATA_LIST: case DECL_DATA_ARRAY: - return list4(DECL_DATA_LIST,pexpr(e2),pexpr(caddr(e1)),cadddr(e1)); case DECL_DATA_FIELD: - return list4(DECL_DATA_FIELD,pexpr(e2),pexpr(caddr(e1)),cadddr(e1)); + return list4(car(e1),pexpr(e2),pexpr(caddr(e1)),cadddr(e1)); case ST_DECL: return p_decl(e1); case ST_IF: return p_if(e1); case ST_DO: return p_do(e1);
--- a/mc-parse.c Tue Oct 23 14:30:59 2007 +0900 +++ b/mc-parse.c Tue Oct 23 16:19:09 2007 +0900 @@ -1562,10 +1562,12 @@ // .__tcp_lhash_lock = (rwlock_t) { }, // We cannot distinguish this case and cascading comma here. // Do it more upper syntactical node; - if ((offset = decl_data_1(type,v,offset))) { - return offset; - } + int offset1=decl_data_1(car(t1),v,0); + offset1 = reverse0(offset1); + offset=list3(DECL_DATA,offset1,car(t1)); + if (offset) return offset; checksym(RPAR); + return offset; } else { error(SIERR); }