convert namelist structure to use unions
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Fri, 27 Aug 1982 10:42:36 +0000 (02:42 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Fri, 27 Aug 1982 10:42:36 +0000 (02:42 -0800)
SCCS-vsn: usr.bin/pascal/src/0.h 1.15
SCCS-vsn: usr.bin/pascal/src/call.c 1.19
SCCS-vsn: usr.bin/pascal/src/fend.c 1.12
SCCS-vsn: usr.bin/pascal/src/fhdr.c 1.5
SCCS-vsn: usr.bin/pascal/src/flvalue.c 1.12
SCCS-vsn: usr.bin/pascal/src/lab.c 1.12
SCCS-vsn: usr.bin/pascal/src/savenl.c 1.5
SCCS-vsn: usr.bin/pascal/src/clas.c 1.5

usr/src/usr.bin/pascal/src/0.h
usr/src/usr.bin/pascal/src/call.c
usr/src/usr.bin/pascal/src/clas.c
usr/src/usr.bin/pascal/src/fend.c
usr/src/usr.bin/pascal/src/fhdr.c
usr/src/usr.bin/pascal/src/flvalue.c
usr/src/usr.bin/pascal/src/lab.c
usr/src/usr.bin/pascal/src/savenl.c

index c780be3..732033d 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-/* static char sccsid[] = "@(#)0.h 1.14 %G%"; */
+/* static char sccsid[] = "@(#)0.h 1.15 %G%"; */
 
 #define DEBUG
 #define CONSETS
 
 #define DEBUG
 #define CONSETS
@@ -220,15 +220,14 @@ bool      Enoline;
 
 /*
  * The basic namelist structure.
 
 /*
  * The basic namelist structure.
- * There are also two other variants, defining the real
- * field as longs or integers given below.
+ * There is a union of data types defining the stored information
+ * as pointers, integers, longs, or a double.
  *
  * The array disptab defines the hash header for the symbol table.
  * Symbols are hashed based on the low 6 bits of their pointer into
  * the string table; see the routines in the file "lookup.c" and also "fdec.c"
  * especially "funcend".
  */
  *
  * The array disptab defines the hash header for the symbol table.
  * Symbols are hashed based on the low 6 bits of their pointer into
  * the string table; see the routines in the file "lookup.c" and also "fdec.c"
  * especially "funcend".
  */
-extern struct  nl *Fp;
 extern int     pnumcnt;
 
 #ifdef PTREE
 extern int     pnumcnt;
 
 #ifdef PTREE
@@ -236,55 +235,33 @@ extern int        pnumcnt;
 #endif PTREE
 struct nl {
        char    *symbol;
 #endif PTREE
 struct nl {
        char    *symbol;
-       char    class, nl_flags;
-#ifdef PC
-       char    extra_flags;    /* for where things are */
-#endif PC
+       char    info[4];
        struct  nl *type;
        struct  nl *chain, *nl_next;
        struct  nl *type;
        struct  nl *chain, *nl_next;
-       int     value[5];
+       union {
+               int     *un_ptr[5];
+               int     un_value[5];
+               long    un_range[2];
+               double  un_real;
+       } nl_un;
 #      ifdef PTREE
            pPointer    inTree;
 #      endif PTREE
 #      ifdef PTREE
            pPointer    inTree;
 #      endif PTREE
-} *nlp, *disptab[077+1];
+};
 
 
-extern struct nl nl[INL];
+#define class info[0]
+#define nl_flags info[1]
+#define nl_block info[1]
+#define extra_flags info[2]
 
 
-struct {
-       char    *symbol;
-       char    class, nl_flags;
-#ifdef PC
-       char    extra_flags;
-#endif
-       struct  nl *type;
-       struct  nl *chain, *nl_next;
-       double  real;
-};
+#define range nl_un.un_range
+#define value nl_un.un_value
+#define ptr nl_un.un_ptr
+#define real nl_un.un_real
 
 
-struct {
-       char    *symbol;
-       char    class, nl_block;
-#ifdef PC
-       char    extra_flags;
-#endif
-       struct  nl *type;
-       struct  nl *chain, *nl_next;
-       long    range[2];
-};
+extern struct nl *nlp, *disptab[077+1], *Fp;
+extern struct nl nl[INL];
 
 
-struct {
-       char    *symbol;
-       char    class, nl_flags;
-#ifdef PC
-       char    extra_flags;
-#endif
-       struct  nl *type;
-       struct  nl *chain, *nl_next;
-       int     *ptr[4];
-#ifdef PI
-       int     entloc;
-#endif PI
-};
 \f
 /*
  * NL FLAGS BITS
 \f
 /*
  * NL FLAGS BITS
@@ -330,7 +307,8 @@ struct {
 #define NL_NLSTRT 2
 #define        NL_LINENO 3
 #define        NL_FVAR 3
 #define NL_NLSTRT 2
 #define        NL_LINENO 3
 #define        NL_FVAR 3
-#define        NL_FCHAIN 4
+#define        NL_ENTLOC 4     /* FUNC, PROC - entry point */
+#define        NL_FCHAIN 4     /* FFUNC, FPROC - ptr to formals */
 
 #define NL_GOLEV 2
 #define NL_GOLINE 3
 
 #define NL_GOLEV 2
 #define NL_GOLINE 3
@@ -341,7 +319,7 @@ struct {
 #define        NL_VTOREC 2
 #define        NL_TAG  3
 
 #define        NL_VTOREC 2
 #define        NL_TAG  3
 
-#define        NL_ELABEL       4
+#define        NL_ELABEL 4     /* SCAL - ptr to definition of enums */
 
 /*
  * For BADUSE nl structures, NL_KINDS is a bit vector
 
 /*
  * For BADUSE nl structures, NL_KINDS is a bit vector
index 9d19a5d..21df4a5 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)call.c 1.18 %G%";
+static char sccsid[] = "@(#)call.c 1.19 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -319,7 +319,7 @@ call(p, argv, porf, psbn)
                put(1, O_FCALL);
                put(2, O_FRTN, even(width(p->type)));
            } else {
                put(1, O_FCALL);
                put(2, O_FRTN, even(width(p->type)));
            } else {
-               put(2, O_CALL | psbn << 8, (long)p->entloc);
+               put(2, O_CALL | psbn << 8, (long)p->value[NL_ENTLOC]);
            }
 #      endif OBJ
 #      ifdef PC
            }
 #      endif OBJ
 #      ifdef PC
index 3c30bb1..b2ad89a 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)clas.c 1.4 %G%";
+static char sccsid[] = "@(#)clas.c 1.5 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -214,17 +214,17 @@ nowexp(r)
      *     positives are parameters
      *     negative evens are locals
      */
      *     positives are parameters
      *     negative evens are locals
      */
-whereis( level , offset , extra_flags )
+whereis( level , offset , other_flags )
     int                level;
     int                offset;
     int                level;
     int                offset;
-    char       extra_flags;
+    char       other_flags;
 {
     
 #   ifdef OBJ
        return ( offset >= 0 ? PARAMVAR : LOCALVAR );
 #   endif OBJ
 #   ifdef PC
 {
     
 #   ifdef OBJ
        return ( offset >= 0 ? PARAMVAR : LOCALVAR );
 #   endif OBJ
 #   ifdef PC
-       switch ( extra_flags & ( NGLOBAL | NPARAM | NLOCAL ) ) {
+       switch ( other_flags & ( NGLOBAL | NPARAM | NLOCAL ) ) {
            case NGLOBAL:
                return GLOBALVAR;
            case NPARAM:
            case NGLOBAL:
                return GLOBALVAR;
            case NPARAM:
index 3e126c7..f97ff49 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)fend.c 1.11 %G%";
+static char sccsid[] = "@(#)fend.c 1.12 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -78,7 +78,7 @@ funcend(fp, bundle, endline)
         * Patch the branch to the
         * entry point of the function
         */
         * Patch the branch to the
         * entry point of the function
         */
-       patch4(fp->entloc);
+       patch4(fp->value[NL_ENTLOC]);
        /*
         * Put out the block entrance code and the block name.
         * HDRSZE is the number of bytes of info in the static
        /*
         * Put out the block entrance code and the block name.
         * HDRSZE is the number of bytes of info in the static
@@ -131,14 +131,14 @@ funcend(fp, bundle, endline)
            putprintf( "        calls   $0,_program" , 0 );
            putprintf( "        pushl   $0" , 0 );
            putprintf( "        calls   $1,_PCEXIT" , 0 );
            putprintf( "        calls   $0,_program" , 0 );
            putprintf( "        pushl   $0" , 0 );
            putprintf( "        calls   $1,_PCEXIT" , 0 );
-           ftnno = fp -> entloc;
+           ftnno = fp -> value[NL_ENTLOC];
            putprintf( "        .text" , 0 );
            putprintf( "        .align  1" , 0 );
            putprintf( "        .globl  _program" , 0 );
            putprintf( "_program:" , 0 );
            stabfunc( "program" , fp -> class , bundle[1] , 0 );
        } else {
            putprintf( "        .text" , 0 );
            putprintf( "        .align  1" , 0 );
            putprintf( "        .globl  _program" , 0 );
            putprintf( "_program:" , 0 );
            stabfunc( "program" , fp -> class , bundle[1] , 0 );
        } else {
-           ftnno = fp -> entloc;
+           ftnno = fp -> value[NL_ENTLOC];
            putprintf( "        .text" , 0 );
            putprintf( "        .align  1" , 0 );
            sextname( extname , fp -> symbol , cbn - 1 );
            putprintf( "        .text" , 0 );
            putprintf( "        .align  1" , 0 );
            sextname( extname , fp -> symbol , cbn - 1 );
index 415c1b0..85ca796 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)fhdr.c 1.4 %G%";
+static char sccsid[] = "@(#)fhdr.c 1.5 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -241,13 +241,13 @@ funchdr(r)
         * the "entry point" of
         * the prog/proc/func.
         */
         * the "entry point" of
         * the prog/proc/func.
         */
-       p->entloc = getlab();
+       p->value[NL_ENTLOC] = getlab();
        if (monflg) {
                bodycnts[ cbn ] = getcnt();
                p->value[ NL_CNTR ] = 0;
        }
 #      ifdef OBJ
        if (monflg) {
                bodycnts[ cbn ] = getcnt();
                p->value[ NL_CNTR ] = 0;
        }
 #      ifdef OBJ
-           put(2, O_TRA4, (long)p->entloc);
+           put(2, O_TRA4, (long)p->value[NL_ENTLOC]);
 #      endif OBJ
 #      ifdef PTREE
            {
 #      endif OBJ
 #      ifdef PTREE
            {
index 7bc040d..9895770 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1980 Regents of the University of California */
 
 /* Copyright (c) 1980 Regents of the University of California */
 
-static char sccsid[] = "@(#)flvalue.c 1.11 %G%";
+static char sccsid[] = "@(#)flvalue.c 1.12 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -78,7 +78,7 @@ flvalue( r , formalp )
 #                  ifdef OBJ
                        put(2 , O_LV | cbn << 8 + INDX ,
                                (int)tempnlp -> value[ NL_OFFS ] );
 #                  ifdef OBJ
                        put(2 , O_LV | cbn << 8 + INDX ,
                                (int)tempnlp -> value[ NL_OFFS ] );
-                       put(2, O_FSAV | bn << 8, (long)p->entloc);
+                       put(2, O_FSAV | bn << 8, (long)p->value[NL_ENTLOC]);
 #                  endif OBJ
 #                  ifdef PC
                        putleaf( P2ICON , 0 , 0 ,
 #                  endif OBJ
 #                  ifdef PC
                        putleaf( P2ICON , 0 , 0 ,
index 54c7a21..072f802 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)lab.c 1.11 %G%";
+static char sccsid[] = "@(#)lab.c 1.12 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -65,7 +65,7 @@ label(r, l)
                p->chain = lp;
                p->nl_flags |= (NFORWD|NMOD);
                p->value[NL_GOLEV] = NOTYET;
                p->chain = lp;
                p->nl_flags |= (NFORWD|NMOD);
                p->value[NL_GOLEV] = NOTYET;
-               p->entloc = l;
+               p->value[NL_ENTLOC] = l;
                lp = p;
 #              ifdef OBJ
                    /*
                lp = p;
 #              ifdef OBJ
                    /*
@@ -121,7 +121,7 @@ gotoop(s)
        if (p == NIL)
                return (NIL);
 #      ifdef OBJ
        if (p == NIL)
                return (NIL);
 #      ifdef OBJ
-           put(2, O_TRA4, (long)p->entloc);
+           put(2, O_TRA4, (long)p->value[NL_ENTLOC]);
 #      endif OBJ
 #      ifdef PC
            if ( cbn != bn ) {
 #      endif OBJ
 #      ifdef PC
            if ( cbn != bn ) {
@@ -184,7 +184,7 @@ labeled(s)
        }
        p->nl_flags &= ~NFORWD;
 #      ifdef OBJ
        }
        p->nl_flags &= ~NFORWD;
 #      ifdef OBJ
-           patch4(p->entloc);
+           patch4(p->value[NL_ENTLOC]);
 #      endif OBJ
 #      ifdef PC
            extlabname( extname , p -> symbol , bn );
 #      endif OBJ
 #      ifdef PC
            extlabname( extname , p -> symbol , bn );
index 4d5ea8f..0784ab7 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1982 Regents of the University of California */
 
 /* Copyright (c) 1982 Regents of the University of California */
 
-static char sccsid[] = "@(#)savenl.c 1.4 %G%";
+static char sccsid[] = "@(#)savenl.c 1.5 %G%";
 
 /*
  * savenl - routines for saving namelist and line number information
 
 /*
  * savenl - routines for saving namelist and line number information
@@ -210,7 +210,7 @@ struct nl *to;
                s->osymvalue.orangev.lower = p->range[0];
                s->osymvalue.orangev.upper = p->range[1];
                if (isblock(p)) {
                s->osymvalue.orangev.lower = p->range[0];
                s->osymvalue.orangev.upper = p->range[1];
                if (isblock(p)) {
-                       s->osymvalue.ofuncv.codeloc = p->entloc;
+                       s->osymvalue.ofuncv.codeloc = p->value[NL_ENTLOC];
                } else if (p->class == RECORD || p->class == VARNT) {
                        s->osymvalue.ovarnt.vtorecno = symno(p->ptr[2]);
                        s->osymvalue.ovarnt.vtagno = symno(p->ptr[3]);
                } else if (p->class == RECORD || p->class == VARNT) {
                        s->osymvalue.ovarnt.vtorecno = symno(p->ptr[2]);
                        s->osymvalue.ovarnt.vtagno = symno(p->ptr[3]);