Mercurial > hg > CbC > old > device
changeset 501:a63eb2319d11
inline continue...
author | kono |
---|---|
date | Fri, 23 Dec 2005 16:21:25 +0900 |
parents | 0a4ca939f403 |
children | bc66e49e25a2 |
files | mc-inline.c |
diffstat | 1 files changed, 75 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-inline.c Fri Dec 23 14:27:32 2005 +0900 +++ b/mc-inline.c Fri Dec 23 16:21:25 2005 +0900 @@ -416,103 +416,114 @@ static int pfunction(int e) { - return e; + // list4(INLINE,e1,arglist,ftype); + // include code segement case + int e1 = pexpr(cadr(e)); + int arglist = caddr(e); + int newargs = 0; + int ftype = cadddr(e); + int e3; + for (e3 = arglist; e3; e3 = cadr(e3)) { + newargs = list3( pexpr(car(e3)), cadr(e3), caddr(e3)); + } + newargs = reverse0(newargs); + return list4(INLINE,e1,newargs,ftype); } static int prindirect(int e) { - return e; + return list3(car(e),pexpr(cadr(e)),caddr(e)); } static int paddress(int e) { - return e; + return list2(car(e),pexpr(cadr(e))); } static int p_conv(int e1,int e2) { - return e1; + return list3(CONV,pexpr(e1),e2); } static int pbinop(int op,int e1,int e2) { - return e1; + return list3(op,pexpr(e1),pexpr(e2)); } static int psassign(int e) { - return e; + return list4(car(e),pexpr(cadr(e)),pexpr(caddr(e)),cadddr(e)); } static int passign(int e) { - return e; + return list3(car(e),pexpr(cadr(e)),pexpr(caddr(e))); } static int passop(int e) { - return e; + return list4(car(e),pexpr(cadr(e)),pexpr(caddr(e)),cadddr(e)); } static int pdassign(int e) { - return e; + return list3(car(e),pexpr(cadr(e)),pexpr(caddr(e))); } static int pdassop(int e) { - return e; + return list4(car(e),pexpr(cadr(e)),pexpr(caddr(e)),cadddr(e)); } static int plassign(int e) { - return e; + return list3(car(e),pexpr(cadr(e)),pexpr(caddr(e))); } static int plassop(int e) { - return e; + return list4(car(e),pexpr(cadr(e)),pexpr(caddr(e)),cadddr(e)); } static int palloc(int e) { - return e; + return list2(car(e),pexpr(cadr(e))); } static int pcomma(int e1,int e2) { - return e1; + return list3(COMMA,pexpr(e1),pexpr(e2)); } static int prbit_field(int e) { - return e; + return list3(car(e),pexpr(cadr(e)),caddr(e)); } static int pbassign(int e) { - return e; + return list4(car(e),pexpr(cadr(e)),pexpr(caddr(e)),cadddr(e)); } static int pbassop(int e) { - return e; + return list4(car(e),pexpr(cadr(e)),pexpr(caddr(e)),cadddr(e)); } static int @@ -569,91 +580,118 @@ static int p_do(int e) { - return e; + return list4(ST_DO,pexpr(cadr(e)),pexpr(caddr(e)),pexpr(cadddr(e))); } static int p_while(int e) { - return e; + return list4(ST_WHILE,pexpr(cadr(e)),pexpr(caddr(e)),pexpr(cadddr(e))); } static int p_for(int e) { - return e; + int e1=caddr(e); + int p0=car(e1); + int p1=cadr(e1); + int p2=caddr(e1); + int p3=cadddr(e1); + return list3(ST_FOR,pexpr(cadr(e)), + list4(pexpr(p0),pexpr(p1),pexpr(p2),pexpr(p3))); } static int p_switch(int e) { - return e; + return list4(ST_SWITCH,pexpr(cadr(e)),caddr(e),pexpr(cadddr(e))); } static int p_comp(int e) { - return e; + return list3(ST_COMP,pexpr(cadr(e)),pexpr(caddr(e))); } static int p_break(int e) { - return e; + return list2(ST_BREAK,expr(cadr(e))); } static int p_continue(int e) { - return e; + return list2(ST_CONTINUE,expr(cadr(e))); } static int p_case(int e) { - return e; + return list3(ST_CASE,expr(cadr(e)),caddr(e)); } static int p_default(int e) { - return e; + return list2(ST_DEFAULT,expr(cadr(e))); } static int p_return(int e) { - return e; + return list3(ST_RETURN,expr(cadr(e)),expr(caddr(e))); } static int p_goto(int e) { - return e; + int e1; + if ((e1=caddr(e))) { + switch(car(e1)) { + case RINDIRECT: e1=pexpr(e1); break; + case CODE: e1=list3(CODE,pexpr(cadr(e1)),pexpr(caddr(e1))); break; + case FLABEL: break; + } + } + return list3(ST_GOTO,expr(cadr(e)),e1); +} + +static int +p_list_expr(int e) +{ + int e3,new = 0; + for (e3 = e; e3; e3 = cadr(e3)) { + new= list2( pexpr(car(e3)), new); + } + return reverse0(new); } static int p_asm(int e) { - return e; + int param=caddr(e); + int e1 = p_list_expr(cadddr(e)); + return list4(ST_ASM,pexpr(cadr(e)),param,e1); } static int p_label(int e) { - return e; + return list3(ST_GOTO,expr(cadr(e)),caddr(e)); } static int p_bool(int e) { + error(-1); return e; } static int p_comment(int e) { - return pexpr(cadr(e)); + return list3(ST_COMMENT,pexpr(cadr(e)),caddr(e)); } extern int @@ -715,7 +753,7 @@ #endif return prindirect(e1); case ADDRESS: - return paddress(pexpr(e2)); + return paddress(e2); case MINUS: if ((e3 = pexpr(e2))==e2) return e1; if (car(e3)==CONST) return list2(CONST,-cadr(e3)); @@ -739,7 +777,7 @@ return list2(car(e1),e3); #endif case CONV: - return p_conv(caddr(e1),pexpr(e2)); + return p_conv(caddr(e1),e2); case BNOT: /* ~ */ if ((e3 = pexpr(e2))==e2) return e1; if (car(e3)==CONST) return list2(CONST,~cadr(e3)); @@ -811,9 +849,7 @@ case LLSHIFT: case LULSHIFT: case LRSHIFT: case LURSHIFT: case LADD: case LSUB: case LBAND: case LEOR: case LBOR: case LCMP: #endif - e3 = pexpr(e2); e2 = pexpr(caddr(e1)); - if (e3==cadr(e1)&&e2==caddr(e1)) return e1; - return pbinop(car(e1),e3,e2); + return pbinop(car(e1),e2,caddr(e1)); case LCOND: case DCOND: case FCOND: case COND: e3 = pexpr(e2); if (car(e3)==CONST) return pexpr(cadr(e3)?caddr(e1):cadddr(e1)); @@ -838,7 +874,7 @@ return plassop(e1); #endif case ALLOCA: - return palloc(pexpr(e2)); + return palloc(e2); case BUILTINP: return list2(CONST,is_const(pexpr(e2))); case COMMA: @@ -860,8 +896,8 @@ #if ASM_CODE case ASM: return list3(ASM,list4( - pexpr(car(e2)),pexpr(cadr(e2)),pexpr(caddr(e2)),pexpr(cadddr(e2))), - pexpr(caddr(e1))); + car(e2),cadr(e2),caddr(e2),cadddr(e2)), + caddr(e1)); #endif case ST_DECL: return p_decl(e1); case ST_IF: return p_if(e1);