Mercurial > hg > CbC > old > device
changeset 713:88e364604533 current-release **INVALID**
*** empty log message ***
author | kono |
---|---|
date | Mon, 29 Oct 2007 17:26:43 +0900 |
parents | bf94c295d763 |
children | 5fad4649bed8 |
files | Makefile mc-inline.c mc-macro.c mc-parse.c test/longcode.c test/offset.c |
diffstat | 6 files changed, 50 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Sat Oct 27 23:20:44 2007 +0900 +++ b/Makefile Mon Oct 29 17:26:43 2007 +0900 @@ -116,6 +116,7 @@ make check TARGET=test/inline make check TARGET=test/ps2 make check-inline TARGET=test/ps2 + make check TARGET=test/offset make check TARGET=test/multi make check-inline TARGET=test/multi make check TARGET=test/comp
--- a/mc-inline.c Sat Oct 27 23:20:44 2007 +0900 +++ b/mc-inline.c Mon Oct 29 17:26:43 2007 +0900 @@ -446,11 +446,14 @@ static char *plinebuf; // last comment in parse tree (for compiler debug) +static int plineno; + extern void st_comment(int e1){ glineno++; printf("## %d ",glineno); - gen_comment(plinebuf=(char *)ncaddr(e1)); + plineno = caddr(e1); + gen_comment(plinebuf=(char *)ncadddr(e1)); } /* @@ -1070,7 +1073,8 @@ // 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(cexpr(pexpr(car(clist))),new,0); + // new=glist3(cexpr(pexpr(car(clist))),new,0); + new=glist3(car(clist),new,0); return list3(ST_CASE,pexpr(cadr(e)),reverse0(new)); } @@ -1177,7 +1181,8 @@ p_comment(int e) { glineno++; - return list3n(ST_COMMENT,pexpr(cadr(e)),ncaddr(e)); + plineno = caddr(e); + return list4n(ST_COMMENT,pexpr(cadr(e)),caddr(e),ncadddr(e)); } static int
--- a/mc-macro.c Sat Oct 27 23:20:44 2007 +0900 +++ b/mc-macro.c Mon Oct 29 17:26:43 2007 +0900 @@ -240,9 +240,8 @@ save_cheap(&scheap,cheap); fp = fopen(name,"r") ; if (next && fp) { fclose(fp); fp=0; next=0; prev=name; } - if (fp) { - p = name; - } else { + p = name; + if (!fp) { // no deferenced on "" and <>? for(pp=include_path; *pp;pp++) { p = expand_file_name(*pp,name); @@ -410,7 +409,7 @@ p = st_cheap->ptr; sprintf(num,"%d: ",lineno); - parse = list3n(ST_COMMENT,parse,(NMTBL*)p); + parse = list4n(ST_COMMENT,parse,lineno,(NMTBL*)p); // should contain file name c = 0; while((*st_cheap->ptr = num[c++]))
--- a/mc-parse.c Sat Oct 27 23:20:44 2007 +0900 +++ b/mc-parse.c Mon Oct 29 17:26:43 2007 +0900 @@ -1227,7 +1227,7 @@ type=list3(ARRAY,type,0); } else { array_type=type; - i=cexpr(expr(1)); + i=inmode?cexpr(pexpr(expr(1))):cexpr(expr(1)); checksym(RBRA); type=list3(ARRAY,array_type,i); } @@ -1556,12 +1556,16 @@ // .__tcp_lhash_lock = (rwlock_t) { }, // We cannot distinguish this case and cascading comma here. // Do it more upper syntactical node; - 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; + if (inmode) { + int offset1=decl_data_1(car(t1),v,0); + offset1 = reverse0(offset1); + offset=list3(DECL_DATA,offset1,car(t1)); + return offset; + } else { + offset=decl_data_1(car(t1),v,offset); + if (!offset) checksym(RPAR); + return offset; + } } else { error(SIERR); } @@ -1975,7 +1979,7 @@ nptr0 = nptr; if (getsym(0) == ASS) { getsym(0); - disp = cexpr(expr1()); + disp = inmode?cexpr(pexpr(expr1())):cexpr(expr1()); } nptr0->dsp = disp; if (sym!=COMMA) break; @@ -2063,9 +2067,9 @@ /* reverse all argument offset (with size) */ arglist = fnptr->dsp; for(t=arglist;t;t=cadr(t)) { - n=ncaddr(t); + n=ncadddr(t); if(n->sc==LVAR) - n->dsp = -n->dsp-cadddr(t); + n->dsp = -n->dsp-caddr(t); } arg_register(fnptr); } @@ -2944,7 +2948,7 @@ conv->case_begin_(0,0); getsym(0); // we have to make it global? - c = inmode?expr(1): cexpr(expr(1)); + c = inmode?cexpr(pexpr(expr1())):cexpr(expr1()); if (!inmode && cst) { clist |= (cadr(csvalue1)==c); conv->case_(list2(c,0),0); @@ -3014,7 +3018,7 @@ while(sym==CASE) { conv->case_begin_(c,0); getsym(0); - c=cexpr(expr(1)); + c = inmode?cexpr(pexpr(expr1(1))):cexpr(expr1(1)); if (!inmode && cst) clist |= (c==cadr(csvalue1)); else @@ -4493,7 +4497,7 @@ if(sym==LBRA) { getsym(0); t=type; - i=cexpr(expr(1)); + i = inmode?cexpr(pexpr(expr(1))):cexpr(expr(1)); checksym(RBRA); type=list3(ARRAY,t,i); } else if(sym==LPAR) { @@ -5092,6 +5096,7 @@ { NMTBL *ret; if (free_nptr_list) { + // we can use free list ret = free_nptr_list; free_nptr_list = free_nptr_list->u.nptr; ret->sc = 0; @@ -5105,8 +5110,10 @@ } if (nptr_pool->ptr >= nptr_pool->last) { if (nptr_pool->next) { + // we can reuse previous nptr_pool nptr_pool = nptr_pool->next; } else { + // allocate new one if (HEAP_REPORT) fprintf(stderr,"** nptr extended\n"); nptr_pool->next = new_cheap(); @@ -5159,6 +5166,11 @@ lexical name scope handler enter_scope leave_scope + + + nptr->dsp + glist3n(ScopeID,next,nptr) + ScopeID MACRO,NAME,TYPEDEF,FIELD */ extern NMTBL * @@ -5167,19 +5179,18 @@ int ns; NMTBL *n; - for(ns=hash->dsp;ns;ns=cadr(ns)) { + for(ns=hash->dsp;ns;ns=cadr(ns)) { // iterate on possible scope if (car(ns)==sc) { return ncaddr(ns); } } if (ns==0) { n = get_nptr(); - hash->dsp = glist3n(sc,hash->dsp,n); + hash->dsp = glist3n(sc,hash->dsp,n); // make a scope for sc } n->nm = hash->nm; n->sc = EMPTY; n->dsp = 0; - n->u.nptr = 0; n->attr = 0; return n; } @@ -5206,12 +5217,13 @@ make_local_scope(NMTBL *nlist,NMTBL *nptr1,int sc) { int ns; - for(ns=nlist->dsp;ns;ns=cadr(ns)) { - if (car(ns)==sc /* && nptr1->sc!=EMPTY */) { + for(ns=nlist->dsp;ns;ns=cadr(ns)) { // iterate on possible scope + if (car(ns)==sc) { // memorize previous nptr for this name for leave_scope car(current_scope) = glist3n(ns,car(current_scope),nptr1); ncaddr(ns) = nptr1 = get_nptr(); nptr1->nm = nlist->nm; nptr1->sc=EMPTY; nptr1->dsp = 0; + break; } } return nptr1; @@ -5225,10 +5237,11 @@ for(scope=current_scope;cadr(scope);scope=cadr(scope)); for(ns=nlist->dsp;ns;ns=cadr(ns)) { // memorize previous nptr for this name for leave_scope - if (car(ns)==sc /* && nptr1->sc!=EMPTY */) { + if (car(ns)==sc) { car(scope) = glist3n(ns,car(scope),nptr1); ncaddr(ns) = nptr1 = get_nptr(); nptr1->nm = nlist->nm; nptr1->sc=EMPTY; nptr1->dsp = 0; + break; } } return nptr1;
--- a/test/longcode.c Sat Oct 27 23:20:44 2007 +0900 +++ b/test/longcode.c Mon Oct 29 17:26:43 2007 +0900 @@ -41,7 +41,7 @@ __code move13(int tekino,teki *enemy,player jiki,struct move_interface interface) { - if (enemy[keyenemyno].f == 0 ) { + if (enemy[tekino].f == 0 ) { goto put_enemy_bung(move13_1,tekino,enemy,jiki,interface); }
--- a/test/offset.c Sat Oct 27 23:20:44 2007 +0900 +++ b/test/offset.c Mon Oct 29 17:26:43 2007 +0900 @@ -1,5 +1,9 @@ extern int printf(const char *,...); +#ifndef INLINE +#define INLINE +#endif + #define BIT8 260 #define BIT10 1030 #define BIT12 5000 @@ -8,7 +12,7 @@ int midium[BIT12]; int large[BIT16]; -int +static INLINE int main0(int ac,char *av[]) { int *p;