}
union tree *nblock(ds) register struct nmlist *ds; {
- return(block(NAME, ds->htype, ds->hsubsp, ds->hstrp, (union tree *)ds, TNULL));
+ /* return(block(NAME, ds->htype, ds->hsubsp, ds->hstrp, (union tree *)ds, TNULL));*/
+ /* XXX compatibility: */
+ /* formerly c0 would output a NAME node as follows: */
+ /* hp = (struct nmlist *)tp->t.tr1; */
+ /* if (hp->hclass==EXTERN) */
+ /* outcode("BNNS", NAME, EXTERN, tp->t.type, hp->name); */
+ /* else */
+ /* outcode("BNNN", NAME, hp->hclass==0?STATIC:hp->hclass, tp->t.type, hp->hoffset); */
+ /* this would then be decoded by c1 as follows: */
+ /* t = geti(); */
+ /* if (t==EXTERN) { */
+ /* tp = getblk(sizeof(struct xtname)); */
+ /* tp->t.type = geti(); */
+ /* outname(s); */
+ /* tp->x.name = (char *)getblk(strlen(s) + 1); */
+ /* strcpy(tp->x.name, s); */
+ /* } else { */
+ /* tp = getblk(sizeof(struct tname)); */
+ /* tp->t.type = geti(); */
+ /* tp->n.nloc = geti(); */
+ /* } */
+ /* tp->t.op = NAME; */
+ /* tp->n.class = t; */
+ /* tp->n.regno = 0; */
+ /* tp->n.offset = 0; */
+ union tree *tp;
+ if (ds->hclass == EXTERN) {
+ tp = (union tree *)Tblock(sizeof(struct xtname));
+ tp->x.name = ds->name;
+ }
+ else {
+ tp = (union tree *)Tblock(sizeof(struct tname));
+ tp->n.nloc = ds->hoffset;
+ }
+ tp->n.op = NAME;
+ tp->n.type = ds->htype;
+ tp->n.subsp = ds->hsubsp;
+ tp->n.strp = ds->hstrp;
+ tp->n.tr1 = (union tree *)ds;
+ tp->n.class = ds->hclass==0?STATIC:ds->hclass;
+ tp->n.regno = 0;
+ tp->n.offset = 0;
+ return tp;
}
/*
struct tconst czero = { CON, INT, 0/*subsp*/, 0/*strp*/, 0};
struct tconst cone = { CON, INT, 0/*subsp*/, 0/*strp*/, 1};
-struct tname sfuncr = { NAME, STRUCT, STATIC, 0, 0, 0 };
-
+struct tname sfuncr = { NAME, STRUCT, 0/*subsp*/, 0/*strp*/, 0/*tr1*/, STATIC, 0, 0, 0 };
struct table *cregtab;
int nreg = 3;
int type;
int *subsp; /* subscript list for arrays; pass 0 only */
union str *strp; /* structure descr for structs; pass 0 only */
- int degree; /* pass 1 only */
union tree *tr1;
union tree *tr2;
+ int degree; /* pass 1 only */
};
/*
- * tree1 names for locals
+ * tree names for locals
*/
struct tname {
int op;
int type;
- char class;
- char regno;
- int offset;
- int nloc;
+ int *subsp; /* subscript list for arrays; pass 0 only */
+ union str *strp; /* structure descr for structs; pass 0 only */
+ union tree *tr1; /* really struct nmlist pointer; pass 0 only */
+ char class; /* pass 1 only */
+ char regno; /* pass 1 only */
+ int offset; /* pass 1 only */
+ int nloc; /* pass 1 only */
};
/*
- * tree1 names for externals
+ * tree names for externals
*/
struct xtname {
int op;
int type;
- char class;
- char regno;
- int offset;
- char *name;
+ int *subsp; /* subscript list for arrays; pass 0 only */
+ union str *strp; /* structure descr for structs; pass 0 only */
+ union tree *tr1; /* really struct nmlist pointer; pass 0 only */
+ char class; /* pass 1 only */
+ char regno; /* pass 1 only */
+ int offset; /* pass 1 only */
+ char *name; /* pass 1 only */
};
/*
int type;
int *subsp; /* subscript list for arrays; pass 0 only */
union str *strp; /* structure descr for structs; pass 0 only */
- int degree; /* pass 1 only */
union tree *tr1;
union tree *tr2;
+ int degree; /* pass 1 only */
int mask;
};