Mercurial > hg > CbC > old > device
changeset 351:000c509b663d
name table reconfigure continue...
author | kono |
---|---|
date | Sat, 03 Jul 2004 00:32:27 +0900 |
parents | 43099915f4c2 |
children | 48aeb7379759 |
files | .gdbinit Changes mc-macro.c mc-parse.c mc.h |
diffstat | 5 files changed, 64 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/.gdbinit Fri Jul 02 18:28:19 2004 +0900 +++ b/.gdbinit Sat Jul 03 00:32:27 2004 +0900 @@ -1,8 +1,9 @@ tb main # run -s test/arg.c -# run -s -ob00.s mc-parse.c +run -s -ob00.s mc-parse.c +# run -s -ob01.s mc-switch.c # run -s l.c -run -s test/macro.c +# run -s test/simp0.c # run -s test/code-gen-all.c define regs printf "pc =%08x lr =%08x r0 =%08x r1 =%08x r3= %08x r4= %08x\n",$pc,$lr,$r0,$r1,$r3,$r4
--- a/Changes Fri Jul 02 18:28:19 2004 +0900 +++ b/Changes Sat Jul 03 00:32:27 2004 +0900 @@ -5394,3 +5394,9 @@ cheap hash ぐらい? + +やっぱり、大変だわ。あと、もう少しだとは思うけど。 + +Fri Jul 2 23:38:14 JST 2004 + +あと、もう少し..
--- a/mc-macro.c Fri Jul 02 18:28:19 2004 +0900 +++ b/mc-macro.c Sat Jul 03 00:32:27 2004 +0900 @@ -87,7 +87,8 @@ *cheap->ptr = '/'; cheap = increment_cheap(cheap,&p); } while(( *cheap->ptr = *name++ )) cheap = increment_cheap(cheap,&p); - cheap->ptr = 0; + *cheap->ptr = 0; + cheap = increment_cheap(cheap,&p); return p; } @@ -98,10 +99,7 @@ char *s,*p,**pp,*name; FILE *fp; struct cheap scheap; - struct cheap scheap1; - save_cheap(&scheap,cheap); name = cheap->ptr; - getch(); if(skipspc()=='"') { end = '"'; @@ -114,26 +112,28 @@ } if(ch=='\n') error(INCERR); if (err) return filep->fcb; - cheap->ptr = 0; + *cheap->ptr = 0; + cheap = increment_cheap(cheap,&name); + save_cheap(&scheap,cheap); fp = fopen(name,"r") ; if (fp) { p = name; } else { - save_cheap(&scheap1,cheap); for(pp=(end=='>'||filep->inc=='>') ?l_include_path:include_path; *pp;pp++) { - cheap = reset_cheap(&scheap1); p = expand_file_name(*pp,name); if ((fp = fopen(p,"r"))) break ; } } if(!fp) { error(FILERR); return filep->fcb; } copy_current_file_dir(s=p); + // File name determined. Dispose extra copies. + cheap = reset_cheap(&scheap); if (p!=name) { - // File name determined. Dispose extra copies. - cheap = reset_cheap(&scheap); name = cheap->ptr; while((*cheap->ptr = *s++)) cheap = increment_cheap(cheap,&name); + *cheap->ptr = 0; + cheap = increment_cheap(cheap,&name); } (filep+1)->inc = end; (filep+1)->name0 = name; @@ -435,7 +435,9 @@ && c != '\n') { cheap = increment_cheap(cheap,body); if (c=='/'&&chptr[0]=='/') { - cheap->ptr--; while(*chptr++); break; + cheap->ptr--; + *cheap->ptr = '\0'; + while(*chptr++); break; } else if (c=='/'&&chptr[0]=='*') { cheap->ptr--; chptr++; while((c = *chptr++)) {
--- a/mc-parse.c Fri Jul 02 18:28:19 2004 +0900 +++ b/mc-parse.c Sat Jul 03 00:32:27 2004 +0900 @@ -130,6 +130,7 @@ static int typename(void); extern NMTBL * get_name_from_chptr(); static NMTBL * hash_search(char *name,struct cheap *scheap,int len,unsigned int hash,int mode); +static NMTBL * make_local_scope(NMTBL *nlist,NMTBL *nptr1,int sc); static void enter_scope(); static void leave_scope(); static void extrn_use(NMTBL *nptr); @@ -609,7 +610,7 @@ } else error(DCERR); } conv->return_type_(type,n,sd); - def(n); + n = def(n); if (sym==ASS && n!=&null_nptr) { decl_data(type,n,0,0); data_closing(n); } while(sym==COMMA) { @@ -1001,6 +1002,7 @@ char *p = cheap->ptr; unsigned int hash = 0; struct cheap scheap; + NMTBL *n; save_cheap(&scheap,cheap); while((ch = *name++)) { @@ -1008,17 +1010,21 @@ increment_cheap(cheap,&p);len++; } ndsp = ++stat_no; - cheap->ptr[-1] = delimit; + *cheap->ptr = delimit; + increment_cheap(cheap,&p); //len++; while(ndsp>0) { ch = ndsp%10+'0'; - hash_value(hash,*cheap->ptr = ch); - increment_cheap(cheap,&p);len++; + // hash_value(hash,*cheap->ptr = ch); + *cheap->ptr = ch; + increment_cheap(cheap,&p);//len++; ndsp /= 10; } *cheap->ptr = 0; increment_cheap(cheap,&p); - return name_space_search( + n = name_space_search( name_space_search(hash_search(p,&scheap,len,hash,DEF),LDECL),0); + n->nm = p; + return n; } @@ -1417,7 +1423,7 @@ int sd = stypedecl; int arglist; if(!chk) gen_enter(n->nm); - extrn_use(nptr); + extrn_use(n); local_static_list = &null_nptr; fnptr=n; retlabel=fwdlabel(); @@ -2566,6 +2572,7 @@ type= glist3(FUNCTION,INT,0); nptr->sc = EXTRN1; nptr->ty= type; + extrn_use(nptr); e1=expr15(list2(FNAME,(int)nptr)); break; } else if (in_macro_if) { @@ -2868,6 +2875,7 @@ struct cheap *p = (struct cheap *)malloc(sizeof(struct cheap)); if (!p) error(MMERR); // fatal p->ptr = p->first = (char *)malloc(CHEAPSIZE); + p->last = p->first + CHEAPSIZE; if (!p->ptr) error(MMERR); // fatal p->next = 0; return p; @@ -3143,7 +3151,7 @@ if (!d) { if (is_ll()) { #if LONGLONG_CODE - *cheap->ptr = '0'; + *cheap->ptr = 0; cheap = increment_cheap(cheap,&num); lsymval = strtoll(num,0,0); sym=LCONST; @@ -3181,7 +3189,7 @@ extern int getsym(int sc) { - NMTBL *nlist,*nptr0,*nptr1,*nptrm; int ns; + NMTBL *nlist,*nptr0,*nptr1,*nptrm; char c; if (alpha(skipspc())) { @@ -3225,15 +3233,7 @@ } } /* define case */ - for(ns=nlist->dsp;ns;ns=cadr(ns)) { - if (car(ns)==sc && nptr1->sc!=EMPTY) { - current_scope = glist3((int)&(caddr(ns)),current_scope, - (int)nptr1); - caddr(ns) = (int)(nptr1 = get_nptr()); - nptr1->nm = nlist->nm; nptr1->sc=EMPTY; nptr1->dsp = 0; - } - } - nptr=nptr1; + nptr = make_local_scope(nlist,nptr1,sc); return sym; } else if (digit(ch)||ch=='.') { @@ -3440,8 +3440,25 @@ static NMTBL * lsearch(char *name,int sc) { - return - name_space_search(name_space_search(get_name(name,0,DEF),LDECL),sc); + NMTBL *nlist,*nptr1; + nptr1 = name_space_search( + nlist = name_space_search(get_name(name,0,DEF),LDECL),sc); + return make_local_scope(nlist,nptr1,sc); +} + +static NMTBL * +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 */) { + current_scope = glist3((int)&(caddr(ns)),current_scope, + (int)nptr1); + caddr(ns) = (int)(nptr1 = get_nptr()); + nptr1->nm = nlist->nm; nptr1->sc=EMPTY; nptr1->dsp = 0; + } + } + return nptr1; } static void @@ -3464,6 +3481,12 @@ free_glist2(current_scope); // will destroy cadr current_scope = next; } + if (saved_scope) { + current_scope = car(saved_scope); + next = cadr(saved_scope); + free_glist2(saved_scope); + saved_scope = next; + } } extern void