From f0b1882a416bbba2cdf0de8cf5488f74687a8dc4 Mon Sep 17 00:00:00 2001 From: Nick Downing Date: Sun, 12 Feb 2017 16:31:09 +1100 Subject: [PATCH] Change structure tags in struct nmlist to be prefixed by nl_ --- c00.c | 80 ++++++++++++------------ c01.c | 66 ++++++++++---------- c02.c | 142 +++++++++++++++++++++--------------------- c03.c | 180 ++++++++++++++++++++++++++--------------------------- c04.c | 34 +++++----- ccom.h | 22 +++---- fields.sed | 22 +++++++ 7 files changed, 284 insertions(+), 262 deletions(-) diff --git a/c00.c b/c00.c index 94d00fb..dd99db7 100644 --- a/c00.c +++ b/c00.c @@ -141,28 +141,28 @@ int lookup() { return(KEYW); rp = hshtab[ihash]; while (rp) { - if (strcmp(symbuf, rp->name) != 0) + if (strcmp(symbuf, rp->nl_name) != 0) goto no; - if (mossym != (rp->hflag&FKIND)) + if (mossym != (rp->nl_flag&FKIND)) goto no; csym = rp; return(NAME); no: - rp = rp->nextnm; + rp = rp->nl_nextnm; } rp = (struct nmlist *)Dblock(sizeof(struct nmlist)); - rp->nextnm = hshtab[ihash]; + rp->nl_nextnm = hshtab[ihash]; hshtab[ihash] = rp; - rp->hclass = 0; - rp->htype = 0; - rp->hoffset = 0; - rp->hsubsp = NULL; - rp->hstrp = NULL; - rp->sparent = NULL; - rp->hblklev = blklev; - rp->hflag = mossym; - rp->name = Dblock((strlen(symbuf) + 1 + LNCPW - 1) & ~(LNCPW - 1)); - strcpy(rp->name, symbuf); + rp->nl_class = 0; + rp->nl_type = 0; + rp->nl_offset = 0; + rp->nl_subsp = NULL; + rp->nl_strp = NULL; + rp->nl_sparent = NULL; + rp->nl_blklev = blklev; + rp->nl_flag = mossym; + rp->nl_name = Dblock((strlen(symbuf) + 1 + LNCPW - 1) & ~(LNCPW - 1)); + strcpy(rp->nl_name, symbuf); csym = rp; return(NAME); } @@ -648,21 +648,21 @@ advanc: case NAME: cs = csym; - if (cs->hclass==TYPEDEF) + if (cs->nl_class==TYPEDEF) goto atype; - if (cs->hclass==ENUMCON) { - *cp++ = (struct node *)cblock(cs->hoffset); + if (cs->nl_class==ENUMCON) { + *cp++ = (struct node *)cblock(cs->nl_offset); goto tand; } - if (cs->hclass==0 && cs->htype==0) + if (cs->nl_class==0 && cs->nl_type==0) if(nextchar()=='(') { /* set function */ - cs->hclass = EXTERN; - cs->htype = FUNC; + cs->nl_class = EXTERN; + cs->nl_type = FUNC; } else { - cs->hclass = STATIC; - error0("%s undefined; func. %s", cs->name, - funcsym ? funcsym->name : "(none)"); + cs->nl_class = STATIC; + error0("%s undefined; func. %s", cs->nl_name, + funcsym ? funcsym->nl_name : "(none)"); } *cp++ = (struct node *)nblock(cs); goto tand; @@ -710,18 +710,18 @@ advanc: else putstr(cval, 0); cs = (struct nmlist *)Tblock(sizeof(struct nmlist)); - cs->hclass = STATIC; - /* cs->hoffset = cval; + cs->nl_class = STATIC; + /* cs->nl_offset = cval; *cp++ = block(NAME, unscflg? ARRAY+UNCHAR:ARRAY+CHAR, &nchstr, (union str *)NULL, (struct node *)cs, (struct node *)NULL);*/ - cs->hflag = 0; - cs->htype = unscflg? ARRAY+UNCHAR:ARRAY+CHAR; - cs->hstrp = (union str *)&nchstr; - cs->hoffset = cval; - cs->nextnm = 0; - cs->sparent = 0; - cs->hblklev = 0; - cs->name = 0; + cs->nl_flag = 0; + cs->nl_type = unscflg? ARRAY+UNCHAR:ARRAY+CHAR; + cs->nl_strp = (union str *)&nchstr; + cs->nl_offset = cval; + cs->nl_nextnm = 0; + cs->nl_sparent = 0; + cs->nl_blklev = 0; + cs->nl_name = 0; *cp++ = (struct node *)nblock(cs); tand: @@ -922,15 +922,15 @@ struct tnode *xprtype() { scp = cp; sc = DEFXTRN; /* will cause error if class mentioned */ getkeywords(&sc, &typer); - absname.hclass = 0; - absname.hblklev = blklev; - absname.hsubsp = NULL; - absname.hstrp = NULL; - absname.htype = 0; + absname.nl_class = 0; + absname.nl_blklev = blklev; + absname.nl_subsp = NULL; + absname.nl_strp = NULL; + absname.nl_type = 0; decl1(sc, &typer, 0, &absname); cp = scp; - return(block(ETYPE, absname.htype, absname.hsubsp, - absname.hstrp, (struct node *)NULL, (struct node *)NULL)); + return(block(ETYPE, absname.nl_type, absname.nl_subsp, + absname.nl_strp, (struct node *)NULL, (struct node *)NULL)); } /*char *copnum(len) int len; { diff --git a/c01.c b/c01.c index 58da0d2..b2c57f2 100644 --- a/c01.c +++ b/c01.c @@ -180,7 +180,7 @@ void build(op) int op; { * then * is tacked on to access the member. */ case ARROW: - if (p2->n_op!=NAME || ((struct nnode *)p2)->nn_nmlist->hclass!=MOS) { + if (p2->n_op!=NAME || ((struct nnode *)p2)->nn_nmlist->nl_class!=MOS) { error0("Illegal structure ref"); *cp++ = p1; return; @@ -188,21 +188,21 @@ void build(op) int op; { #define np2 ((struct nnode *)p2) structident(p1, np2); t2 = np2->nn_type; - if (t2==INT && np2->nn_nmlist->hflag&FFIELD) + if (t2==INT && np2->nn_nmlist->nl_flag&FFIELD) t2 = UNSIGN; t = incref0(t2); chkw(p1, -1); setype(p1, t, (struct node *)np2); *cp++ = (struct node *)block(PLUS, t, np2->nn_subsp, np2->nn_strp, - p1, (struct node *)cblock(np2->nn_nmlist->hoffset)); + p1, (struct node *)cblock(np2->nn_nmlist->nl_offset)); build(STAR); - if (np2->nn_nmlist->hflag&FFIELD) + if (np2->nn_nmlist->nl_flag&FFIELD) #if 1 cp[-1] = (struct node *)block(FSEL, UNSIGN, (int *)NULL, (union str *)NULL, - cp[-1], (struct node *)np2->nn_nmlist->hstrp); + cp[-1], (struct node *)np2->nn_nmlist->nl_strp); #else *cp++ = (struct node *)block(FSEL, UNSIGN, (int *)NULL, (union str *)NULL, - *--cp, (struct node *)np2->nn_nmlist->hstrp); + *--cp, (struct node *)np2->nn_nmlist->nl_strp); #endif return; #undef np2 @@ -394,30 +394,30 @@ void structident(p1, p2) register struct node *p1; register struct nnode *p2; { np = nporig = p2->nn_nmlist; for (;;) { - if (namesame && p1->n_type==STRUCT+PTR && p1->n_strp == np->sparent) { - p2->nn_type = np->htype; - p2->nn_strp = np->hstrp; - p2->nn_subsp = np->hsubsp; + if (namesame && p1->n_type==STRUCT+PTR && p1->n_strp == np->nl_sparent) { + p2->nn_type = np->nl_type; + p2->nn_strp = np->nl_strp; + p2->nn_subsp = np->nl_subsp; p2->nn_nmlist = np; return; } - np = np->nextnm; + np = np->nl_nextnm; if (np==NULL) break; namesame = 0; - if (strcmp(nporig->name, np->name) != 0) + if (strcmp(nporig->nl_name, np->nl_name) != 0) continue; - if ((nporig->hflag&FKIND) != (np->hflag&FMOS)) + if ((nporig->nl_flag&FKIND) != (np->nl_flag&FMOS)) continue; namesame = 1; - if (nporig->htype==np->htype && nporig->hoffset==np->hoffset) + if (nporig->nl_type==np->nl_type && nporig->nl_offset==np->nl_offset) continue; vartypes++; } if (vartypes) - error0("Ambiguous structure reference for %s",nporig->name); + error0("Ambiguous structure reference for %s",nporig->nl_name); else - werror0("%s not member of cited struct/union",nporig->name); + werror0("%s not member of cited struct/union",nporig->nl_name); } /* @@ -481,7 +481,7 @@ struct node *disarray(p) register struct node *p; { return(p); /* check array & not MOS and not typer */ if (((t = p->n_type)&XTYPE)!=ARRAY - || p->n_op==NAME && ((struct nnode *)p)->nn_nmlist->hclass==MOS + || p->n_op==NAME && ((struct nnode *)p)->nn_nmlist->nl_class==MOS || p->n_op==ETYPE) return(p); p->n_subsp++; @@ -598,29 +598,29 @@ struct tnode *block(op, t, subs, str, p1, p2) int op; int t; int *subs; union st } struct nnode *nblock(ds) register struct nmlist *ds; { - /* return(block(NAME, ds->htype, ds->hsubsp, ds->hstrp, (struct node *)ds, (struct node *)NULL));*/ + /* return(block(NAME, ds->nl_type, ds->nl_subsp, ds->nl_strp, (struct node *)ds, (struct node *)NULL));*/ struct nnode *p; - if (ds->hclass == EXTERN) { + if (ds->nl_class == EXTERN) { #define extp (*(struct extnnode **)&p) extp = (struct extnnode *)Tblock(sizeof(struct extnnode)); - extp->extnn_name = Tblock((strlen(ds->name)+2+LNCPW-1) & ~(LNCPW-1)); + extp->extnn_name = Tblock((strlen(ds->nl_name)+2+LNCPW-1) & ~(LNCPW-1)); extp->extnn_name[0] = '_'; - strcpy(extp->extnn_name + 1, ds->name); + strcpy(extp->extnn_name + 1, ds->nl_name); #undef extp } else { #define locp (*(struct locnnode **)&p) locp = (struct locnnode *)Tblock(sizeof(struct locnnode)); - locp->locnn_nloc = ds->hoffset; + locp->locnn_nloc = ds->nl_offset; #undef locp } p->nn_op = NAME; - p->nn_type = ds->htype; - p->nn_subsp = ds->hsubsp; - p->nn_strp = ds->hstrp; + p->nn_type = ds->nl_type; + p->nn_subsp = ds->nl_subsp; + p->nn_strp = ds->nl_strp; p->nn_nmlist = ds; - p->nn_class = ds->hclass==0?STATIC:ds->hclass; + p->nn_class = ds->nl_class==0?STATIC:ds->nl_class; p->nn_regno = 0; p->nn_offset = 0; return p; @@ -982,14 +982,14 @@ struct nmlist *gentemp(type) int type; { register struct nmlist *tp; tp = (struct nmlist *)Tblock(sizeof(struct nmlist)); - tp->hclass = AUTO; - tp->htype = type; - tp->hflag = 0; - tp->hsubsp = NULL; - tp->hstrp = NULL; - tp->hblklev = blklev; + tp->nl_class = AUTO; + tp->nl_type = type; + tp->nl_flag = 0; + tp->nl_subsp = NULL; + tp->nl_strp = NULL; + tp->nl_blklev = blklev; autolen -= rlength((struct node *)tp); - tp->hoffset = autolen; + tp->nl_offset = autolen; if (autolen < maxauto) maxauto = autolen; return(tp); diff --git a/c02.c b/c02.c index 5c5ef01..d140ed7 100644 --- a/c02.c +++ b/c02.c @@ -43,14 +43,14 @@ void extdef() { if ((ds=defsym)==0) return; funcsym = ds; - if ((ds->htype&XTYPE)==FUNC) { + if ((ds->nl_type&XTYPE)==FUNC) { if ((peeksym=symbol())==LBRACE || peeksym==KEYW - || (peeksym==NAME && csym->hclass==TYPEDEF)) { + || (peeksym==NAME && csym->nl_class==TYPEDEF)) { /* create a fake local variable of same type as function's return type */ - funcblk.locnn_type = decref0(ds->htype); - funcblk.locnn_strp = ds->hstrp; + funcblk.locnn_type = decref0(ds->nl_type); + funcblk.locnn_strp = ds->nl_strp; setinit(ds); - outcode("BS", SYMDEF, sclass==EXTERN?ds->name:""); + outcode("BS", SYMDEF, sclass==EXTERN?ds->nl_name:""); cfunc(); return; } @@ -61,9 +61,9 @@ void extdef() { o = (length((struct node *)ds)+ALIGN) & ~ALIGN; if (sclass==STATIC) { setinit(ds); - outcode("BSBBSBN", SYMDEF, "", BSS, NLABEL, ds->name, SSPACE, o); + outcode("BSBBSBN", SYMDEF, "", BSS, NLABEL, ds->nl_name, SSPACE, o); } else if (scflag) - outcode("BSN", CSPACE, ds->name, o); + outcode("BSN", CSPACE, ds->nl_name, o); } else { if (o!=ASSIGN) { error0("Declaration syntax"); @@ -71,8 +71,8 @@ void extdef() { } setinit(ds); if (sclass==EXTERN) - outcode("BS", SYMDEF, ds->name); - outcode("BBS", DATA, NLABEL, ds->name); + outcode("BS", SYMDEF, ds->nl_name); + outcode("BBS", DATA, NLABEL, ds->nl_name); if (cinit(ds, 1, sclass) & ALIGN) outcode("B", EVEN); } @@ -99,7 +99,7 @@ void cfunc() { sloc = isn0; isn0 += 2; - outcode("BBS", PROG, RLABEL, funcsym->name); + outcode("BBS", PROG, RLABEL, funcsym->nl_name); regvar = 5; autolen = STAUTO; maxauto = STAUTO; @@ -108,7 +108,7 @@ void cfunc() { declist(ARG); outcode("B", SAVE); if (proflg) - outcode("BNS", PROFIL, isn0++, funcsym->name); + outcode("BNS", PROFIL, isn0++, funcsym->nl_name); funchead(); branch0(sloc); label0(sloc+1); @@ -136,7 +136,7 @@ int cinit(anp, flex, sclass) struct nmlist *anp; int flex; int sclass; { struct node *s; np = *anp; - realtype = np.htype; + realtype = np.nl_type; isarray = 0; if ((realtype&XTYPE) == ARRAY) isarray++; @@ -153,16 +153,16 @@ int cinit(anp, flex, sclass) struct nmlist *anp; int flex; int sclass; { if (isarray || realtype==STRUCT) error0("No auto. aggregate initialization"); if (isarray) { - np.htype = decref0(realtype); - np.hsubsp++; + np.nl_type = decref0(realtype); + np.nl_subsp++; if (width==0 && flex==0) - error0("0-length row: %s", anp->name); + error0("0-length row: %s", anp->nl_name); o = length((struct node *)&np); nel = (unsigned)width/o; width = o; } brace = 0; - if ((peeksym=symbol())==LBRACE && (isarray || np.htype!=STRUCT)) { + if ((peeksym=symbol())==LBRACE && (isarray || np.nl_type!=STRUCT)) { peeksym = -1; brace++; } @@ -179,9 +179,9 @@ int cinit(anp, flex, sclass) struct nmlist *anp; int flex; int sclass; { ninit += nchstr; o = symbol(); break; - } else if (np.htype==STRUCT) { + } else if (np.nl_type==STRUCT) { strinit(&np, sclass); - } else if ((np.htype&ARRAY)==ARRAY || peeksym==LBRACE) + } else if ((np.nl_type&ARRAY)==ARRAY || peeksym==LBRACE) cinit(&np, 0, sclass); else { char *st; @@ -189,7 +189,7 @@ int cinit(anp, flex, sclass) struct nmlist *anp; int flex; int sclass; { st = starttree(); s = tree(/*0*/); initflg = 0; - if (np.hflag&FFIELD) + if (np.nl_flag&FFIELD) error0("No field initialization"); *cp++ = (struct node *)nblock(&np); *cp++ = s; @@ -198,10 +198,10 @@ int cinit(anp, flex, sclass) struct nmlist *anp; int flex; int sclass; { rcexpr0(*--cp); else if (sclass==ENUMCON) { if (s->n_op!=CON) - error0("Illegal enum constant for %s", anp->name); - anp->hoffset = ((struct cnode *)s)->cn_value; + error0("Illegal enum constant for %s", anp->nl_name); + anp->nl_offset = ((struct cnode *)s)->cn_value; } else - rcexpr0((struct node *)block(INIT,np.htype,(int *)NULL, + rcexpr0((struct node *)block(INIT,np.nl_type,(int *)NULL, (union str *)NULL, ((struct tnode *)(*--cp))->tn_tr2, (struct node *)NULL)); endtree(st); } @@ -221,9 +221,9 @@ int cinit(anp, flex, sclass) struct nmlist *anp; int flex; int sclass; { outcode("BN", SSPACE, (nel-ninit)*width); else if (ninit>nel) { if (flex && nel==0) { - np.hsubsp[-1] = ninit; + np.nl_subsp[-1] = ninit; } else - error0("Too many initializers: %s", anp->name); + error0("Too many initializers: %s", anp->nl_name); nel = ninit; } return(nel*width); @@ -238,7 +238,7 @@ void strinit(np, sclass) struct nmlist *np; int sclass; { static struct nmlist *zerloc = NULL; register int o, brace; - if ((mlp = np->hstrp->S.memlist)==NULL) { + if ((mlp = np->nl_strp->S.memlist)==NULL) { mlp = &zerloc; error0("Undefined structure initialization"); } @@ -261,7 +261,7 @@ void strinit(np, sclass) struct nmlist *np; int sclass; { mlp++; } /* DAG -- union initialization bug fix */ - if (*mlp && mlp[-1]->hoffset == (*mlp)->hoffset) { + if (*mlp && mlp[-1]->nl_offset == (*mlp)->nl_offset) { werror0("union initialization non-portable"); while (*mlp) /* will NOT be &structhole */ mlp++; /* skip other members of union */ @@ -269,7 +269,7 @@ void strinit(np, sclass) struct nmlist *np; int sclass; { } while ((o=symbol())==COMMA && (*mlp || brace)); if (sclass!=AUTO && sclass!=REG) { if (*mlp) - outcode("BN", SSPACE, np->hstrp->S.ssize - (*mlp)->hoffset); + outcode("BN", SSPACE, np->nl_strp->S.ssize - (*mlp)->nl_offset); outcode("B", EVEN); } if (o!=RBRACE || brace==0) @@ -281,9 +281,9 @@ void strinit(np, sclass) struct nmlist *np; int sclass; { */ void setinit(np) register struct nmlist *np; { - if (np->hflag&FINIT) - error0("%s multiply defined", np->name); - np->hflag |= FINIT; + if (np->nl_flag&FINIT) + error0("%s multiply defined", np->nl_name); + np->nl_flag |= FINIT; } /* @@ -529,22 +529,22 @@ stmt: if (nextchar()==':') { peekc = 0; np = csym; - if (np->hclass>0) { - if (np->hblklev==0) { + if (np->nl_class>0) { + if (np->nl_blklev==0) { np = pushdecl(np); - np->hoffset = 0; + np->nl_offset = 0; } else { defsym = np; redec(); goto stmt; } } - np->hclass = STATIC; - np->htype = ARRAY; - np->hflag |= FLABL; - if (np->hoffset==0) - np->hoffset = isn0++; - label0(np->hoffset); + np->nl_class = STATIC; + np->nl_type = ARRAY; + np->nl_flag |= FLABL; + if (np->nl_offset==0) + np->nl_offset = isn0++; + label0(np->nl_offset); goto stmt; } } @@ -694,37 +694,37 @@ void funchead() { pl = STARG; while(paraml) { - parame->sparent = NULL; + parame->nl_sparent = NULL; cs = paraml; - paraml = ¶ml->sparent->P; - if (cs->htype==FLOAT) - cs->htype = DOUBLE; - cs->hoffset = pl; - if ((cs->htype&XTYPE) == ARRAY) { - cs->htype -= (ARRAY-PTR); /* set ptr */ - cs->hsubsp++; /* pop dims */ + paraml = ¶ml->nl_sparent->P; + if (cs->nl_type==FLOAT) + cs->nl_type = DOUBLE; + cs->nl_offset = pl; + if ((cs->nl_type&XTYPE) == ARRAY) { + cs->nl_type -= (ARRAY-PTR); /* set ptr */ + cs->nl_subsp++; /* pop dims */ } pl += rlength((struct node *)cs); - if (cs->hclass==AREG && (hreg.hoffset=goodreg(cs))>=0) { + if (cs->nl_class==AREG && (hreg.nl_offset=goodreg(cs))>=0) { st = starttree(); *cp++ = (struct node *)&areg; *cp++ = (struct node *)nblock(cs); - areg.locnn_type = cs->htype; - areg.locnn_strp = cs->hstrp; - cs->hclass = AUTO; + areg.locnn_type = cs->nl_type; + areg.locnn_strp = cs->nl_strp; + cs->nl_class = AUTO; build(ASSIGN); rcexpr0(*--cp); - cs->hoffset = hreg.hoffset; - cs->hclass = REG; + cs->nl_offset = hreg.nl_offset; + cs->nl_class = REG; endtree(st); } else - cs->hclass = AUTO; + cs->nl_class = AUTO; prste(cs); } for (pl=0; plnextnm) { - if (cs->hclass == ARG || cs->hclass==AREG) - error0("Not an argument: %s", cs->name); + for (cs = hshtab[pl]; cs!=NULL; cs = cs->nl_nextnm) { + if (cs->nl_class == ARG || cs->nl_class==AREG) + error0("Not an argument: %s", cs->nl_name); } } outcode("BN", SETREG, regvar); @@ -754,26 +754,26 @@ void blkend() { lcs = &hshtab[i]; cs = *lcs; while (cs) { - if (cs->hblklev > blklev - && (((cs->hflag&FLABL)==0 && cs->hclass!=EXTERN) || blklev<=0)) { - if (cs->hclass==0) - error0("%s undefined", cs->name); - if (cs->hclass==EXTERN) + if (cs->nl_blklev > blklev + && (((cs->nl_flag&FLABL)==0 && cs->nl_class!=EXTERN) || blklev<=0)) { + if (cs->nl_class==0) + error0("%s undefined", cs->nl_name); + if (cs->nl_class==EXTERN) nameconflict(hshtab[i], cs); - *lcs = cs->nextnm; + *lcs = cs->nl_nextnm; } else - lcs = &cs->nextnm; - cs = cs->nextnm; + lcs = &cs->nl_nextnm; + cs = cs->nl_nextnm; } } } void nameconflict(ocs, cs) register struct nmlist *ocs; register struct nmlist *cs; { - for (; ocs!=NULL; ocs = ocs->nextnm) - if (ocs!=cs && ocs->hclass==EXTERN && - strncmp(cs->name, ocs->name, MAXCPS-1) == 0) - error0("names %s and %s conflict", cs->name, ocs->name); + for (; ocs!=NULL; ocs = ocs->nl_nextnm) + if (ocs!=cs && ocs->nl_class==EXTERN && + strncmp(cs->nl_name, ocs->nl_name, MAXCPS-1) == 0) + error0("names %s and %s conflict", cs->nl_name, ocs->nl_name); } /* @@ -784,7 +784,7 @@ void nameconflict(ocs, cs) register struct nmlist *ocs; register struct nmlist * void prste(cs) struct nmlist *cs; { register int nkind; - switch (cs->hclass) { + switch (cs->nl_class) { case REG: nkind = RNAME; break; @@ -801,7 +801,7 @@ void prste(cs) struct nmlist *cs; { return; } - outcode("BSN", nkind, cs->name, cs->hoffset); + outcode("BSN", nkind, cs->nl_name, cs->nl_offset); } /* diff --git a/c03.c b/c03.c index 80971f1..e4c4760 100644 --- a/c03.c +++ b/c03.c @@ -36,21 +36,21 @@ int getkeywords(scptr, tptr) int *scptr; struct nmlist *tptr; { isadecl = 0; longf = 0; unsignf = 0; - tptr->htype = INT; - tptr->hstrp = NULL; - tptr->hsubsp = NULL; + tptr->nl_type = INT; + tptr->nl_strp = NULL; + tptr->nl_subsp = NULL; tkw = -1; skw = *scptr; ismos = skw==MOS||skw==MOU? FMOS: 0; for (;;) { mosflg = isadecl? ismos: 0; o = symbol(); - if (o==NAME && csym->hclass==TYPEDEF) { + if (o==NAME && csym->nl_class==TYPEDEF) { if (tkw >= 0) error0("type clash"); - tkw = csym->htype; - tptr->hsubsp = csym->hsubsp; - tptr->hstrp = csym->hstrp; + tkw = csym->nl_type; + tptr->nl_subsp = csym->nl_subsp; + tptr->nl_strp = csym->nl_strp; isadecl++; continue; } @@ -86,7 +86,7 @@ int getkeywords(scptr, tptr) int *scptr; struct nmlist *tptr; { case UNION: case STRUCT: - tptr->hstrp = strdec(ismos, cval); + tptr->nl_strp = strdec(ismos, cval); cval = STRUCT; case INT: case CHAR: @@ -130,7 +130,7 @@ int getkeywords(scptr, tptr) int *scptr; struct nmlist *tptr; { error0("Misplaced 'long'"); } *scptr = skw; - tptr->htype = tkw; + tptr->nl_type = tkw; return(1); } isadecl++; @@ -168,20 +168,20 @@ union str *strdec(mosf, kind) int mosf; int kind; { ssym = csym; mosflg = mosf; o = symbol(); - if (o==LBRACE && ssym->hblklevnl_blklevhclass && ssym->hclass!=tagkind) { + if (ssym->nl_class && ssym->nl_class!=tagkind) { defsym = ssym; redec(); ssym = pushdecl(ssym); } - if (ssym->hclass==0) { - ssym->hclass = tagkind; - ssym->hstrp = (union str *)Dblock(sizeof(struct SS)); - ssym->hstrp->S.ssize = 0; - ssym->hstrp->S.memlist = NULL; + if (ssym->nl_class==0) { + ssym->nl_class = tagkind; + ssym->nl_strp = (union str *)Dblock(sizeof(struct SS)); + ssym->nl_strp->S.ssize = 0; + ssym->nl_strp->S.memlist = NULL; } - strp = ssym->hstrp; + strp = ssym->nl_strp; } else { strp = (union str *)Dblock(sizeof(struct SS)); strp->S.ssize = 0; @@ -191,7 +191,7 @@ union str *strdec(mosf, kind) int mosf; int kind; { if (o != LBRACE) { if (ssym==0) goto syntax; - if (ssym->hclass!=tagkind) + if (ssym->nl_class!=tagkind) error0("Bad structure/union/enum name"); peeksym = o; } else { @@ -206,8 +206,8 @@ union str *strdec(mosf, kind) int mosf; int kind; { nmems = 2; bitoffs = 0; if (kind==ENUM) { - typer.htype = INT; - typer.hstrp = strp; + typer.nl_type = INT; + typer.nl_strp = strp; declare(ENUM, &typer, 0); } else elsize = declist(kind==UNION?MOU:MOS); @@ -221,7 +221,7 @@ union str *strdec(mosf, kind) int mosf; int kind; { #else defsym = ds; if (strp->S.ssize) - error0("%s redeclared", ssym->name); + error0("%s redeclared", ssym->nl_name); #endif strp->S.ssize = elsize; *memlist++ = NULL; @@ -267,15 +267,15 @@ int declare(askw, tptr, offset) int askw; struct nmlist *tptr; int offset; { break; } if (skw == MOS) { - abs.hclass = 0; - abs.hflag = 0; - abs.htype = 0; - abs.hsubsp = 0; - abs.hstrp = 0; - abs.nextnm = 0; - abs.sparent = 0; - abs.hblklev = blklev; - abs.name = ""; + abs.nl_class = 0; + abs.nl_flag = 0; + abs.nl_type = 0; + abs.nl_subsp = 0; + abs.nl_strp = 0; + abs.nl_nextnm = 0; + abs.nl_sparent = 0; + abs.nl_blklev = blklev; + abs.nl_name = ""; aptr = &abs; } else aptr = NULL; @@ -325,7 +325,7 @@ int decl1(askw, atptr, offset, absname) int askw; struct nmlist *atptr; int offs error0("Negative field width"); t1 = 0; } - elsize = align(tptr->htype, offset, t1); + elsize = align(tptr->nl_type, offset, t1); bitoffs += t1; return(elsize); } @@ -334,15 +334,15 @@ int decl1(askw, atptr, offset, absname) int askw; struct nmlist *atptr; int offs return(0); if (defsym) absname = NULL; - if (tptr->hsubsp) { - type = tptr->htype; + if (tptr->nl_subsp) { + type = tptr->nl_type; for (a=0; type&XTYPE;) { if ((type&XTYPE)==ARRAY) - dim.dimens[dim.rank++] = tptr->hsubsp[a++]; + dim.dimens[dim.rank++] = tptr->nl_subsp[a++]; type >>= TYLEN; } } - type = tptr->htype & ~TYPE; + type = tptr->nl_type & ~TYPE; while (t1&XTYPE) { if (type&BIGTYPE) { typov(); @@ -351,7 +351,7 @@ int decl1(askw, atptr, offset, absname) int askw; struct nmlist *atptr; int offs type = type<>= TYLEN; } - type |= tptr->htype&TYPE; + type |= tptr->nl_type&TYPE; if ((type&XTYPE) == FUNC) { if (skw==AUTO) skw = EXTERN; @@ -367,14 +367,14 @@ int decl1(askw, atptr, offset, absname) int askw; struct nmlist *atptr; int offs return(0); } if (defsym) - if (dsym->hblklevhclass==MOS && skw==MOS) { - if (skw==MOS && dsym->sparent==sparent) + if (dsym->nl_blklevnl_class==MOS && skw==MOS) { + if (skw==MOS && dsym->nl_sparent==sparent) redec(); defsym = dsym; if (skw==EXTERN) { - for (; dsym!=NULL; dsym = dsym->nextnm) { - if (dsym->hclass==EXTERN - && strcmp(dsym->name, defsym->name)==0) { + for (; dsym!=NULL; dsym = dsym->nl_nextnm) { + if (dsym->nl_class==EXTERN + && strcmp(dsym->nl_name, defsym->nl_name)==0) { defsym = dsym; break; } @@ -384,25 +384,25 @@ int decl1(askw, atptr, offset, absname) int askw; struct nmlist *atptr; int offs defsym = dsym = pushdecl(dsym); } if (dim.rank == 0) - dsym->hsubsp = NULL; + dsym->nl_subsp = NULL; else { /* * If an array is declared twice, make sure the declarations * agree in dimension. This happens typically when a .h * and .c file both declare a variable. */ - if (dsym->hsubsp) { - for (a=0, t1 = dsym->htype; + if (dsym->nl_subsp) { + for (a=0, t1 = dsym->nl_type; a>= TYLEN) /* * If we haven't seen a declaration for this * dimension yet, take what's been given now. */ - if (!dsym->hsubsp[a]) - dsym->hsubsp[a] = dim.dimens[a]; + if (!dsym->nl_subsp[a]) + dsym->nl_subsp[a] = dim.dimens[a]; else if (dim.dimens[a] - && dim.dimens[a] != dsym->hsubsp[a]) + && dim.dimens[a] != dsym->nl_subsp[a]) redec(); if (ahsubsp = dp; + dsym->nl_subsp = dp; } } - if (!(dsym->hclass==0 - || ((skw==ARG||skw==AREG) && dsym->hclass==ARG1) - || (skw==EXTERN && dsym->hclass==EXTERN && dsym->htype==type))) { + if (!(dsym->nl_class==0 + || ((skw==ARG||skw==AREG) && dsym->nl_class==ARG1) + || (skw==EXTERN && dsym->nl_class==EXTERN && dsym->nl_type==type))) { redec(); goto syntax; } - if (dsym->hclass && (dsym->htype&TYPE)==STRUCT && (type&TYPE)==STRUCT) - if (dsym->hstrp != tptr->hstrp) { + if (dsym->nl_class && (dsym->nl_type&TYPE)==STRUCT && (type&TYPE)==STRUCT) + if (dsym->nl_strp != tptr->nl_strp) { error0("structure redeclaration"); } - dsym->htype = type; - if (tptr->hstrp) - dsym->hstrp = tptr->hstrp; + dsym->nl_type = type; + if (tptr->nl_strp) + dsym->nl_strp = tptr->nl_strp; if (skw==TYPEDEF) { - dsym->hclass = TYPEDEF; + dsym->nl_class = TYPEDEF; return(0); } if (skw==ARG1) { if (paraml==NULL) paraml = dsym; else - parame->sparent = (union str *)dsym; + parame->nl_sparent = (union str *)dsym; parame = dsym; - dsym->hclass = skw; + dsym->nl_class = skw; return(0); } elsize = 0; @@ -447,16 +447,16 @@ int decl1(askw, atptr, offset, absname) int askw; struct nmlist *atptr; int offs peeksym = -1; t1 = conexp(); a = align(type, offset, t1); - if (dsym->hflag&FFIELD) { - if (dsym->hstrp->F.bitoffs!=bitoffs - || dsym->hstrp->F.flen!=t1) + if (dsym->nl_flag&FFIELD) { + if (dsym->nl_strp->F.bitoffs!=bitoffs + || dsym->nl_strp->F.flen!=t1) redec(); } else { - dsym->hstrp = (union str *)Dblock(sizeof(struct FS)); + dsym->nl_strp = (union str *)Dblock(sizeof(struct FS)); } - dsym->hflag |= FFIELD; - dsym->hstrp->F.bitoffs = bitoffs; - dsym->hstrp->F.flen = t1; + dsym->nl_flag |= FFIELD; + dsym->nl_strp->F.bitoffs = bitoffs; + dsym->nl_strp->F.flen = t1; bitoffs += t1; } else a = align(type, offset, 0); @@ -469,14 +469,14 @@ int decl1(askw, atptr, offset, absname) int askw; struct nmlist *atptr; int offs } if (a) *memlist++ = &structhole; - dsym->hoffset = offset; + dsym->nl_offset = offset; *memlist++ = dsym; - dsym->sparent = sparent; + dsym->nl_sparent = sparent; } if (skw==REG) - if ((dsym->hoffset = goodreg(dsym)) < 0) + if ((dsym->nl_offset = goodreg(dsym)) < 0) skw = AUTO; - dsym->hclass = skw; + dsym->nl_class = skw; isinit = 0; if ((a=symbol()) == ASSIGN) isinit++; @@ -484,14 +484,14 @@ int decl1(askw, atptr, offset, absname) int askw; struct nmlist *atptr; int offs peeksym = a; if (skw==AUTO) { /* if (STAUTO < 0) { */ - /*fprintf(stderr, "%s autolen %d -> ", dsym->name, autolen);*/ + /*fprintf(stderr, "%s autolen %d -> ", dsym->nl_name, autolen);*/ autolen -= rlength((struct node *)dsym); - dsym->hoffset = autolen; + dsym->nl_offset = autolen; if (autolen < maxauto) maxauto = autolen; /*fprintf(stderr, "%d maxauto %d\n", autolen, maxauto);*/ /* } else { */ - /* dsym->hoffset = autolen; */ + /* dsym->nl_offset = autolen; */ /* autolen += rlength(dsym); */ /* if (autolen > maxauto) */ /* maxauto = autolen; */ @@ -500,7 +500,7 @@ int decl1(askw, atptr, offset, absname) int askw; struct nmlist *atptr; int offs cinit(dsym, 0, AUTO); isinit = 0; } else if (skw==STATIC) { - dsym->hoffset = isn0; + dsym->nl_offset = isn0; if (isinit) { outcode("BBN", DATA, LABEL, isn0++); if (cinit(dsym, 1, STATIC) & ALIGN) @@ -515,12 +515,12 @@ int decl1(askw, atptr, offset, absname) int askw; struct nmlist *atptr; int offs isinit = 0; } else if (skw==ENUM) { if (type!=INT) - error0("Illegal enumeration %s", dsym->name); - dsym->hclass = ENUMCON; - dsym->hoffset = offset; + error0("Illegal enumeration %s", dsym->nl_name); + dsym->nl_class = ENUMCON; + dsym->nl_offset = offset; if (isinit) cinit(dsym, 0, ENUMCON); - elsize = dsym->hoffset-offset+1; + elsize = dsym->nl_offset-offset+1; isinit = 0; } if (absname==0) @@ -540,16 +540,16 @@ struct nmlist *pushdecl(sp) register struct nmlist *sp; { nsp = (struct nmlist *)Dblock(sizeof(struct nmlist)); *nsp = *sp; - nsp->hclass = 0; - nsp->hflag &= FKIND; - nsp->htype = 0; - nsp->hoffset = 0; - nsp->hblklev = blklev; - nsp->hstrp = NULL; - nsp->hsubsp = NULL; - nsp->sparent = NULL; - hsp = &hshtab[hash(sp->name)]; - nsp->nextnm = *hsp; + nsp->nl_class = 0; + nsp->nl_flag &= FKIND; + nsp->nl_type = 0; + nsp->nl_offset = 0; + nsp->nl_blklev = blklev; + nsp->nl_strp = NULL; + nsp->nl_subsp = NULL; + nsp->nl_sparent = NULL; + hsp = &hshtab[hash(sp->nl_name)]; + nsp->nl_nextnm = *hsp; *hsp = nsp; return(nsp); } @@ -711,7 +711,7 @@ void decsyn(o) int o; { * Complain about a redeclaration */ void redec() { - error0("%s redeclared", defsym->name); + error0("%s redeclared", defsym->nl_name); } /* @@ -721,7 +721,7 @@ void redec() { int goodreg(hp) struct nmlist *hp; { int type; - type = hp->htype; + type = hp->nl_type; if ((type!=INT && type!=UNSIGN && (type&XTYPE)==0) || (type&XTYPE)>PTR || regvar<3) return(-1); diff --git a/c04.c b/c04.c index f928733..9decee6 100644 --- a/c04.c +++ b/c04.c @@ -111,19 +111,19 @@ void treeout(tp, isstruct) register struct node *tp; int isstruct; { case NAME: hp = (struct nmlist *)tp->tn_tr1; - if (hp->hclass==TYPEDEF) + if (hp->nl_class==TYPEDEF) error0("Illegal use of type name"); #if 1 - if (hp->hclass==EXTERN) - outcode("BNNS", NAME, EXTERN, tp->tn_type, hp->name); + if (hp->nl_class==EXTERN) + outcode("BNNS", NAME, EXTERN, tp->tn_type, hp->nl_name); else - outcode("BNNN", NAME, hp->hclass==0?STATIC:hp->hclass, tp->tn_type, hp->hoffset); + outcode("BNNN", NAME, hp->nl_class==0?STATIC:hp->nl_class, tp->tn_type, hp->nl_offset); #else - outcode("BNN", NAME, hp->hclass==0?STATIC:hp->hclass, tp->tn_type); - if (hp->hclass==EXTERN) - outcode("S", hp->name); + outcode("BNN", NAME, hp->nl_class==0?STATIC:hp->nl_class, tp->tn_type); + if (hp->nl_class==EXTERN) + outcode("S", hp->nl_name); else - outcode("N", hp->hoffset); + outcode("N", hp->nl_offset); #endif break; @@ -287,18 +287,18 @@ int simplegoto() { if ((peeksym=symbol())==NAME && nextchar()==';') { csp = csym; - if (csp->hblklev == 0) + if (csp->nl_blklev == 0) csp = pushdecl(csp); - if (csp->hclass==0 && csp->htype==0) { - csp->htype = ARRAY; - csp->hflag |= FLABL; - if (csp->hoffset==0) - csp->hoffset = isn0++; + if (csp->nl_class==0 && csp->nl_type==0) { + csp->nl_type = ARRAY; + csp->nl_flag |= FLABL; + if (csp->nl_offset==0) + csp->nl_offset = isn0++; } - if ((csp->hclass==0||csp->hclass==STATIC) - && csp->htype==ARRAY) { + if ((csp->nl_class==0||csp->nl_class==STATIC) + && csp->nl_type==ARRAY) { peeksym = -1; - return(csp->hoffset); + return(csp->nl_offset); } } return(0); diff --git a/ccom.h b/ccom.h index 99e9b2b..1cc3c98 100644 --- a/ccom.h +++ b/ccom.h @@ -29,17 +29,17 @@ typedef struct { uint32_t l; uint32_t h; } _DOUBLE; */ struct nmlist { /* note: this must be compatible with struct node in respect of the */ - /* htype and hsubsp fields, because of length(), rlength() computations */ - char hclass; /* storage class */ - char hflag; /* various flags */ - int htype; /* type */ - int *hsubsp; /* subscript list */ - union str *hstrp; /* structure description */ - int hoffset; /* post-allocation location */ - struct nmlist *nextnm; /* next name in chain */ - union str *sparent; /* Structure of which this is member */ - char hblklev; /* Block level of definition */ - char *name; /* ASCII name */ + /* nl_type, nl_subsp fields, because of length(), rlength() computations */ + char nl_class; /* storage class */ + char nl_flag; /* various flags */ + int nl_type; /* type */ + int *nl_subsp; /* subscript list */ + union str *nl_strp; /* structure description */ + int nl_offset; /* post-allocation location */ + struct nmlist *nl_nextnm; /* next name in chain */ + union str *nl_sparent; /* Structure of which this is member */ + char nl_blklev; /* Block level of definition */ + char *nl_name; /* ASCII name */ }; /* diff --git a/fields.sed b/fields.sed index 5bf36b7..cf5685b 100644 --- a/fields.sed +++ b/fields.sed @@ -72,5 +72,27 @@ s/@F@\.@tr2@/@fa_tr2@/g s/@F@\.@degree@/@fa_degree@/g s/@F@\.@mask@/@fa_mask@/g +# nmlist +s/\.@hclass@/.@nl_class@/g +s/\.@hflag@/.@nl_flag@/g +s/\.@htype@/.@nl_type@/g +s/\.@hsubsp@/.@nl_subsp@/g +s/\.@hstrp@/.@nl_strp@/g +s/\.@hoffset@/.@nl_offset@/g +s/\.@nextnm@/.@nl_nextnm@/g +s/\.@sparent@/.@nl_sparent@/g +s/\.@hblklev@/.@nl_blklev@/g +s/\.@name@/.@nl_name@/g +s/->@hclass@/->@nl_class@/g +s/->@hflag@/->@nl_flag@/g +s/->@htype@/->@nl_type@/g +s/->@hsubsp@/->@nl_subsp@/g +s/->@hstrp@/->@nl_strp@/g +s/->@hoffset@/->@nl_offset@/g +s/->@nextnm@/->@nl_nextnm@/g +s/->@sparent@/->@nl_sparent@/g +s/->@hblklev@/->@nl_blklev@/g +s/->@name@/->@nl_name@/g + s/@//g s/ATSIGN/@/g -- 2.34.1