Mercurial > hg > CbC > old > device
diff mc-inline.c @ 690:5d3b4669854c
fix prindirect
author | kono |
---|---|
date | Wed, 10 Oct 2007 15:05:04 +0900 |
parents | 1ed8cb78cf9b |
children | 25115b50d033 |
line wrap: on
line diff
--- a/mc-inline.c Sun Oct 07 17:46:00 2007 +0900 +++ b/mc-inline.c Wed Oct 10 15:05:04 2007 +0900 @@ -213,7 +213,7 @@ gen_jmp( cslabel=fwdlabel()); } else { cst = 0; - gexpr(e,1); /* switch value */ + g_expr(e); /* switch value */ csvalue1=csvalue() ; cslabel = control = 0; } @@ -422,7 +422,7 @@ if (nptr0->ty>0&&car(nptr0->ty)==FUNCTION) car(nptr0->ty)=CODE; } - gexpr(list3(JUMP,e1,env),0); + g_expr_u(list3(JUMP,e1,env)); control=0; // conv->sm_(); return ; @@ -451,11 +451,14 @@ fwddef(cadr(lb)); } +static +char *plinebuf; // last comment in parse tree (for compiler debug) + extern void st_comment(int e1){ glineno++; printf("## %d ",glineno); - gen_comment((char *)caddr(e1)); + gen_comment(plinebuf=(char *)caddr(e1)); } /* @@ -510,6 +513,11 @@ { int lvar; int offset = caddr(e); + int type0; + type = cadddr(e); + type0 = type_value(type); + if (type0>0 && car(type0)==POINTER) + type=set_type_with_attr(cadr(type),type); if (car(lvar=cadr(e))==IVAR) { lvar=p_lvar(cadr(e)); // can be anything.... switch(car(lvar)) { @@ -548,9 +556,12 @@ static int p_conv(int e1,int e2) { - int t; + int t,stype = type; if (is_const(e2) && (t=type_of_conv(e1))) { - return correct_type(e2,t); + type = INT; + e1 = correct_type(e2,t); + type = stype; + return e1; } return list3(CONV,pexpr(e2),e1); } @@ -693,7 +704,7 @@ } #endif if (car(e)==ADDRESS||car(e)==GVAR) { - if (scalar(t)) { + if (scalar(t)||car(t)==ARRAY) { t = list2(POINTER,VOID); // fake } else { error(TYERR); @@ -1000,17 +1011,21 @@ static int p_switch(int e) { - int e2 = pexpr(caddr(e)); - int e3 = pexpr(cadddr(e)); + int e2 = pexpr(caddr(e)); // switch variable + int e3 = pexpr(cadddr(e)); // a statement in switch // if cadr(e) is a constant, we have to prune case statement. - // here? + // No we cannot. A statement in case may contain labels or + // falling down entry. + // case constants are need to be pexpred in p_case. + return list4(ST_SWITCH,pexpr(cadr(e)),e2,e3); } static int p_comp(int e) { - int e1=pexpr(caddr(e)); + int e1; + e1=pexpr(caddr(e)); return list3(ST_COMP,pexpr(cadr(e)),e1); } @@ -1031,8 +1046,9 @@ { int new=0,clist = caddr(e); // insert destory clist, we have to copy it now + // car(clist) have to be expred, it may contain operators. for(;clist;clist=cadr(clist)) - new=glist3(car(clist),new,0); + new=glist3(cexpr(pexpr(car(clist))),new,0); return list3(ST_CASE,pexpr(cadr(e)),reverse0(new)); } @@ -1405,10 +1421,11 @@ return list3(DECL_DATA,pexpr(cadr(e2)),caddr(e2)); } if (type_compatible(caddr(e1),cadddr(e1))) { - return pexpr(e2); + return pexpr(e2); // rvalue ? } else { + e2 = pexpr(e2); // will override type type = cadddr(e1); - return correct_type(pexpr(e2),caddr(e1)); + return correct_type(e2,caddr(e1)); // return list4(CAST,pexpr(e2),caddr(e1),cadddr(e1)); } case DECL_DATA: