Mercurial > hg > CbC > old > device
changeset 349:b74b580c10f6
name table debug continue...
author | kono |
---|---|
date | Fri, 02 Jul 2004 14:14:24 +0900 |
parents | e77b3a7002ad |
children | 43099915f4c2 |
files | Changes mc-macro.c mc-parse.c mc-parse.h |
diffstat | 4 files changed, 38 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Fri Jul 02 07:19:15 2004 +0900 +++ b/Changes Fri Jul 02 14:14:24 2004 +0900 @@ -5389,3 +5389,8 @@ Fri Jul 2 06:46:27 JST 2004 こんなに変更しちゃって、動くわけないよね。 + +単体テスト書く? + cheap + hash +ぐらい?
--- a/mc-macro.c Fri Jul 02 07:19:15 2004 +0900 +++ b/mc-macro.c Fri Jul 02 14:14:24 2004 +0900 @@ -451,7 +451,6 @@ } } if (c=='\n') { - cheap->ptr--; *cheap->ptr = '\0'; } cheap = increment_cheap(cheap,body); @@ -610,7 +609,8 @@ static int macro_eval(int macrop,char *body0,int history) { - int c,len; + int c/*,len*/; + int sch; char *schptr; int in_quote = 0; int in_wquote = 0; char *macro; @@ -642,9 +642,17 @@ // name concatenation. skip ## and re-eval macro line. mconcat = 1; body++; continue; } else if (alpha(c)) { +#if 0 + body--; // ungetc nptrm = get_name(body,&len); - body += len; + c = *body; +#else + sch = ch; schptr = chptr; ch = c; chptr = body; + nptrm = get_name_from_chptr(); + body = chptr; c = ch; body--; // ungetc + ch = sch; chptr = schptr; +#endif nptrm = name_space_search(nptrm,MACRO); macro = (char *)car(nptrm->dsp); switch(nptrm->sc) { @@ -654,6 +662,7 @@ body--; } if(c!='(') error(MCERR); + *cheap->ptr = 0; cheap = increment_cheap(cheap,expand); body++; macrop = macro_function(macrop,&body,nptrm, @@ -674,9 +683,8 @@ default: macro = nptrm->nm; case LMACRO: - while((*cheap->ptr = *macro++)); + while((*cheap->ptr = *macro++)/* && len-- */) cheap = increment_cheap(cheap,expand); - cheap->ptr--; } continue; }
--- a/mc-parse.c Fri Jul 02 07:19:15 2004 +0900 +++ b/mc-parse.c Fri Jul 02 14:14:24 2004 +0900 @@ -128,8 +128,8 @@ static int decl_data(int t, NMTBL *n,int offset,int skip); static int typeid(int s); static int typename(void); -static NMTBL * get_name_from_chptr(); -static NMTBL * hash_search(char *name,struct cheap *scheap,int len,int hash); +extern NMTBL * get_name_from_chptr(); +static NMTBL * hash_search(char *name,struct cheap *scheap,int len,unsigned int hash); static void enter_scope(); static void leave_scope(); @@ -343,6 +343,8 @@ for(p=nptr_pool;p;p=p->next) p->ptr=p->first; free_nptr_list = 0; + heap_init(); + reserve("int",INT); reserve("void",VOID); reserve("char",CHAR); @@ -387,7 +389,6 @@ reserve("__asm__",ASM); #endif - heap_init(); codegen_reinit(); macro_define("__restrict\n"); macro_define("__micro_c__ 1\n"); @@ -438,8 +439,8 @@ save_cheap(&scheap,cheap); if (! *filename) filename="mcout"; - for (t=0,s=filename;(*cheap->ptr = *s++);cheap=increment_cheap(cheap,&p)) { - if (*s=='.') { + for (t=0,s=filename;(*cheap->ptr = *s);cheap=increment_cheap(cheap,&p)) { + if (*s++ =='.') { t=cheap->ptr; save_cheap(&scheap1,cheap); } @@ -450,8 +451,9 @@ *cheap->ptr='.'; } else { cheap->ptr[-1]='.'; - cheap = increment_cheap(cheap,&p); + cheap->ptr--; } + cheap = increment_cheap(cheap,&p); for(s = ext; *s; s++) { *cheap->ptr = *s; cheap = increment_cheap(cheap,&p); } @@ -464,7 +466,6 @@ newfile(void) { char *s; - struct cheap scheap; if (!first_newfile) { closing(); @@ -484,7 +485,6 @@ if(!ccout) { ccout = make_filename_with_extension(filep->name0,"s"); if ( (freopen(ccout,"w",stdout)) == NULL ) error(FILERR); - cheap = reset_cheap(&scheap); ccout=0; } opening(filep->name0); @@ -2908,7 +2908,7 @@ reset_cheap(struct cheap *scheap) { // go back to the kept curret cheap pointer - if (cheap==scheap) { + if (cheap==scheap->next) { cheap->ptr = scheap->ptr; } else { cheap->ptr = cheap->first; @@ -2923,11 +2923,11 @@ neqnamel(char *p,char *q,int len) { while(len-->0 && *p++ == *q++); - return len!=0; + return len!=-1; } static NMTBL * -hash_search(char *name,struct cheap *scheap,int len,int hash) +hash_search(char *name,struct cheap *scheap,int len,unsigned int hash) { NMTBL *hptr,**iptr,**eptr; @@ -2946,6 +2946,7 @@ } else { cheap = reset_cheap(scheap); } + *iptr = hptr; return hptr; } @@ -2954,7 +2955,7 @@ { /* no name copy */ int ch,i = 0; - int hash0 = 0; + unsigned int hash0 = 0; char *n = name; struct cheap scheap; @@ -2972,7 +2973,7 @@ get_name_from_chptr() { int i = 0; - int hash0 = 0; + unsigned int hash0 = 0; char *name = cheap->ptr; struct cheap scheap; @@ -2992,7 +2993,7 @@ { char *name = cheap->ptr; int i= 0; - int hash = 0; + unsigned int hash = 0; struct cheap scheap; save_cheap(&scheap,cheap); @@ -3211,10 +3212,11 @@ } /* define case */ for(ns=nlist->dsp;ns;ns=cadr(ns)) { - if (car(ns)==sc) { + 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; @@ -3418,14 +3420,14 @@ n->nm = hash->nm; n->sc = EMPTY; n->dsp = 0; - return (nptr = n); + return n; } static NMTBL * lsearch(char *name,int sc) { return - (nptr = name_space_search(name_space_search(get_name(name,0),LDECL),sc)); + name_space_search(name_space_search(get_name(name,0),LDECL),sc); } static void
--- a/mc-parse.h Fri Jul 02 07:19:15 2004 +0900 +++ b/mc-parse.h Fri Jul 02 14:14:24 2004 +0900 @@ -105,6 +105,7 @@ extern struct cheap *cheap; extern NMTBL *get_name(char *name,int *i); +extern NMTBL * get_name_from_chptr(); extern NMTBL *name_space_search(NMTBL *ns,int sc); extern int getsym(int sc);