/*int*/struct type *getkeywords __P((int *scptr/*, struct nmlist *tptr*/));
/*union str*/struct stype *strdec __P((int mosf, int kind));
int declare __P((int askw, struct /*nmlist*/type *tptr, int offset));
+int XXXoldtype __P((struct type *dtype, struct tdim *dimp, struct SS **strp));
int decl1 __P((int askw, struct /*nmlist*/type *atptr, int offset, struct nmlist *absname));
struct nmlist *pushdecl __P((register struct nmlist *sp));
/*int getype __P((register struct tdim *dimp, struct nmlist *absname));*/
rp->nl_nextnm = hshtab[ihash];
hshtab[ihash] = rp;
rp->nl_class = 0;
- rp->nl_type = 0;
+ /* rp->nl_type = 0;*/
rp->nl_offset = 0;
- rp->nl_subsp = NULL;
- rp->nl_strp = NULL;
+ /* rp->nl_subsp = NULL;
+ rp->nl_strp = NULL;*/
rp->nl_dtype = NULL;
rp->nl_sparent = NULL;
rp->nl_blklev = blklev;
int p, ps, os, xo = 0, *xop;
/*char *svtree;*/
static struct cnode garbage = { { CON, INT, (int *)NULL, (union str *)NULL}, 0 };
+ static struct type t_int = {INT};
+ static struct ftype t_func_int = {{{FUNC}, &t_int}, (struct nmlist **)NULL};
+ static struct type t_char = {CHAR};
+ static struct type t_unchar = {UNCHAR};
/*svtree = starttree();*/
op = opst;
*cp++ = (struct node *)cblock(cs->nl_offset);
goto tand;
}
- if (cs->nl_class==0 && cs->nl_type==0)
+ if (cs->nl_class==0 && /*cs->nl_type==0*/cs->nl_dtype==NULL)
if(nextchar()=='(') {
/* set function */
cs->nl_class = EXTERN;
- cs->nl_type = FUNC;
+ /* cs->nl_type = FUNC;*/
+ cs->nl_dtype = (struct type *)&t_func_int;
} else {
cs->nl_class = STATIC;
error0("%s undefined; func. %s", cs->nl_name,
*cp++ = block(NAME, unscflg? ARRAY+UNCHAR:ARRAY+CHAR, &nchstr,
(union str *)NULL, (struct node *)cs, (struct node *)NULL);*/
cs->nl_flag = 0;
- cs->nl_type = unscflg? ARRAY+UNCHAR:ARRAY+CHAR;
+ /* cs->nl_type = unscflg? ARRAY+UNCHAR:ARRAY+CHAR;
cs->nl_subsp = &nchstr;
- cs->nl_strp = (union str *)NULL;
+ cs->nl_strp = (union str *)NULL;*/
+ cs->nl_dtype = (struct type *)Tblock(sizeof(struct atype));
+ ((struct atype *)cs->nl_dtype)->at_id = REF | ARRAY;
+ ((struct atype *)cs->nl_dtype)->at_reftype = unscflg ? &t_unchar : &t_char;
+ ((struct atype *)cs->nl_dtype)->at_nelt = nchstr;
cs->nl_offset = cval;
cs->nl_nextnm = 0;
cs->nl_sparent = 0;
int sc;
register struct node **scp;
struct type *dtype;
+ struct tdim dim;
+ int type;
+ union str *strp;
+ int *subsp, a;
scp = cp;
sc = DEFXTRN; /* will cause error if class mentioned */
dtype = getkeywords(&sc);
absname.nl_class = 0;
absname.nl_blklev = blklev;
- absname.nl_subsp = NULL;
+ /* absname.nl_subsp = NULL;
absname.nl_strp = NULL;
- absname.nl_type = 0;
+ absname.nl_type = 0;*/
absname.nl_dtype = NULL;
decl1(sc, /*&typer*/dtype, 0, &absname);
cp = scp;
- return(block(ETYPE, absname.nl_type, absname.nl_subsp,
- absname.nl_strp, (struct node *)NULL, (struct node *)NULL));
+ dim.rank = 0;
+ type = XXXoldtype(absname.nl_dtype, &dim, (struct SS **)&strp);
+ subsp = dim.rank ? (int *)Tblock(dim.rank*sizeof(dim.rank)) : NULL;
+ for (a=0; a<dim.rank; a++)
+ subsp[a] = dim.dimens[a];
+ return(block(ETYPE, /*absname.nl_*/type, /*absname.nl_*/subsp,
+ /*absname.nl_*/strp, (struct node *)NULL, (struct node *)NULL));
}
/*char *copnum(len) int len; {
case AMPER:
if (p1->n_op==NAME || p1->n_op==STAR) {
- /*fprintf(stderr, "amper %p type %x strp %p\n", p1, p1->n_type, p1->n_strp);*/
*cp++ = (struct node *)block(op,incref0(p1->n_type),p1->n_subsp,p1->n_strp,p1,(struct node *)NULL);
return;
}
}
}
+int XXXeqtype(struct type *t0, struct type *t1) {
+ while (t0->t_id == t1->t_id) {
+ if ((t0->t_id & TYPE) != REF)
+ return 1;
+ t0 = ((struct rtype *)t0)->rt_reftype;
+ t1 = ((struct rtype *)t1)->rt_reftype;
+ }
+ return 0;
+}
void structident(p1, p2) register struct node *p1; register struct nnode *p2; {
register struct nmlist *np, *nporig;
int vartypes = 0, namesame = 1;
+ struct tdim dim;
+ int a;
/*fprintf(stderr, "structident %p op %d type %x strp %p field %s\n", p1, p1->n_op, p1->n_type, p1->n_strp, p2->nn_nmlist->nl_name);*/
np = nporig = p2->nn_nmlist;
for (;;) {
if (namesame && p1->n_type==STRUCT+PTR && p1->n_strp == np->nl_sparent) {
/*fprintf(stderr, "found %p type %x strp %p\n", np, np->nl_type, np->nl_strp);*/
- p2->nn_type = np->nl_type;
+ /* p2->nn_type = np->nl_type;
p2->nn_strp = np->nl_strp;
- p2->nn_subsp = np->nl_subsp;
+ p2->nn_subsp = np->nl_subsp;*/
+ dim.rank = 0;
+ p2->nn_type = XXXoldtype(np->nl_dtype, &dim, (struct SS **)&p2->nn_strp);
+ p2->nn_subsp = dim.rank ? (int *)Tblock(dim.rank*sizeof(dim.rank)) : NULL;
+ for (a=0; a<dim.rank; a++)
+ p2->nn_subsp[a] = dim.dimens[a];
p2->nn_nmlist = np;
return;
}
if ((nporig->nl_flag&FKIND) != (np->nl_flag&FMOS))
continue;
namesame = 1;
- if (nporig->nl_type==np->nl_type && nporig->nl_offset==np->nl_offset)
+ if (/*nporig->nl_type==np->nl_type*/XXXeqtype(nporig->nl_dtype, np->nl_dtype) && nporig->nl_offset==np->nl_offset)
continue;
vartypes++;
}
vfprintf(stderr, s, argp);
va_end(argp);
fprintf(stderr, "\n");
+ abort();
}
#ifdef __STDC__
vfprintf(stderr, s, argp);
va_end(argp);
fprintf(stderr, "\n");
+ abort();
}
/*
struct nnode *nblock(ds) register struct nmlist *ds; {
/* return(block(NAME, ds->nl_type, ds->nl_subsp, ds->nl_strp, (struct node *)ds, (struct node *)NULL));*/
struct nnode *p;
+ struct tdim dim;
+ int a;
if (ds->nl_class == EXTERN) {
#define extp (*(struct extnnode **)&p)
}
/*fprintf(stderr, "nblock %p name %s type %x strp %p\n", p, ds->nl_name, ds->nl_type, ds->nl_strp);*/
p->nn_op = NAME;
- p->nn_type = ds->nl_type;
+ /* p->nn_type = ds->nl_type;
p->nn_subsp = ds->nl_subsp;
- p->nn_strp = ds->nl_strp;
- /*p->nn_dtype = ds->nl_dtype;*/
+ p->nn_strp = ds->nl_strp;*/
+ dim.rank = 0;
+ p->nn_type = XXXoldtype(ds->nl_dtype, &dim, (struct SS **)&p->nn_strp);
+ p->nn_subsp = dim.rank ? (int *)Tblock(dim.rank*sizeof(dim.rank)) : NULL;
+ for (a=0; a<dim.rank; a++)
+ p->nn_subsp[a] = dim.dimens[a];
p->nn_nmlist = ds;
p->nn_class = ds->nl_class==0?STATIC:ds->nl_class;
p->nn_regno = 0;
tp = (struct nmlist *)Tblock(sizeof(struct nmlist));
tp->nl_class = AUTO;
- tp->nl_type = type;
+ /* tp->nl_type = type;*/
tp->nl_flag = 0;
- tp->nl_subsp = NULL;
- tp->nl_strp = NULL;
+ /* tp->nl_subsp = NULL;
+ tp->nl_strp = NULL;*/
tp->nl_dtype = basic_types + type;
tp->nl_blklev = blklev;
autolen -= rlength(/*(struct node *)tp*/tp->nl_dtype);
/* struct nmlist typer;*/
struct type *dtype;
register struct nmlist *ds;
+ struct tdim dim;
+ int a;
if(((o=symbol())==EOFC) || o==SEMI)
return;
if ((peeksym=symbol())==LBRACE || peeksym==KEYW
|| (peeksym==NAME && csym->nl_class==TYPEDEF)) {
/* create a fake local variable of same type as function's return type */
- funcblk.locnn_type = decref0(ds->nl_type);
- funcblk.locnn_strp = ds->nl_strp;
- /*funcblk.locnn_dtype = ds->nl_dtype;*/
+ /* funcblk.locnn_type = decref0(ds->nl_type);
+ funcblk.locnn_strp = ds->nl_strp;*/
+ dim.rank = 0;
+ funcblk.locnn_type = XXXoldtype(((struct ftype *)ds->nl_dtype)->ft_reftype, &dim, (struct SS **)&funcblk.locnn_strp);
+ funcblk.locnn_subsp = dim.rank ? (int *)Tblock(dim.rank*sizeof(dim.rank)) : NULL;
+ for (a=0; a<dim.rank; a++)
+ funcblk.locnn_subsp[a] = dim.dimens[a];
setinit(ds);
outcode("BS", SYMDEF, sclass==EXTERN?ds->nl_name:"");
cfunc();
int cinit(anp, flex, sclass) struct nmlist *anp; int flex; int sclass; {
struct nmlist np;
register int nel, ninit;
- int width, isarray, o, brace, realtype;
+ int width, isarray, o, brace/*, realtype*/;
+ struct type *realtype;
struct node *s;
+ struct tdim dim;
+ int type;
+ union str *strp;
+ int *subsp, a;
np = *anp;
- realtype = np.nl_type;
+ realtype = /*np.nl_type*/np.nl_dtype;
isarray = 0;
- if ((realtype&XTYPE) == ARRAY)
+ if (/*(realtype&XTYPE) == ARRAY*/realtype->t_id == (REF | ARRAY))
isarray++;
else
flex = 0;
* an array of.
*/
if (sclass==AUTO)
- if (isarray || realtype==STRUCT)
+ if (isarray || /*realtype*/realtype->t_id==STRUCT)
error0("No auto. aggregate initialization");
if (isarray) {
- np.nl_type = decref0(realtype);
- np.nl_subsp++;
- np.nl_dtype = ((struct atype *)np.nl_dtype)->at_reftype;
+ /* np.nl_type = decref0(realtype);
+ np.nl_subsp++;*/
+ np.nl_dtype = ((struct atype *)realtype)->at_reftype;
if (width==0 && flex==0)
error0("0-length row: %s", anp->nl_name);
o = length(/*(struct node *)&np*/np.nl_dtype);
width = o;
}
brace = 0;
- if ((peeksym=symbol())==LBRACE && (isarray || np.nl_type!=STRUCT)) {
+ if ((peeksym=symbol())==LBRACE && (isarray || /*np.nl_type*/np.nl_dtype->t_id!=STRUCT)) {
peeksym = -1;
brace++;
}
if ((o=symbol())==RBRACE)
break;
peeksym = o;
- if (o==STRING && (realtype==ARRAY+CHAR || realtype==ARRAY+UNCHAR)) {
+ if (o==STRING && /*(realtype==ARRAY+CHAR || realtype==ARRAY+UNCHAR)*/realtype->t_id == (REF | ARRAY) && (((struct atype *)realtype)->at_reftype->t_id == CHAR || ((struct atype *)realtype)->at_reftype->t_id == UNCHAR)) {
if (sclass==AUTO)
error0("No strings in automatic");
peeksym = -1;
ninit += nchstr;
o = symbol();
break;
- } else if (np.nl_type==STRUCT) {
+ } else if (/*np.nl_type*/np.nl_dtype->t_id==STRUCT) {
strinit(&np, sclass);
- } else if ((np.nl_type&ARRAY)==ARRAY || peeksym==LBRACE)
+ } else if (/*(np.nl_type&ARRAY)==ARRAY*/np.nl_dtype->t_id==(REF|ARRAY) || peeksym==LBRACE)
cinit(&np, 0, sclass);
else {
char *st;
error0("Illegal enum constant for %s", anp->nl_name);
anp->nl_offset = ((struct cnode *)s)->cn_value;
} else
- rcexpr0((struct node *)block(INIT,np.nl_type,(int *)NULL,
- (union str *)NULL, ((struct tnode *)(*--cp))->tn_tr2, (struct node *)NULL));
+ {
+ dim.rank = 0;
+ type = XXXoldtype(np.nl_dtype, &dim, (struct SS **)&strp);
+ subsp = dim.rank ? (int *)Tblock(dim.rank*sizeof(dim.rank)) : NULL;
+ for (a=0; a<dim.rank; a++)
+ subsp[a] = dim.dimens[a];
+ rcexpr0((struct node *)block(INIT,/*np.nl_type*/type,/*(int *)NULL*/subsp,
+ /*(union str *)NULL*/strp, ((struct tnode *)(*--cp))->tn_tr2, (struct node *)NULL));
+ }
endtree(st);
}
ninit++;
outcode("BN", SSPACE, (nel-ninit)*width);
else if (ninit>nel) {
if (flex && nel==0) {
- np.nl_subsp[-1] = ninit;
+ /* note: nel==0 implies isarray, since otherwise nel must be 1 */
+ /* np.nl_subsp[-1] = ninit;*/
+#define arealtype (*(struct atype **)&realtype)
+ arealtype = (struct atype *)Dblock(sizeof(struct atype));
+ arealtype->at_id = REF | ARRAY;
+ arealtype->at_reftype = np.nl_dtype;
+ arealtype->at_nelt = ninit;
+ anp->nl_dtype = (struct type *)arealtype;
+#undef arealtype
} else
error0("Too many initializers: %s", anp->nl_name);
nel = ninit;
* Initialize a structure
*/
void strinit(np, sclass) struct nmlist *np; int sclass; {
- static struct nmlist junk;
+ /* static*/ struct nmlist junk;
+ static struct type t_int = {INT};
register struct nmlist **mlp;
static struct nmlist *zerloc = NULL;
register int o, brace;
- if ((mlp = np->nl_strp->S.memlist)==NULL) {
+ if ((mlp = /*np->nl_strp->S.memlist*/((struct stype *)np->nl_dtype)->st_memlist)==NULL) {
mlp = &zerloc;
error0("Undefined structure initialization");
}
break;
peeksym = o;
if (*mlp==0) {
+ /* change this to a static struct nmlist later when nmlist has stabilized */
+ bzero(&junk, sizeof(struct nmlist));
+ junk.nl_dtype = &t_int;
error0("Too many structure initializers");
cinit(&junk, 0, sclass);
} else
} while ((o=symbol())==COMMA && (*mlp || brace));
if (sclass!=AUTO && sclass!=REG) {
if (*mlp)
- outcode("BN", SSPACE, np->nl_strp->S.ssize - (*mlp)->nl_offset);
+ outcode("BN", SSPACE, /*np->nl_strp->S.ssize*/((struct stype *)np->nl_dtype)->st_ssize - (*mlp)->nl_offset);
outcode("B", EVEN);
}
if (o!=RBRACE || brace==0)
/*
* Process one statement in a function.
*/
+struct type gototype = {0}; /* dummy type distinguished by its address */
void statement() {
register int o, o1;
int sauto, sreg;
}
}
np->nl_class = STATIC;
- np->nl_type = ARRAY;
+ /* np->nl_type = ARRAY;*/
+ np->nl_dtype = &gototype;
np->nl_flag |= FLABL;
if (np->nl_offset==0)
np->nl_offset = isn0++;
/*
* Structure resembling a block for a register variable.
*/
-struct nmlist hreg = { REG, 0, 0, NULL, NULL, 0 };
+struct nmlist hreg = { REG, 0, /*0, (int *)NULL, (union str *)NULL,*/ (struct type *)NULL, 0/*nl_offset*/ }; /* note: remaining fields not initialized */
struct locnnode areg = { { { NAME, 0, (int *)NULL, (union str *)NULL }, &hreg, 0/*nn_class*/, 0/*nn_regno*/, 0/*nn_offset*/}, 0/*locnn_nloc*/ };
void funchead() {
register int pl;
register struct nmlist *cs;
register char *st;
+ static struct type t_double = {DOUBLE};
+ struct tdim dim;
+ int a;
pl = STARG;
while(paraml) {
parame->nl_sparent = NULL;
cs = paraml;
paraml = ¶ml->nl_sparent->P;
- if (cs->nl_type==FLOAT)
- cs->nl_type = DOUBLE;
+ if (cs->/*nl_type*/nl_dtype->t_id==FLOAT)
+ cs->/*nl_type*/nl_dtype = /*DOUBLE*/&t_double;
cs->nl_offset = pl;
- if ((cs->nl_type&XTYPE) == ARRAY) {
- cs->nl_type -= (ARRAY-PTR); /* set ptr */
- cs->nl_subsp++; /* pop dims */
+ if (/*(cs->nl_type&XTYPE) == ARRAY*/cs->nl_dtype->t_id == (REF | ARRAY)) {
+/* cs->nl_type -= (ARRAY-PTR); *//* set ptr *//*
+ cs->nl_subsp++;*/ /* pop dims */
+ struct rtype *rt = (struct rtype *)Dblock(sizeof(struct rtype));
+ rt->rt_id = REF | PTR;
+ rt->rt_reftype = ((struct rtype *)cs->nl_dtype)->rt_reftype;
+ cs->nl_dtype = (struct type *)rt;
}
pl += rlength(/*(struct node *)cs*/cs->nl_dtype);
if (cs->nl_class==AREG && (hreg.nl_offset=goodreg(cs))>=0) {
+ hreg.nl_dtype = cs->nl_dtype; /* probably not necessary, but be safe */
st = starttree();
*cp++ = (struct node *)&areg;
*cp++ = (struct node *)nblock(cs);
- areg.locnn_type = cs->nl_type;
- areg.locnn_strp = cs->nl_strp;
+ /* areg.locnn_type = cs->nl_type;
+ areg.locnn_strp = cs->nl_strp;*/
+ dim.rank = 0;
+ areg.locnn_type = XXXoldtype(cs->nl_dtype, &dim, (struct SS **)&areg.locnn_strp);
+ areg.locnn_subsp = dim.rank ? (int *)Tblock(dim.rank*sizeof(dim.rank)) : NULL;
+ for (a=0; a<dim.rank; a++)
+ areg.locnn_subsp[a] = dim.dimens[a];
cs->nl_class = AUTO;
build(ASSIGN);
rcexpr0(*--cp);
if (o==NAME && csym->nl_class==TYPEDEF) {
if (tkw >= 0)
error0("type clash");
- tkw = csym->nl_type;
- /* tptr->nl_subsp = csym->nl_subsp;
+ /* tkw = csym->nl_type;
+ tptr->nl_subsp = csym->nl_subsp;
tptr->nl_strp = csym->nl_strp;*/
dtype = csym->nl_dtype;
isadecl++;
stype->st_id = STRUCT;
/*ssym->nl_strp->S.ssize*/stype->st_ssize = 0;
/*ssym->nl_strp->S.memlist*/stype->st_memlist = NULL;
- ssym->nl_strp = (union str *)&stype->st_S;
+ /*ssym->nl_strp = (union str *)&stype->st_S;*/
ssym->nl_dtype = (struct type *)stype;
}
/* strp = ssym->nl_strp;*/
if (skw == MOS) {
abs.nl_class = 0;
abs.nl_flag = 0;
- abs.nl_type = 0;
+ /* abs.nl_type = 0;
abs.nl_subsp = 0;
- abs.nl_strp = 0;
+ abs.nl_strp = 0;*/
+ abs.nl_dtype = NULL;
abs.nl_nextnm = 0;
abs.nl_sparent = 0;
abs.nl_blklev = blklev;
* Process a single declarator
*/
/* convert detailed type description to old type description */
-static int oldtype(dtype, dimp, strp) struct type *dtype; struct tdim *dimp; struct SS **strp; {
+int XXXoldtype(dtype, dimp, strp) struct type *dtype; struct tdim *dimp; struct SS **strp; {
int type;
switch (dtype->t_id) {
case REF | PTR:
/*fprintf(stderr, "ptr(");*/
- type = oldtype(((struct rtype *)dtype)->rt_reftype, dimp, strp);
+ type = XXXoldtype(((struct rtype *)dtype)->rt_reftype, dimp, strp);
if (type & BIGTYPE) {
typov();
type = 0;
break;
case REF | FUNC:
/*fprintf(stderr, "func(");*/
- type = oldtype(((struct ftype *)dtype)->ft_reftype, dimp, strp);
+ type = XXXoldtype(((struct ftype *)dtype)->ft_reftype, dimp, strp);
if (type & BIGTYPE) {
typov();
type = 0;
dimp->rank = 4;
}
dimp->dimens[dimp->rank++] = ((struct atype *)dtype)->at_nelt;
- type = oldtype(((struct atype *)dtype)->at_reftype, dimp, strp);
+ type = XXXoldtype(((struct atype *)dtype)->at_reftype, dimp, strp);
if (type & BIGTYPE) {
typov();
type = 0;
type = (type & TYPE) | (type & ~TYPE) << TYLEN | ARRAY;
break;
case STRUCT:
+ /*fprintf(stderr, "struct(%d", dtype->t_id);*/
*strp = &((struct stype *)dtype)->st_S;
goto got_strp;
+ case BITFLD:
+ /*fprintf(stderr, "bitfld(%d", dtype->t_id);*/
+ *strp = NULL;
+ type = UNSIGN;
+ break;
default:
+ /*fprintf(stderr, "basic(%d", dtype->t_id);*/
*strp = NULL;
got_strp:
- /*fprintf(stderr, "basic(%d", dtype->t_id);*/
type = dtype->t_id;
+ break;
}
/*fprintf(stderr, ")", type);*/
return type;
/* int type;*/
register struct nmlist *dsym;
register struct /*nmlist*/type *tptr;
- struct tdim dim;
+ /* struct tdim dim;*/
/*struct SS *strp;
int *dp;*/
int isinit;
}
else
dsym->nl_dtype = dtype;
- /* XXX this is only for compatibility */
- dim.rank = 0;
- /*fprintf(stderr, "oldtype ");*/
- dsym->nl_type = oldtype(dtype, &dim, &dsym->nl_strp);
- /*fprintf(stderr, "\n");*/
+ /*dim.rank = 0;
+ dsym->nl_type = XXXoldtype(dtype, &dim, (struct SS **)&dsym->nl_strp);
if (dim.rank && dsym->nl_subsp == 0)
dsym->nl_subsp = (int *)Dblock(dim.rank*sizeof(dim.rank));
for (a=0; a<dim.rank; a++)
- dsym->nl_subsp[a] = dim.dimens[a];
- /* XXX to here */
+ dsym->nl_subsp[a] = dim.dimens[a];*/
if (skw==TYPEDEF) {
dsym->nl_class = TYPEDEF;
return(0);
bdtype->bt_id = BITFLD;
bdtype->bt_flen = t1;
bdtype->bt_bitoffs = bitoffs;
- dsym->nl_strp = (union str *)&bdtype->bt_F;
+ /*dsym->nl_strp = (union str *)&bdtype->bt_F;*/
dsym->nl_dtype = (struct type *)bdtype;
#undef bdtype
}
*nsp = *sp;
nsp->nl_class = 0;
nsp->nl_flag &= FKIND;
- nsp->nl_type = 0;
+ /* nsp->nl_type = 0;*/
nsp->nl_dtype = NULL;
nsp->nl_offset = 0;
nsp->nl_blklev = blklev;
- nsp->nl_strp = NULL;
- nsp->nl_subsp = NULL;
+ /* nsp->nl_strp = NULL;
+ nsp->nl_subsp = NULL;*/
nsp->nl_sparent = NULL;
hsp = &hshtab[hash(sp->nl_name)];
nsp->nl_nextnm = *hsp;
*/
void redec() {
error0("%s redeclared", defsym->nl_name);
- abort();
}
/*
* a register; if so return the register number
*/
int goodreg(hp) struct nmlist *hp; {
- int type;
+ /* int type;*/
+ struct type *dtype;
- type = hp->nl_type;
- if ((type!=INT && type!=UNSIGN && (type&XTYPE)==0)
- || (type&XTYPE)>PTR || regvar<3)
+ /* type = hp->nl_type;*/
+ dtype = hp->nl_dtype;
+ if ((/*type*/dtype->t_id!=INT && /*type*/dtype->t_id!=UNSIGN && /*(type&XTYPE)==0*/dtype->t_id!=(REF|PTR))
+ || /*(type&XTYPE)>PTR ||*/ regvar<3)
return(-1);
return(--regvar);
}
* After an "if (...) goto", look to see if the transfer
* is to a simple label.
*/
+extern struct type gototype; /* dummy type distinguished by its address */
int simplegoto() {
register struct nmlist *csp;
csp = csym;
if (csp->nl_blklev == 0)
csp = pushdecl(csp);
- if (csp->nl_class==0 && csp->nl_type==0) {
- csp->nl_type = ARRAY;
+ if (csp->nl_class==0 && csp->/*nl_type==0*/nl_dtype==NULL) {
+ /* csp->nl_type = ARRAY;*/
+ csp->nl_dtype = &gototype;
csp->nl_flag |= FLABL;
if (csp->nl_offset==0)
csp->nl_offset = isn0++;
}
if ((csp->nl_class==0||csp->nl_class==STATIC)
- && csp->nl_type==ARRAY) {
+ && /*csp->nl_type==ARRAY*/csp->nl_dtype==&gototype) {
peeksym = -1;
return(csp->nl_offset);
}
/* nl_type, nl_subsp fields, because of length(), rlength() computations */
char nl_class; /* storage class */
char nl_flag; /* various flags */
+#if 0
/* note: these will be phased out in favour of nl_dtype: */
int nl_type; /* type */
int *nl_subsp; /* subscript list */
union str *nl_strp; /* structure description */
/* to here */
+#endif
struct type *nl_dtype; /* detailed type */
int nl_offset; /* post-allocation location */
struct nmlist *nl_nextnm; /* next name in chain */