X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/2b84abb596f52ab2068d52108adc96838ad4340a..31cef89cb428866f787983e68246030321893df4:/usr/src/cmd/pi/rec.c diff --git a/usr/src/cmd/pi/rec.c b/usr/src/cmd/pi/rec.c index a281f63bdd..bdb8fad05c 100644 --- a/usr/src/cmd/pi/rec.c +++ b/usr/src/cmd/pi/rec.c @@ -1,13 +1,8 @@ /* Copyright (c) 1979 Regents of the University of California */ -# -/* - * pi - Pascal interpreter code translator - * - * Charles Haley, Bill Joy UCB - * Version 1.2 Novmeber 1978 - */ -#include "whoami" +static char sccsid[] = "@(#)rec.c 1.2 9/22/80"; + +#include "whoami.h" #include "0.h" #include "tree.h" #include "opcode.h" @@ -78,6 +73,10 @@ tyrec1(r, off, first) fields(p, r[2]); variants(p, r[3]); } + /* + * round the lengths of records up to their alignments + */ + p -> value[ NL_OFFS ] = roundup( p -> value[ NL_OFFS ] , align( p ) ); P0 = P0was; return (p); } @@ -119,6 +118,9 @@ variants(p, r) if (r == NIL) return; ct = gtype(r[3]); + if ( isnta( ct , "bcsi" ) ) { + error("Tag fields cannot be %ss" , nameof( ct ) ); + } line = r[1]; /* * Want it even if r[2] is NIL so @@ -160,7 +162,16 @@ deffld(p, s, t) s = NIL; } #ifndef PI0 - fp = enter(defnl(s, FIELD, t, p->value[NL_OFFS])); + /* + * it used to be easy to keep track of offsets of fields + * and total sizes of records. + * but now, the offset of the field is aligned + * so only it knows it's offset, and calculating + * the total size of the record is based on it, + * rather than just the width of the field. + */ + fp = enter( defnl( s , FIELD , t , roundup( p -> value[ NL_OFFS ] + , align( t ) ) ) ); #else fp = enter(defnl(s, FIELD, t, 0)); #endif @@ -168,12 +179,20 @@ deffld(p, s, t) fp->chain = P0->chain; P0->chain = fp; #ifndef PI0 - p->value[NL_FLDSZ] = p->value[NL_OFFS] += even(width(t)); + /* + * and the size of the record is incremented. + */ + p -> value[ NL_OFFS ] = fp -> value[ NL_OFFS ] + width( t ); + p -> value[ NL_FLDSZ ] = p -> value[ NL_OFFS ]; #endif if (t != NIL) { P0->nl_flags |= t->nl_flags & NFILES; p->nl_flags |= t->nl_flags & NFILES; } +# ifdef PC + stabfield( s , p2type( t ) , fp -> value[ NL_OFFS ] + , lwidth( t ) ); +# endif PC } return (fp); } @@ -192,7 +211,7 @@ defvnt(p, t, vr, ct) register struct nl *av; gconst(t); - if (ct != NIL && incompat(con.ctype, ct)) { + if (ct != NIL && incompat(con.ctype, ct , t )) { #ifndef PI1 cerror("Variant label type incompatible with selector type"); #endif