BSD 4_3 release
[unix-history] / usr / src / ucb / pascal / src / lab.c
index ddec17e..c065796 100644 (file)
@@ -1,6 +1,12 @@
-/* Copyright (c) 1979 Regents of the University of California */
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
 
 
-static char sccsid[] = "@(#)lab.c 1.17 2/1/83";
+#ifndef lint
+static char sccsid[] = "@(#)lab.c      5.1 (Berkeley) 6/5/85";
+#endif not lint
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -9,8 +15,9 @@ static char sccsid[] = "@(#)lab.c 1.17 2/1/83";
 #include "objfmt.h"
 #ifdef PC
 #   include    "pc.h"
 #include "objfmt.h"
 #ifdef PC
 #   include    "pc.h"
-#   include    "pcops.h"
+#   include    <pcc.h>
 #endif PC
 #endif PC
+#include "tree_ty.h"
 
 /*
  * Label enters the definitions
 
 /*
  * Label enters the definitions
@@ -18,7 +25,8 @@ static char sccsid[] = "@(#)lab.c 1.17 2/1/83";
  * into the namelist.
  */
 label(r, l)
  * into the namelist.
  */
 label(r, l)
-       int *r, l;
+       struct tnode *r;
+       int l;
 {
     static bool        label_order = FALSE;
     static bool        label_seen = FALSE;
 {
     static bool        label_order = FALSE;
     static bool        label_seen = FALSE;
@@ -26,7 +34,7 @@ label(r, l)
        char    extname[ BUFSIZ ];
 #endif PC
 #ifndef PI0
        char    extname[ BUFSIZ ];
 #endif PC
 #ifndef PI0
-       register *ll;
+       register struct tnode *ll;
        register struct nl *p, *lp;
 
        lp = NIL;
        register struct nl *p, *lp;
 
        lp = NIL;
@@ -65,13 +73,14 @@ label(r, l)
        parts[ cbn ] |= LPRT;
 #endif
 #ifndef PI0
        parts[ cbn ] |= LPRT;
 #endif
 #ifndef PI0
-       for (ll = r; ll != NIL; ll = ll[2]) {
-               l = getlab();
-               p = enter(defnl(ll[1], LABEL, 0, l));
+       for (ll = r; ll != TR_NIL; ll = ll->list_node.next) {
+               l = (int) getlab();
+               p = enter(defnl((char *) ll->list_node.list, LABEL, NLNIL,
+                               (int) l));
                /*
                 * Get the label for the eventual target
                 */
                /*
                 * Get the label for the eventual target
                 */
-               p->value[1] = getlab();
+               p->value[1] = (int) getlab();
                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;
@@ -84,8 +93,8 @@ label(r, l)
                     * and provides a target for
                     * gotos for this label via TRA.
                     */
                     * and provides a target for
                     * gotos for this label via TRA.
                     */
-                   putlab(l);
-                   put(2, O_GOTO | cbn<<8, (long)p->value[1]);
+                   (void) putlab((char *) l);
+                   (void) put(2, O_GOTO | cbn<<8, (long)p->value[1]);
 #              endif OBJ
 #              ifdef PC
                    /*
 #              endif OBJ
 #              ifdef PC
                    /*
@@ -94,7 +103,7 @@ label(r, l)
                     *  which defines them.
                     */
                    extlabname( extname , p -> symbol , cbn );
                     *  which defines them.
                     */
                    extlabname( extname , p -> symbol , cbn );
-                   putprintf(" .globl  %s", 0, extname);
+                   putprintf(" .globl  %s", 0, (int) extname);
                    if ( cbn == 1 ) {
                        stabglabel( extname , line );
                    }
                    if ( cbn == 1 ) {
                        stabglabel( extname , line );
                    }
@@ -128,9 +137,9 @@ gotoop(s)
        gocnt++;
        p = lookup(s);
        if (p == NIL)
        gocnt++;
        p = lookup(s);
        if (p == NIL)
-               return (NIL);
+               return;
 #      ifdef OBJ
 #      ifdef OBJ
-           put(2, O_TRA4, (long)p->value[NL_ENTLOC]);
+           (void) put(2, O_TRA4, (long)p->value[NL_ENTLOC]);
 #      endif OBJ
 #      ifdef PC
            if ( cbn == bn ) {
 #      endif OBJ
 #      ifdef PC
            if ( cbn == bn ) {
@@ -151,10 +160,10 @@ gotoop(s)
                     * the rest of the program.
                     */
 #              ifdef vax
                     * the rest of the program.
                     */
 #              ifdef vax
-                   putprintf(" jmp     %s", 0, extname);
+                   putprintf(" jmp     %s", 0, (int) extname);
 #              endif vax
 #              ifdef mc68000
 #              endif vax
 #              ifdef mc68000
-                   putprintf(" jra     %s", 0, extname);
+                   putprintf(" jra     %s", 0, (int) extname);
 #              endif mc68000
            } else {
                    /*
 #              endif mc68000
            } else {
                    /*
@@ -177,27 +186,27 @@ gotoop(s)
                     *  will be in its stack frame.
                     */
                parts[ bn ] |= NONLOCALGOTO;
                     *  will be in its stack frame.
                     */
                parts[ bn ] |= NONLOCALGOTO;
-               putleaf( P2ICON , 0 , 0 , ADDTYPE( P2FTN | P2INT , P2PTR )
+               putleaf( PCC_ICON , 0 , 0 , PCCM_ADDTYPE( PCCTM_FTN | PCCT_INT , PCCTM_PTR )
                        , "_PCLOSE" );
                if ( bn > 1 ) {
                    p = lookup( enclosing[ bn - 1 ] );
                    sprintf( extname, "%s%d+%d",
                        FRAME_SIZE_LABEL, p -> value[NL_ENTLOC], sizeof(int));
                    p = lookup(s);
                        , "_PCLOSE" );
                if ( bn > 1 ) {
                    p = lookup( enclosing[ bn - 1 ] );
                    sprintf( extname, "%s%d+%d",
                        FRAME_SIZE_LABEL, p -> value[NL_ENTLOC], sizeof(int));
                    p = lookup(s);
-                   putLV( extname , bn , 0 , NNLOCAL , P2PTR | P2CHAR );
+                   putLV( extname , bn , 0 , NNLOCAL , PCCTM_PTR | PCCT_CHAR );
                } else {
                } else {
-                   putLV( 0 , bn , -( DPOFF1 + sizeof( int ) ) , LOCALVAR ,
-                       P2PTR | P2CHAR );
+                   putLV((char *) 0 , bn , -( DPOFF1 + sizeof( int ) ) , LOCALVAR ,
+                       PCCTM_PTR | PCCT_CHAR );
                }
                }
-               putop( P2CALL , P2INT );
+               putop( PCC_CALL , PCCT_INT );
                putdot( filename , line );
                putdot( filename , line );
-               putleaf( P2ICON , 0 , 0 , ADDTYPE( P2FTN | P2INT , P2PTR )
+               putleaf( PCC_ICON , 0 , 0 , PCCM_ADDTYPE( PCCTM_FTN | PCCT_INT , PCCTM_PTR )
                        , "_longjmp" );
                        , "_longjmp" );
-               putLV( 0 , bn , GOTOENVOFFSET , NLOCAL , P2PTR|P2STRTY );
+               putLV((char *) 0 , bn , GOTOENVOFFSET , NLOCAL , PCCTM_PTR|PCCT_STRTY );
                extlabname( extname , p -> symbol , bn );
                extlabname( extname , p -> symbol , bn );
-               putLV( extname , 0 , 0 , NGLOBAL , P2PTR|P2STRTY );
-               putop( P2LISTOP , P2INT );
-               putop( P2CALL , P2INT );
+               putLV( extname , 0 , 0 , NGLOBAL , PCCTM_PTR|PCCT_STRTY );
+               putop( PCC_CM , PCCT_INT );
+               putop( PCC_CALL , PCCT_INT );
                putdot( filename , line );
            }
 #      endif PC
                putdot( filename , line );
            }
 #      endif PC
@@ -231,7 +240,7 @@ labeled(s)
 
        p = lookup(s);
        if (p == NIL)
 
        p = lookup(s);
        if (p == NIL)
-               return (NIL);
+               return;
        if (bn != cbn) {
                error("Label %s not defined in correct block", s);
                return;
        if (bn != cbn) {
                error("Label %s not defined in correct block", s);
                return;
@@ -242,16 +251,16 @@ labeled(s)
        }
        p->nl_flags &= ~NFORWD;
 #      ifdef OBJ
        }
        p->nl_flags &= ~NFORWD;
 #      ifdef OBJ
-           patch4(p->value[NL_ENTLOC]);
+           patch4((PTR_DCL) p->value[NL_ENTLOC]);
 #      endif OBJ
 #      ifdef PC
            extlabname( extname , p -> symbol , bn );
 #      endif OBJ
 #      ifdef PC
            extlabname( extname , p -> symbol , bn );
-           putprintf( "%s:" , 0 , extname );
+           putprintf( "%s:" , 0 , (int) extname );
 #      endif PC
        if (p->value[NL_GOLEV] != NOTYET)
                if (p->value[NL_GOLEV] < level) {
                        recovered();
 #      endif PC
        if (p->value[NL_GOLEV] != NOTYET)
                if (p->value[NL_GOLEV] < level) {
                        recovered();
-                       error("Goto %s from line %d is into a structured statement", s, p->value[NL_GOLINE]);
+                       error("Goto %s from line %d is into a structured statement", s, (char *) p->value[NL_GOLINE]);
                }
        p->value[NL_GOLEV] = level;
 }
                }
        p->value[NL_GOLEV] = level;
 }