Mercurial > hg > CbC > old > device
changeset 77:2b8ba655e572 k-c-arg-style
fix arg type
author | kono |
---|---|
date | Fri, 28 Feb 2003 20:29:21 +0900 |
parents | fb3fb9e9a462 |
children | 8418d4b7caa7 |
files | .gdbinit conv/c.c mc-code-ia32.c mc-codegen.c mc-codegen.h mc-parse.c mc.h test/arg.c |
diffstat | 8 files changed, 56 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/.gdbinit Mon Feb 24 21:36:16 2003 +0900 +++ b/.gdbinit Fri Feb 28 20:29:21 2003 +0900 @@ -13,5 +13,5 @@ x/1i $eip end b errmsg -r -Cc test/tmp2.c +r -Cc test/arg.c
--- a/conv/c.c Mon Feb 24 21:36:16 2003 +0900 +++ b/conv/c.c Fri Feb 28 20:29:21 2003 +0900 @@ -29,7 +29,7 @@ break; } } -#if 0 +#if 1 vout = fopen(p,"w"); #else vout = stderr;p=p;
--- a/mc-code-ia32.c Mon Feb 24 21:36:16 2003 +0900 +++ b/mc-code-ia32.c Fri Feb 28 20:29:21 2003 +0900 @@ -1055,6 +1055,7 @@ printf("%s:\n",name); } + void code_enter1(int args) {
--- a/mc-codegen.c Mon Feb 24 21:36:16 2003 +0900 +++ b/mc-codegen.c Fri Feb 28 20:29:21 2003 +0900 @@ -90,6 +90,27 @@ regv[i]=1; } +void +set_register_var() { +} + +void +arg_register(int args) +{ + NMTBL *n; + if (args) { + /* process in reverse order */ + arg_register(cadr(args)); + n = (NMTBL*)car(args); + if(n->sc==REGISTER) { + if ((n->dsp = get_register_var()) <0) { + error(-1); return; + } + use_register_var(n->dsp); /* it has now value in it */ + } + } +} + int creg_regvar = -1; static int creg_regvar_back; static int creg_back;
--- a/mc-codegen.h Mon Feb 24 21:36:16 2003 +0900 +++ b/mc-codegen.h Fri Feb 28 20:29:21 2003 +0900 @@ -58,6 +58,7 @@ extern void closing(); extern void ret(void); extern void use_register_var(int); +extern void arg_register(int); /* end */
--- a/mc-parse.c Mon Feb 24 21:36:16 2003 +0900 +++ b/mc-parse.c Fri Feb 28 20:29:21 2003 +0900 @@ -92,7 +92,6 @@ static int struct_return = 0; -static int arglist = 0; static int sdecl_f = 1; static int stypedecl; @@ -358,7 +357,7 @@ { NMTBL *n; int t,sd; - if (mode==GDECL) typedefed=0; + if (mode==GDECL) { typedefed=0; } if(sym==STATIC) { if(mode==LDECL) { @@ -547,30 +546,32 @@ mode=ADECL;getsym();mode=GDECL; /* ??? */ } else getsym(); - if(sym==RPAR) - getsym(); - else { - if (type==CODE) { - n->sc=CODE; - n->dsp=0; + n->dsp=0; + if (type==CODE) { + n->sc=CODE; + n->sc=EMPTY; + if(sym==RPAR) { + getsym(); + } else { stmode=REGISTER; adecl(n); stmode=0; - n->sc=EMPTY; - type=list3(CODE,type,n->dsp); - return n; - } else { - n->sc=FUNCTION; - n->dsp=0; - n->ty=type; + } + type=list3(CODE,type,n->dsp); + } else { + n->sc=FUNCTION; + n->ty=type; + n->sc=EMPTY; + if(sym==RPAR) { + getsym(); + } else adecl(n); - n->sc=EMPTY; - } + type=list3(FUNCTION,type,n->dsp); } - type=list3(FUNCTION,type,n->dsp); } else return n; } + /* NOT REACHED */ } @@ -678,6 +679,10 @@ } if(car(t)==ARRAY) return(size(cadr(t))*caddr(t)); + else if(car(t)==CODE) + return size_of_int; + else if(car(t)==FUNCTION) + return size_of_int; else error(DCERR); return 0; @@ -762,12 +767,6 @@ !(type!=CHAR && !scalar(type))) { n->sc = REGISTER; reg_var++; - if (n->dsp==0) { - if ((n->dsp = get_register_var())<0) { - error(-1); - } - use_register_var(n->dsp); /* it has now value in it */ - } caddr(arglist)=size_of_int; return n; } @@ -789,6 +788,8 @@ } else if (!scalar(type)) { if((t=car(type))==STRUCT || t==UNION) { n->ty = type; + } else if((t=car(type))==FUNCTION || t==CODE) { + n->ty = list2(POINTER,type); } else error(TYERR); } @@ -800,8 +801,8 @@ error(DCERR); nsc = REGISTER; reg_var++; - if ((ndsp = get_register_var())<0) - error(-1); + if ((ndsp = get_register_var())<0) + error(-1); } else { nsc = LVAR; ndsp = (disp -= sz); @@ -1044,6 +1045,7 @@ if(n->sc==LVAR) n->dsp = -n->dsp-caddr(t); } + arg_register(arglist); conv->code_(fnptr,arglist); typedefed=0; /* local variable declaration */ @@ -1092,6 +1094,7 @@ fnptr->dsp=reverse0(fnptr->dsp); } fdecl_struct(fnptr->ty); + arg_register(arglist); typedefed=0; conv->function_(fnptr,arglist,sd); conv->lc_(); disp=0;