Mercurial > hg > CbC > old > device
changeset 891:ece860823251
on going ...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 06 Apr 2014 14:17:59 +0900 |
parents | 9d5da127f462 |
children | 3542a0e38a54 |
files | mc-codegen.c mc-codegen.h mc-parse.c test/strinit.c |
diffstat | 4 files changed, 12 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-codegen.c Sun Apr 06 12:49:08 2014 +0900 +++ b/mc-codegen.c Sun Apr 06 14:17:59 2014 +0900 @@ -3793,7 +3793,6 @@ extern int gen_delayed_decl_data(int v,int offset) { - int offset0=0; int e; int t,sz,offset1=0; int init = decl_str_init; @@ -3807,20 +3806,19 @@ list4(offset,next,expression,list2(type0,type1)); */ while (init) { - offset= car(init); + offset1= car(init); e=caddr(init); t=car(cadddr(init)); - if (offset!=offset0) { + if (offset1!=offset) { // make space - assign_data(list2(CONST,offset-offset0),EMPTY,v,offset0); + assign_data(list2(CONST,offset1-offset),EMPTY,v,offset); } type=cadr(cadddr(init)); - offset0 = gen_decl_data0(v,t,e,offset); + offset = assign_data(e,t,v,offset1); init = cadr(init); } - offset = offset0; - if ((sz=(offset1+sz-offset))>0) - assign_data(list2(CONST,sz),EMPTY,v,offset0); + if ((sz=(sz-offset))>0) + assign_data(list2(CONST,sz),EMPTY,v,offset); decl_str_init = 0; local_nptr = 0; return offset; @@ -4036,7 +4034,7 @@ */ ass = assign_expr0( (v0==REGISTER||v0==DREGISTER||v0==FREGISTER||v0==LREGISTER)? - v: (offset? list3(v0,cadr(v)+offset,caddr(v)) : v), + v: (offset? list3n(v0,cadr(v)+offset,ncaddr(v)) : v), e,t,type); init_vars = list2(ass,init_vars); break; @@ -4066,45 +4064,10 @@ } extern void -flush_delayed_decl_data(int v) -{ - int offset; - int offset0=0; - int e; - int t,sz,offset1=0; - NMTBL *n = ncaddr(v); - - sz = size(n->ty); - /* - decl_str_init - output delayed decl data - list4(offset,next,expression,list2(type0,type1)); - */ - while (decl_str_init) { - offset= car(decl_str_init); - e=caddr(decl_str_init); - t=car(cadddr(decl_str_init)); - if (offset!=offset0) { - // make space - assign_data(list2(CONST,offset-offset0),EMPTY,v,offset0); - } - type=cadr(cadddr(decl_str_init)); -// if (lsrc)printf("## %d flush c0(e)=%d type=%d t=%d offset=%d\n",lineno,car(e),type,t,offset); - offset0 = assign_data(e,t,v,offset); - decl_str_init = cadr(decl_str_init); - } - offset = offset0; - if ((sz=(offset1+sz-offset))>0) - assign_data(list2(CONST,sz),EMPTY,v,offset0); - decl_str_init = 0; - local_nptr = 0; -} - -extern void data_closing(int e) { if (!chk) { - if (decl_str_init) flush_delayed_decl_data(e); + if (decl_str_init) gen_delayed_decl_data(e,0); emit_data_closing(ncaddr(e)); } }
--- a/mc-codegen.h Sun Apr 06 12:49:08 2014 +0900 +++ b/mc-codegen.h Sun Apr 06 14:17:59 2014 +0900 @@ -104,7 +104,7 @@ extern void ret(void); extern void gen_ret(void); extern void gen_label_call(int l); -extern void flush_delayed_decl_data(int v); +extern int gen_delayed_decl_data(int v,int offset); extern void jump(int e,int env); extern int arg_alignment(int disp0,NMTBL *n,int type0,int sz, int is_code);
--- a/mc-parse.c Sun Apr 06 12:49:08 2014 +0900 +++ b/mc-parse.c Sun Apr 06 14:17:59 2014 +0900 @@ -1700,7 +1700,7 @@ list3(RSTRUCT,v0,sz),sz), init_vars); mode=STADECL; - flush_delayed_decl_data(v); + gen_delayed_decl_data(v,0); mode = smode; } #endif
--- a/test/strinit.c Sun Apr 06 12:49:08 2014 +0900 +++ b/test/strinit.c Sun Apr 06 14:17:59 2014 +0900 @@ -168,8 +168,8 @@ .dport = dport } } }; flp = &fl; - printf("#0170:%x %x\n",flp->oif,flp->uli_u.ports.dport); - printf("#0171:%x %x\n",flp->iif,flp->nl_u.ip4_u.saddr); + printf("#0170:%d %d\n",flp->oif,flp->uli_u.ports.dport); + printf("#0171:%d %d\n",flp->iif,flp->nl_u.ip4_u.saddr); } INLINE void