void treeout __P((register struct node *tp, int isstruct));
void branch0 __P((int lab));
void label0 __P((int l));
+int XXXlength __P((struct node *cs));
int plength __P((register struct node *p));
int length __P((struct /*node*/type *cs));
int rlength __P((struct /*node*/type *cs));
* sizeof gets turned into a number here.
*/
if (op==SIZEOF) {
- struct cnode *p = cblock(length(/*p1*/p1->n_dtype));
+ struct cnode *p = cblock(XXXlength(p1));
p->cn_type = UNSIGN;
*cp++ = (struct node *)p;
return;
#define pt (*(struct ptype **)&t)
pt = (struct ptype *)Tblock(sizeof(struct ptype));
pt->pt_id = PTR;
- pt->pt_ptotype = newtype((type >> TYLEN & ~TYPE) | (type & TYPE), dimp, strp);
- break;
+reft:
+
+ goto reft;
#undef pt
case FUNC:
fprintf(stderr, "func(");
#define ft (*(struct ftype **)&t)
ft = (struct ftype *)Tblock(sizeof(struct ftype));
- ft->ft_id = PTR;
- ft->ft_rettype = newtype((type >> TYLEN & ~TYPE) | (type & TYPE), dimp, strp);
- break;
+ ft->ft_id = FUNC;
+ ft->ft_arglist = NULL;
+ goto reft;
#undef ft
case ARRAY:
if (*dimp)
at = (struct atype *)Tblock(sizeof(struct atype));
at->at_id = PTR;
at->at_nelt = *dimp ? *(*dimp)++ : 0;
- at->at_elttype = newtype((type >> TYLEN & ~TYPE) | (type & TYPE), dimp, strp);
- break;
#undef at
+ reft:
+#define pt ((struct ptype *)t)
+ pt->pt_reftype = newtype((type >> TYLEN & ~TYPE) | (type & TYPE), dimp, strp);
+ break;
+#undef pt
default:
fprintf(stderr, "basic(%d", type);
if (type == STRUCT) {
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_dtype = ds->nl_dtype;*/
p->nn_nmlist = ds;
p->nn_class = ds->nl_class==0?STATIC:ds->nl_class;
p->nn_regno = 0;
*/
struct cnode *cblock(value) _INT value; {
register struct cnode *p;
- static struct type t_int = {INT};
+ /*static struct type t_int = {INT};*/
p = (struct cnode *)Tblock(sizeof(struct cnode));
p->cn_op = CON;
p->cn_type = INT;
p->cn_subsp = NULL;
p->cn_strp = NULL;
- p->cn_dtype = &t_int;
+ /*p->cn_dtype = &t_int;*/
p->cn_value = value;
return(p);
}
*/
struct lnode *lblock(lvalue) _LONG lvalue; {
register struct lnode *p;
- static struct type t_long = {LONG};
+ /*static struct type t_long = {LONG};*/
p = (struct lnode *)Tblock(sizeof(struct lnode));
p->ln_op = LCON;
p->ln_type = LONG;
p->ln_subsp = NULL;
p->ln_strp = NULL;
- p->ln_dtype = &t_long;
+ /*p->ln_dtype = &t_long;*/
p->ln_lvalue = lvalue;
return(p);
}
*/
struct fnode *fblock(value, fvalue) int value; _DOUBLE fvalue; {
register struct fnode *p;
- static struct type t_double = {DOUBLE};
+ /*static struct type t_double = {DOUBLE};*/
p = (struct fnode *)Tblock(sizeof(struct fnode));
p->fn_op = FCON;
p->fn_type = DOUBLE;
p->fn_subsp = NULL;
p->fn_strp = NULL;
- p->fn_dtype = &t_double;
+ /*p->fn_dtype = &t_double;*/
p->fn_value = value;
p->fn_fvalue = fvalue;
return(p);
/* 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_dtype = ds->nl_dtype;*/
setinit(ds);
outcode("BS", SYMDEF, sclass==EXTERN?ds->nl_name:"");
cfunc();
if (isarray) {
np.nl_type = decref0(realtype);
np.nl_subsp++;
- np.nl_dtype = ((struct atype *)np.nl_dtype)->at_elttype;
+ np.nl_dtype = ((struct atype *)np.nl_dtype)->at_reftype;
if (width==0 && flex==0)
error0("0-length row: %s", anp->nl_name);
o = length(/*(struct node *)&np*/np.nl_dtype);
switch (dtype->t_id) {
case PTR:
/*fprintf(stderr, "ptr(");*/
- type = oldtype(((struct ptype *)dtype)->pt_ptotype, dimp, strp);
+ type = oldtype(((struct ptype *)dtype)->pt_reftype, dimp, strp);
if (type & BIGTYPE) {
typov();
type = 0;
break;
case FUNC:
/*fprintf(stderr, "func(");*/
- type = oldtype(((struct ftype *)dtype)->ft_rettype, dimp, strp);
+ type = oldtype(((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_elttype, dimp, strp);
+ type = oldtype(((struct atype *)dtype)->at_reftype, dimp, strp);
if (type & BIGTYPE) {
typov();
type = 0;
}*/
static struct type *getail(dtype, nullok) struct type *dtype; int *nullok; {
static struct type argtype = {INT};
- struct type *t;
+ struct ptype *pt;
register int o;
register struct nmlist *ds;
} else
if ((o=symbol()) != RPARN)
goto syntax;
-#define ft (*(struct ftype **)&t)
+#define ft (*(struct ftype **)&pt)
ft = (struct ftype *)Dblock(sizeof(struct ftype));
ft->ft_id = FUNC;
- ft->ft_rettype = getail(dtype, nullok);
ft->ft_arglist = NULL;
- return (struct type *)ft;
+ goto gett;
#undef ft
case LBRACK:
cval = 0;
}
*nullok = 0;
-#define at (*(struct atype **)&t)
+#define at (*(struct atype **)&pt)
at = (struct atype *)Dblock(sizeof(struct atype));
at->at_id = ARRAY;
at->at_nelt = cval;
- at->at_elttype = getail(dtype, nullok); /* destroys cval */
- return (struct type *)at;
#undef at
+ gett:
+ pt->pt_reftype = getail(dtype, nullok);
+ return (struct type *)pt;
default:
peeksym = o;
decsyn(o);
return(NULL);
}
-
struct type *getype(dtype, nullok, anonok) struct type *dtype; int *nullok; int anonok; {
struct type *t;
register int o;
#define pt (*(struct ptype **)&t)
pt = (struct ptype *)Dblock(sizeof(struct ptype));
pt->pt_id = PTR;
- pt->pt_ptotype = dtype;
+ pt->pt_reftype = dtype;
dtype = (struct type *)pt;
goto getp;
#undef pt
/* while ((t&XTYPE)==ARRAY)
t = decref0(t);*/
while (t->t_id == ARRAY)
- t = ((struct atype *)t)->at_elttype;
+ t = ((struct atype *)t)->at_reftype;
if (/*t*/t->t_id!=CHAR && /*t*/t->t_id!=UNCHAR) {
a = (a+ALIGN) & ~ALIGN;
if (a>offset)
* is some kind of pointer; return the size of the object
* to which the pointer points.
*/
-static int XXXlength(cs) struct node *cs; {
+int XXXlength(cs) struct node *cs; {
register int t, elsz;
long n;
int nd;
l = XXXlength(p);
p->n_type = t;
return(l);
- /*switch (p->t_id) {
- case PTR:
- return length(((struct ptype *)p)->pt_ptotype);
- case FUNC:
- return length(((struct ftype *)p)->ft_rettype);
- case ARRAY:
- return length(((struct atype *)p)->at_elttype);
- }
- return 1;*/
}
/*
n *= cs->n_subsp[nd++];
}*/
n = 1;
- for (t = cs; t->t_id == ARRAY; t = ((struct atype *)t)->at_elttype)
+ for (t = cs; t->t_id == ARRAY; t = ((struct atype *)t)->at_reftype)
n *= ((struct atype *)t)->at_nelt;
if (/*(t&~TYPE)*/t->t_id==FUNC)
return(0);
struct ptype {
struct type pt_type;
#define pt_id pt_type.t_id
- struct type *pt_ptotype; /* pointed-to type */
+ struct type *pt_reftype; /* referenced type */
};
struct ftype {
- struct type ft_type;
-#define ft_id ft_type.t_id
- struct type *ft_rettype; /* return type */
+ struct ptype ft_ptype;
+#define ft_id ft_ptype.pt_id
+#define ft_reftype ft_ptype.pt_reftype
struct nmlist **ft_arglist; /* argument list */
};
struct atype {
- struct type at_type;
-#define at_id at_type.t_id
+ struct ptype at_ptype;
+#define at_id at_ptype.pt_id
+#define at_reftype at_ptype.pt_reftype
int at_nelt; /* number of elements */
- struct type *at_elttype; /* element type */
};
/*
int *n_subsp; /* subscript list for arrays; pass 0 only */
union str *n_strp; /* structure descr for structs; pass 0 only */
/* to here */
- struct type *n_dtype; /* detailed type */
+ /*struct type *n_dtype;*/ /* detailed type */
};
struct tnode {
#define tn_type tn_node.n_type
#define tn_subsp tn_node.n_subsp
#define tn_strp tn_node.n_strp
-#define tn_dtype tn_node.n_dtype
+/*#define tn_dtype tn_node.n_dtype*/
struct node *tn_tr1;
struct node *tn_tr2;
int tn_degree; /* pass 1 only */
#define nn_type nn_node.n_type
#define nn_subsp nn_node.n_subsp
#define nn_strp nn_node.n_strp
-#define nn_dtype nn_node.n_dtype
+/*#define nn_dtype nn_node.n_dtype*/
struct nmlist *nn_nmlist; /* pass 0 only */
char nn_class; /* pass 1 only */
char nn_regno; /* pass 1 only */
#define locnn_type locnn_nnode.nn_type
#define locnn_subsp locnn_nnode.nn_subsp
#define locnn_strp locnn_nnode.nn_strp
-#define locnn_dtype locnn_nnode.nn_dtype
+/*#define locnn_dtype locnn_nnode.nn_dtype*/
#define locnn_nmlist locnn_nnode.nn_nmlist
#define locnn_class locnn_nnode.nn_class
#define locnn_regno locnn_nnode.nn_regno
#define extnn_type extnn_nnode.nn_type
#define extnn_subsp extnn_nnode.nn_subsp
#define extnn_strp extnn_nnode.nn_strp
-#define extnn_dtype extnn_nnode.nn_dtype
+/*#define extnn_dtype extnn_nnode.nn_dtype*/
#define extnn_nmlist extnn_nnode.nn_nmlist
#define extnn_class extnn_nnode.nn_class
#define extnn_regno extnn_nnode.nn_regno
#define cn_type cn_node.n_type
#define cn_subsp cn_node.n_subsp
#define cn_strp cn_node.n_strp
-#define cn_dtype cn_node.n_dtype
+/*#define cn_dtype cn_node.n_dtype*/
_INT cn_value;
};
#define ln_type ln_node.n_type
#define ln_subsp ln_node.n_subsp
#define ln_strp ln_node.n_strp
-#define ln_dtype ln_node.n_dtype
+/*#define ln_dtype ln_node.n_dtype*/
_LONG ln_lvalue;
};
#define fn_type fn_cnode.cn_type
#define fn_subsp fn_cnode.cn_subsp
#define fn_strp fn_cnode.cn_strp
-#define fn_dtype fn_cnode.cn_dtype
+/*#define fn_dtype fn_cnode.cn_dtype*/
#define fn_value fn_cnode.cn_value
_DOUBLE fn_fvalue;
};
#define fa_type fa_tnode.tn_type
#define fa_subsp fa_tnode.tn_subsp
#define fa_strp fa_tnode.tn_strp
-#define fa_dtype fa_tnode.tn_dtype
+/*#define fa_dtype fa_tnode.tn_dtype*/
#define fa_tr1 fa_tnode.tn_tr1
#define fa_tr2 fa_tnode.tn_tr2
#define fa_degree fa_tnode.tn_degree