switch (type & XTYPE) {
case PTR:
fprintf(stderr, "ptr(");
-#define pt (*(struct ptype **)&t)
- pt = (struct ptype *)Tblock(sizeof(struct ptype));
- pt->pt_id = PTR;
+#define rt (*(struct rtype **)&t)
+ rt = (struct rtype *)Tblock(sizeof(struct rtype));
+ rt->rt_id = REF | PTR;
reft:
goto reft;
fprintf(stderr, "func(");
#define ft (*(struct ftype **)&t)
ft = (struct ftype *)Tblock(sizeof(struct ftype));
- ft->ft_id = FUNC;
+ ft->ft_id = REF | FUNC;
ft->ft_arglist = NULL;
goto reft;
#undef ft
fprintf(stderr, "array(?, ");
#define at (*(struct atype **)&t)
at = (struct atype *)Tblock(sizeof(struct atype));
- at->at_id = PTR;
+ at->at_id = REF | PTR;
at->at_nelt = *dimp ? *(*dimp)++ : 0;
#undef at
reft:
-#define pt ((struct ptype *)t)
- pt->pt_reftype = newtype((type >> TYLEN & ~TYPE) | (type & TYPE), dimp, strp);
+#define rt ((struct rtype *)t)
+ rt->rt_reftype = newtype((type >> TYLEN & ~TYPE) | (type & TYPE), dimp, strp);
break;
-#undef pt
+#undef rt
default:
fprintf(stderr, "basic(%d", type);
if (type == STRUCT) {
static int oldtype(dtype, dimp, strp) struct type *dtype; struct tdim *dimp; struct SS **strp; {
int type;
switch (dtype->t_id) {
- case PTR:
+ case REF | PTR:
/*fprintf(stderr, "ptr(");*/
- type = oldtype(((struct ptype *)dtype)->pt_reftype, dimp, strp);
+ type = oldtype(((struct rtype *)dtype)->rt_reftype, dimp, strp);
if (type & BIGTYPE) {
typov();
type = 0;
}
type = (type & TYPE) | (type & ~TYPE) << TYLEN | PTR;
break;
- case FUNC:
+ case REF | FUNC:
/*fprintf(stderr, "func(");*/
type = oldtype(((struct ftype *)dtype)->ft_reftype, dimp, strp);
if (type & BIGTYPE) {
}
type = (type & TYPE) | (type & ~TYPE) << TYLEN | FUNC;
break;
- case ARRAY:
+ case REF | ARRAY:
/*fprintf(stderr, "array(%d, ", ((struct atype *)dtype)->at_nelt);*/
if (dimp->rank>=5) {
error0("Rank too large");
}
static int eqtype(struct type *t0, struct type *t1) {
while (t0->t_id == t1->t_id) {
- if (t0->t_id < PTR)
+ if ((t0->t_id & TYPE) != REF)
return 1;
- t0 = ((struct ptype *)t0)->pt_reftype;
- t1 = ((struct ptype *)t1)->pt_reftype;
+ t0 = ((struct rtype *)t0)->rt_reftype;
+ t1 = ((struct rtype *)t1)->rt_reftype;
}
return 0;
}
t1 >>= TYLEN;
}
type |= tptr->nl_type&TYPE;*/
- if (/*(type&XTYPE)*/dtype->t_id == FUNC) {
+ if (/*(type&XTYPE) == FUNC*/dtype->t_id == (REF|FUNC)) {
if (skw==AUTO)
skw = EXTERN;
if ((skw!=EXTERN && skw!=TYPEDEF) && absname==NULL)
*/
if (dsym->/*nl_subsp*/nl_dtype) {
for (/*a=0*/dt = dtype, /*t1 = dsym->nl_type*/dt1 = dsym->nl_dtype;
- /*a<dim.rank*/dt->t_id==ARRAY && /*(t1&XTYPE)*/dt1->t_id==ARRAY;
+ /*a<dim.rank*/dt->t_id==(REF|ARRAY) && /*(t1&XTYPE)==ARRAY*/dt1->t_id==(REF|ARRAY);
/*a++*/dt=((struct atype *)dt)->at_reftype, /*t1 >>= TYLEN*/dt1=((struct atype *)dt1)->at_reftype)
#define adt ((struct atype *)dt)
#define adt1 ((struct atype *)dt1)
redec();
#undef adt
#undef adt1
- if (/*a<dim.rank*/dt->t_id==ARRAY || /*(t1&XTYPE)*/dt1->t_id==ARRAY)
+ if (/*a<dim.rank*/dt->t_id==(REF|ARRAY) || /*(t1&XTYPE)==ARRAY*/dt1->t_id==(REF|ARRAY))
redec();
} /*else {
dp = (int *)Dblock(dim.rank*sizeof(dim.rank));
error0("structure redeclaration");
}*/
if (dsym->nl_class) {
- for (dt = dtype; dt->t_id >= PTR; dt = ((struct ptype *)dt)->pt_reftype)
+ for (dt = dtype; (dt->t_id & TYPE) == REF; dt = ((struct rtype *)dt)->rt_reftype)
;
- for (dt1 = dsym->nl_dtype; dt1->t_id >= PTR; dt1 = ((struct ptype *)dt1)->pt_reftype)
+ for (dt1 = dsym->nl_dtype; (dt1->t_id & TYPE) == REF; dt1 = ((struct rtype *)dt1)->rt_reftype)
;
if (dt->t_id == STRUCT && dt1->t_id == STRUCT && dt != dt1)
error0("structure redeclaration");
}*/
static struct type *getail(dtype, nullok) struct type *dtype; int *nullok; {
static struct type argtype = {INT};
- struct ptype *pt;
+ struct rtype *rt;
register int o;
register struct nmlist *ds;
} else
if ((o=symbol()) != RPARN)
goto syntax;
-#define ft (*(struct ftype **)&pt)
+#define ft (*(struct ftype **)&rt)
ft = (struct ftype *)Dblock(sizeof(struct ftype));
- ft->ft_id = FUNC;
+ ft->ft_id = REF | FUNC;
ft->ft_arglist = NULL;
goto gett;
#undef ft
cval = 0;
}
*nullok = 0;
-#define at (*(struct atype **)&pt)
+#define at (*(struct atype **)&rt)
at = (struct atype *)Dblock(sizeof(struct atype));
- at->at_id = ARRAY;
+ at->at_id = REF | ARRAY;
at->at_nelt = cval;
#undef at
gett:
- pt->pt_reftype = getail(dtype, nullok);
- return (struct type *)pt;
+ rt->rt_reftype = getail(dtype, nullok);
+ return (struct type *)rt;
default:
peeksym = o;
return(NULL);
}
struct type *getype(dtype, nullok, anonok) struct type *dtype; int *nullok; int anonok; {
- struct type *t;
+ struct rtype *rt;
register int o;
defsym = 0;
switch(o=symbol()) {
case TIMES:
-#define pt (*(struct ptype **)&t)
- pt = (struct ptype *)Dblock(sizeof(struct ptype));
- pt->pt_id = PTR;
- pt->pt_reftype = dtype;
- dtype = (struct type *)pt;
+ rt = (struct rtype *)Dblock(sizeof(struct rtype));
+ rt->rt_id = REF | PTR;
+ rt->rt_reftype = dtype;
+ dtype = (struct type *)rt;
goto getp;
-#undef pt
case LPARN:
if (!anonok || nextchar()!=')') {
flen = aflen;
a = offset;
- t = type;
+ /* t = type;*/
ftl = "Field too long";
if (flen==0) {
a += (NBPC+bitoffs-1) / NBPC;
}
/* while ((t&XTYPE)==ARRAY)
t = decref0(t);*/
- while (t->t_id == ARRAY)
- t = ((struct atype *)t)->at_reftype;
+ for (t = type; t->t_id == (REF | ARRAY); t = ((struct atype *)t)->at_reftype)
+ ;
if (/*t*/t->t_id!=CHAR && /*t*/t->t_id!=UNCHAR) {
a = (a+ALIGN) & ~ALIGN;
if (a>offset)
* UNCHAR 8
* UNLONG 9
* VOID 10
- * PTR 020 (means it's a struct ptype)
+ * REF 11 (used with PTR, FUNC or ARRAY)
+ * PTR 020 (means it's a struct rtype)
* FUNC 040 (means it's a struct ftype)
* ARRAY 060 (means it's a struct atype)
*/
#define st_ssize st_S.ssize
#define st_memlist st_S.memlist
};
-struct ptype {
- struct type pt_type;
-#define pt_id pt_type.t_id
- struct type *pt_reftype; /* referenced type */
+struct rtype {
+ struct type rt_type;
+#define rt_id rt_type.t_id
+ struct type *rt_reftype; /* referenced type */
};
struct ftype {
- struct ptype ft_ptype;
-#define ft_id ft_ptype.pt_id
-#define ft_reftype ft_ptype.pt_reftype
+ struct rtype ft_rtype;
+#define ft_id ft_rtype.rt_id
+#define ft_reftype ft_rtype.rt_reftype
struct nmlist **ft_arglist; /* argument list */
};
struct atype {
- struct ptype at_ptype;
-#define at_id at_ptype.pt_id
-#define at_reftype at_ptype.pt_reftype
+ struct rtype at_rtype;
+#define at_id at_rtype.rt_id
+#define at_reftype at_rtype.rt_reftype
int at_nelt; /* number of elements */
};
#define UNCHAR 8
#define UNLONG 9
#define VOID 10
+#define REF 11
#define ALIGN 01 /* pass 0 only */
#define TYPE 017