/*
* Tree node for constants
*/
-struct cnode {
+struct tconst0 {
int op;
int type;
int *subsp;
union str *strp;
- int value;
+ _INT value;
};
/*
* Tree node for long constants
*/
-struct lnode {
+struct lconst0 {
int op;
int type;
int *subsp;
union str *strp;
- long lvalue;
+ _LONG lvalue;
};
/*
* tree0 node for floating
* constants
*/
-struct fnode {
+struct ftconst0 {
int op;
int type;
int *subsp;
*/
union tree0 {
struct tnode0 t;
- struct cnode c;
- struct lnode l;
- struct fnode f;
- struct nmlist n;
- struct FS fld;
+ struct tconst0 c;
+ struct lconst0 l;
+ struct ftconst0 f;
+ /* struct nmlist n;*/
+ /* n occurs as tr1 of a NAME node, points into symbol table */
+ /* we will just cast tr1 to "struct nmlist *" in that particular case */
+ /* struct FS fld;*/
+ /* fld occurs as tr2 of an FSEL node, points into structure description */
+ /* we will just cast tr2 to "struct FS *" in that particular case */
};
/* c01.c */
void build __P((int op));
-union tree0 *structident __P((register union tree0 *p1, register union tree0 *p2));
+void structident __P((register union tree0 *p1, register union tree0 *p2));
union tree0 *convert __P((union tree0 *p, int t, int cvn, int len));
void setype __P((register union tree0 *p, register int t, register union tree0 *newp));
union tree0 *chkfun __P((register union tree0 *p));
register struct nmlist *cs;
int p, ps, os, xo = 0, *xop;
/*char *svtree;*/
- static struct cnode garbage = { CON, INT, (int *)NULL, (union str *)NULL, 0 };
+ static struct tconst0 garbage = { CON, INT, (int *)NULL, (union str *)NULL, 0 };
/*svtree = starttree();*/
op = opst;
goto tand;
case LCON:
- *cp0 = (union tree0 *)Tblock(sizeof(struct lnode));
+ *cp0 = (union tree0 *)Tblock(sizeof(struct lconst0));
(*cp0)->l.op = LCON;
(*cp0)->l.type = LONG;
(*cp0)->l.lvalue = lcval;
* then * is tacked on to access the member.
*/
case ARROW:
- if (p2->t.op!=NAME || p2->t.tr1->n.hclass!=MOS) {
+ if (p2->t.op!=NAME || ((struct nmlist *)p2->t.tr1)->hclass!=MOS) {
error0("Illegal structure ref");
*cp0++ = p1;
return;
}
- p2 = structident(p1, p2);
- t2 = p2->n.htype;
- if (t2==INT && p2->t.tr1->n.hflag&FFIELD)
+ structident(p1, p2);
+ t2 = p2->t.type;
+ if (t2==INT && ((struct nmlist *)p2->t.tr1)->hflag&FFIELD)
t2 = UNSIGN;
t = incref0(t2);
chkw(p1, -1);
setype(p1, t, p2);
*cp0++ = block(PLUS, t, p2->t.subsp, p2->t.strp,
- p1, cblock(p2->t.tr1->n.hoffset));
+ p1, cblock(((struct nmlist *)p2->t.tr1)->hoffset));
build(STAR);
- if (p2->t.tr1->n.hflag&FFIELD)
+ if (((struct nmlist *)p2->t.tr1)->hflag&FFIELD)
#if 1
cp0[-1] = block(FSEL, UNSIGN, (int *)NULL, (union str *)NULL,
- cp0[-1], (union tree0 *)p2->t.tr1->n.hstrp);
+ cp0[-1], (union tree0 *)((struct nmlist *)p2->t.tr1)->hstrp);
#else
*cp0++ = block(FSEL, UNSIGN, (int *)NULL, (union str *)NULL,
- *--cp0, (union tree0 *)p2->t.tr1->n.hstrp);
+ *--cp0, (union tree0 *)((struct nmlist *)p2->t.tr1)->hstrp);
#endif
return;
}
}
}
-union tree0 *structident(p1, p2) register union tree0 *p1; register union tree0 *p2; {
- register struct nmlist *np;
+void structident(p1, p2) register union tree0 *p1; register union tree0 *p2; {
+ register struct nmlist *np, *nporig;
int vartypes = 0, namesame = 1;
- np = (struct nmlist *)p2->t.tr1;
+ np = nporig = (struct nmlist *)p2->t.tr1;
for (;;) {
if (namesame && p1->t.type==STRUCT+PTR && p1->t.strp == np->sparent) {
p2->t.type = np->htype;
p2->t.strp = np->hstrp;
p2->t.subsp = np->hsubsp;
p2->t.tr1 = (union tree0 *)np;
- return(p2);
+ return;
}
np = np->nextnm;
if (np==NULL)
break;
namesame = 0;
- if (strcmp(p2->t.tr1->n.name, np->name) != 0)
+ if (strcmp(nporig->name, np->name) != 0)
continue;
- if ((p2->t.tr1->n.hflag&FKIND) != (np->hflag&FMOS))
+ if ((nporig->hflag&FKIND) != (np->hflag&FMOS))
continue;
namesame = 1;
- if (p2->t.tr1->n.htype==np->htype && p2->t.tr1->n.hoffset==np->hoffset)
+ if (nporig->htype==np->htype && nporig->hoffset==np->hoffset)
continue;
vartypes++;
}
if (vartypes)
- error0("Ambiguous structure reference for %s",p2->t.tr1->n.name);
+ error0("Ambiguous structure reference for %s",nporig->name);
else
- werror0("%s not member of cited struct/union",p2->t.tr1->n.name);
- return(p2);
+ werror0("%s not member of cited struct/union",nporig->name);
}
/*
return(p);
/* check array & not MOS and not typer */
if (((t = p->t.type)&XTYPE)!=ARRAY
- || p->t.op==NAME && p->t.tr1->n.hclass==MOS
+ || p->t.op==NAME && ((struct nmlist *)p->t.tr1)->hclass==MOS
|| p->t.op==ETYPE)
return(p);
p->t.subsp++;
register union tree0 *p;
/*fprintf(stderr, "cblock(0%06o)\n", v & 0177777);*/
- p = (union tree0 *)Tblock(sizeof(struct cnode));
+ p = (union tree0 *)Tblock(sizeof(struct tconst0));
p->c.op = CON;
p->c.type = INT;
p->c.subsp = NULL;
register union tree0 *p;
/*fprintf(stderr, "fblock(%d, \"%s\")\n", t, string);*/
- p = (union tree0 *)Tblock(sizeof(struct fnode));
+ p = (union tree0 *)Tblock(sizeof(struct ftconst0));
p->f.op = FCON;
p->f.type = t;
p->f.subsp = NULL;
switch(tp->t.op) {
case NAME:
- hp = &tp->t.tr1->n;
+ hp = (struct nmlist *)tp->t.tr1;
if (hp->hclass==TYPEDEF)
error0("Illegal use of type name");
#if 1
case FSEL:
treeout(tp->t.tr1, nextisstruct);
outcode("BNNN", tp->t.op, tp->t.type,
- tp->t.tr2->fld.bitoffs, tp->t.tr2->fld.flen);
+ ((struct FS *)tp->t.tr2)->bitoffs, ((struct FS *)tp->t.tr2)->flen);
break;
case ETYPE:
/*
* short constants
*/
-struct tconst {
+struct tconst1 {
int op;
int type;
_INT value;
/*
* long constants
*/
-struct lconst {
+struct lconst1 {
int op;
int type;
_LONG lvalue;
/*
* Floating constants
*/
-struct ftconst {
+struct ftconst1 {
int op;
int type;
int value;
struct tnode1 t;
struct tname n;
struct xtname x;
- struct tconst c;
- struct lconst l;
- struct ftconst f;
+ struct tconst1 c;
+ struct lconst1 l;
+ struct ftconst1 f;
struct fasgn F;
};
extern char *funcbase;
extern char *curbase;
extern char *coremax;
-extern struct tconst czero, cone;
+extern struct tconst1 czero, cone;
extern long totspace;
extern int regpanic; /* set when SU register alg. fails */
extern int panicposs; /* set when there might be need for regpanic */
extern union tree1 *getblk();
extern union tree1 *strfunc();
extern union tree1 *isconstant();
-extern union tree1 *tconst();
+extern union tree1 *tconst1();
extern union tree1 *hardlongs();
-extern union tree1 *lconst();
+extern union tree1 *lconst1();
extern union tree1 *acommute();
extern union tree1 *lvfield();
extern union tree1 *paint();
void distrib __P((struct acl *list));
void squash __P((union tree1 **p, union tree1 **maxp));
void _const __P((int op, register _INT *vp, _INT v, int type));
-union tree1 *lconst __P((int op, register union tree1 *lp, register union tree1 *rp));
+union tree1 *lconst1 __P((int op, register union tree1 *lp, register union tree1 *rp));
void insert __P((int op, register union tree1 *tree1, register struct acl *list));
union tree1 *tnode1 __P((int op, int type, union tree1 *tr1, union tree1 *tr2));
-union tree1 *tconst __P((int val, int type));
+union tree1 *tconst1 __P((int val, int type));
union tree1 *getblk __P((int size));
int islong __P((int t));
union tree1 *isconstant __P((register union tree1 *t));
LESSEQ, GREATP, GREATQP, LESSP, LESSEQP
};
-struct tconst czero = { CON, INT, 0};
-struct tconst cone = { CON, INT, 1};
+struct tconst1 czero = { CON, INT, 0};
+struct tconst1 cone = { CON, INT, 1};
struct tname sfuncr = { NAME, STRUCT, STATIC, 0, 0, 0 };
return(0);
}
tree1 = tnode1(AMPER, STRUCT+PTR, tree1, TNULL1);
- tree1 = tnode1(PLUS, STRUCT+PTR, tree1, tconst(size, INT));
+ tree1 = tnode1(PLUS, STRUCT+PTR, tree1, tconst1(size, INT));
tree1 = optim(tree1);
retval = rcexpr1(tree1, regtab, 0);
size >>= 1;
case CON:
t = va_arg(argp, int) /*geti()*/;
- *sp++ = tconst(va_arg(argp, int) /*geti()*/, t);
+ *sp++ = tconst1(va_arg(argp, int) /*geti()*/, t);
break;
case LCON:
t = va_arg(argp, int) /*geti()*/;
op = va_arg(argp, int) /*geti()*/;
if (t==0 && op>=0 || t == -1 && op<0) {
- *sp++ = tnode1(ITOL, LONG, tconst(op, INT), TNULL1);
+ *sp++ = tnode1(ITOL, LONG, tconst1(op, INT), TNULL1);
break;
}
- tp = getblk(sizeof(struct lconst));
+ tp = getblk(sizeof(struct lconst1));
tp->t.op = LCON;
tp->t.type = LONG;
tp->l.lvalue = ((_LONG)t<<16) + UNS(op); /* nonportable */
case FCON:
t = va_arg(argp, int) /*geti()*/;
outname(s/*)*/, va_arg(argp, char *));
- tp = getblk(sizeof(struct ftconst));
+ tp = getblk(sizeof(struct ftconst1));
tp->t.op = FCON;
tp->t.type = t;
tp->f.value = isn1++;
case FSEL:
tp = tnode1(FSEL, va_arg(argp, int) /*geti()*/, *--sp, TNULL1);
t = va_arg(argp, int) /*geti()*/;
- tp->t.tr2 = tnode1(COMMA, INT, tconst(va_arg(argp, int) /*geti()*/, INT), tconst(t, INT));
+ tp->t.tr2 = tnode1(COMMA, INT, tconst1(va_arg(argp, int) /*geti()*/, INT), tconst1(t, INT));
if (tp->t.tr2->t.tr1->c.value==16)
tp = paint(tp->t.tr1, tp->t.type);
*sp++ = tp;
tree1->t.tr1 = optim(tree1->t.tr1);
tree1->t.tr2 = optim(tree1->t.tr2);
if (tree1->t.type == LONG || tree1->t.type==UNLONG) {
- t = lconst(tree1->t.op, tree1->t.tr1, tree1->t.tr2);
+ t = lconst1(tree1->t.op, tree1->t.tr1, tree1->t.tr2);
if (t)
return(t);
}
case ITOL:
if (subtre->t.op==CON && subtre->t.type==INT && subtre->c.value<0) {
- subtre = getblk(sizeof(struct lconst));
+ subtre = getblk(sizeof(struct lconst1));
subtre->t.op = LCON;
subtre->t.type = LONG;
subtre->l.lvalue = tree1->t.tr1->c.value;
case LTOF:
if (subtre->t.op==LCON) {
- tree1 = getblk(sizeof(struct ftconst));
+ tree1 = getblk(sizeof(struct ftconst1));
tree1->t.op = FCON;
tree1->t.type = DOUBLE;
tree1->f/*c*/.value = isn1++;
case ITOF:
if (subtre->t.op==CON) {
- tree1 = getblk(sizeof(struct ftconst));
+ tree1 = getblk(sizeof(struct ftconst1));
tree1->t.op = FCON;
tree1->t.type = DOUBLE;
tree1->f.value = isn1++;
case STAR:
subtre->t.type = tree1->t.type;
subtre->t.tr1->t.type = tree1->t.type+PTR;
- subtre->t.tr1 = tnode1(PLUS, tree1->t.type, subtre->t.tr1, tconst(2, INT));
+ subtre->t.tr1 = tnode1(PLUS, tree1->t.type, subtre->t.tr1, tconst1(2, INT));
return(optim(subtre));
case ITOL:
}
if (subtre->t.op==ITOL) {
if (subtre->t.tr1->t.op==CON) {
- tree1 = getblk(sizeof(struct lconst));
+ tree1 = getblk(sizeof(struct lconst1));
tree1->t.op = LCON;
tree1->t.type = LONG;
if (uns(subtre->t.tr1))
return(subtre);
}
if (subtre->t.op==ITOL && subtre->t.tr1->t.op==CON) {
- tree1 = getblk(sizeof(struct lconst));
+ tree1 = getblk(sizeof(struct lconst1));
tree1->t.op = LCON;
tree1->t.type = LONG;
if (uns(subtre->t.tr1))
t1->t.tr1 = t->t.tr2;
t->t.tr2 = t1;
t1 = t1->t.tr2;
- t1 = tnode1(COMMA, INT, tconst(t1->t.tr1->c.value, INT),
- tconst(t1->t.tr2->c.value, INT));
+ t1 = tnode1(COMMA, INT, tconst1(t1->t.tr1->c.value, INT),
+ tconst1(t1->t.tr2->c.value, INT));
return(optim(tnode1(FSELT, UNSIGN, t, t1)));
}
t2--;
_const(op, &t2[0]->c.value, t2[1]->c.value, d);
t2[0]->t.type = d;
- } else if (t = lconst(op, t2[-1], t2[0])) {
+ } else if (t = lconst1(op, t2[-1], t2[0])) {
acl.nextl--;
t2--;
t2[0] = t;
error1("C error1: const");
}
-union tree1 *lconst(op, lp, rp) int op; register union tree1 *lp; register union tree1 *rp; {
+union tree1 *lconst1(op, lp, rp) int op; register union tree1 *lp; register union tree1 *rp; {
_UNSIGNED_LONG l, r;
if (lp->t.op==LCON)
lp->l.lvalue = l;
return(lp);
}
- lp = getblk(sizeof(struct lconst));
+ lp = getblk(sizeof(struct lconst1));
lp->t.op = LCON;
lp->t.type = LONG;
lp->l.lvalue = l;
return(p);
}
-union tree1 *tconst(val, type) int val; int type; {
+union tree1 *tconst1(val, type) int val; int type; {
register union tree1 *p;
- p = getblk(sizeof(struct tconst));
+ p = getblk(sizeof(struct tconst1));
p->t.op = CON;
p->t.type = type;
p->c.value = val;
s/@tree@/@tree0@/g
s/@xprtype@/@xprtype0@/g
s/@TNULL@/@TNULL0@/g
+s/@cnode@/@tconst0@/g
+s/@lnode@/@lconst0@/g
+s/@fnode@/@ftconst0@/g
+
+
s/@//g
s/ATSIGN/@/g
s/@tree@/@tree1@/g
s/@xprtype@/@xprtype1@/g
s/@TNULL@/@TNULL1@/g
+s/@tconst@/@tconst1@/g
+s/@lconst@/@lconst1@/g
+s/@ftconst@/@ftconst1@/g
s/@//g
s/ATSIGN/@/g