add sextname() to make up long external names for things.
authorPeter B. Kessler <peter@ucbvax.Berkeley.EDU>
Wed, 25 Mar 1981 09:53:25 +0000 (01:53 -0800)
committerPeter B. Kessler <peter@ucbvax.Berkeley.EDU>
Wed, 25 Mar 1981 09:53:25 +0000 (01:53 -0800)
SCCS-vsn: usr.bin/pascal/src/call.c 1.11
SCCS-vsn: usr.bin/pascal/src/fend.c 1.4
SCCS-vsn: usr.bin/pascal/src/flvalue.c 1.8
SCCS-vsn: usr.bin/pascal/src/lab.c 1.8
SCCS-vsn: usr.bin/pascal/src/stab.c 1.6

usr/src/usr.bin/pascal/src/call.c
usr/src/usr.bin/pascal/src/fend.c
usr/src/usr.bin/pascal/src/flvalue.c
usr/src/usr.bin/pascal/src/lab.c
usr/src/usr.bin/pascal/src/stab.c

index 207ce0c..947d7c0 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.10 %G%";
+static char sccsid[] = "@(#)call.c 1.11 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -12,9 +12,6 @@ static        char sccsid[] = "@(#)call.c 1.10 %G%";
 #   include "pcops.h"
 #endif PC
 
 #   include "pcops.h"
 #endif PC
 
-short  slenline = 0;
-short  floatline = 0;
-
 /*
  * Call generates code for calls to
  * user defined procedures and functions
 /*
  * Call generates code for calls to
  * user defined procedures and functions
@@ -65,6 +62,8 @@ call(p, argv, porf, psbn)
            long        temptype;       /* type of the temporary */
            long        p_type_width;
            long        p_type_align;
            long        temptype;       /* type of the temporary */
            long        p_type_width;
            long        p_type_align;
+           char        extname[ BUFSIZ ];
+
 #      endif PC
 
 #      ifdef OBJ
 #      endif PC
 
 #      ifdef OBJ
@@ -117,25 +116,8 @@ call(p, argv, porf, psbn)
                        /*
                         *      ... p( ...
                         */
                        /*
                         *      ... p( ...
                         */
-                   {
-                       char    extname[ BUFSIZ ];
-                       char    *starthere;
-                       int     funcbn;
-                       int     i;
-
-                       starthere = &extname[0];
-                       funcbn = p -> nl_block & 037;
-                       for ( i = 1 ; i < funcbn ; i++ ) {
-                           sprintf( starthere , EXTFORMAT , enclosing[ i ] );
-                           starthere += strlen( enclosing[ i ] ) + 1;
-                       }
-                       sprintf( starthere , EXTFORMAT , p -> symbol );
-                       starthere += strlen( p -> symbol ) + 1;
-                       if ( starthere >= &extname[ BUFSIZ ] ) {
-                           panic( "call namelength" );
-                       }
-                       putleaf( P2ICON , 0 , 0 , p2type( p ) , extname );
-                   }
+                   sextname( extname , p -> symbol , p -> nl_block & 037 );
+                   putleaf( P2ICON , 0 , 0 , p2type( p ) , extname );
                    break;
                case FFUNC:
                case FPROC:
                    break;
                case FFUNC:
                case FPROC:
index b31d3d7..10e7d7e 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.3 %G%";
+static char sccsid[] = "@(#)fend.c 1.4 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -52,9 +52,10 @@ funcend(fp, bundle, endline)
        char *cp;
        extern int cntstat;
 #      ifdef PC
        char *cp;
        extern int cntstat;
 #      ifdef PC
-           int savlabel = getlab();
-           int toplabel = getlab();
-           int botlabel = getlab();
+           int         savlabel = getlab();
+           int         toplabel = getlab();
+           int         botlabel = getlab();
+           char        extname[ BUFSIZ ];
 #      endif PC
 
        cntstat = 0;
 #      endif PC
 
        cntstat = 0;
@@ -133,15 +134,9 @@ funcend(fp, bundle, endline)
            ftnno = fp -> entloc;
            putprintf( "        .text" , 0 );
            putprintf( "        .align  1" , 0 );
            ftnno = fp -> entloc;
            putprintf( "        .text" , 0 );
            putprintf( "        .align  1" , 0 );
-           putprintf( "        .globl  " , 1 );
-           for ( i = 1 ; i < cbn ; i++ ) {
-               putprintf( EXTFORMAT , 1 , enclosing[ i ] );
-           }
-           putprintf( "" , 0 );
-           for ( i = 1 ; i < cbn ; i++ ) {
-               putprintf( EXTFORMAT , 1 , enclosing[ i ] );
-           }
-           putprintf( ":" , 0 );
+           sextname( extname , fp -> symbol , cbn );
+           putprintf( "        .globl  %s" , 0 , extname );
+           putprintf( "%s:" , 0 , extname );
            stabfunc( fp -> symbol , fp -> class , bundle[1] , cbn - 1 );
            for ( p = fp -> chain ; p != NIL ; p = p -> chain ) {
                stabparam( p -> symbol , p2type( p -> type )
            stabfunc( fp -> symbol , fp -> class , bundle[1] , cbn - 1 );
            for ( p = fp -> chain ; p != NIL ; p = p -> chain ) {
                stabparam( p -> symbol , p2type( p -> type )
@@ -580,3 +575,29 @@ funcend(fp, bundle, endline)
                opop('l');
        }
 }
                opop('l');
        }
 }
+
+#ifdef PC
+    /*
+     * construct the long name of a function based on it's static nesting.
+     * into a caller-supplied buffer (that should be about BUFSIZ big).
+     */
+sextname( buffer , name , level )
+    char       buffer[];
+    char       *name;
+    int                level;
+{
+    char       *starthere;
+    int        i;
+
+    starthere = &buffer[0];
+    for ( i = 1 ; i < level ; i++ ) {
+       sprintf( starthere , EXTFORMAT , enclosing[ i ] );
+       starthere += strlen( enclosing[ i ] ) + 1;
+    }
+    sprintf( starthere , EXTFORMAT , p -> symbol );
+    starthere += strlen( p -> symbol ) + 1;
+    if ( starthere >= &buffer[ BUFSIZ ] ) {
+       panic( "sextname" );
+    }
+}
+#endif PC
index ab72a24..16d8e50 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.7 %G%";
+static char sccsid[] = "@(#)flvalue.c 1.8 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -34,6 +34,9 @@ flvalue( r , formalp )
        struct nl       *p;
        long            tempoff;
        char            *typename;
        struct nl       *p;
        long            tempoff;
        char            *typename;
+#ifdef PC
+       char            extname[ BUFSIZ ];
+#endif PC
 
        if ( r == NIL ) {
            return NIL;
 
        if ( r == NIL ) {
            return NIL;
@@ -95,23 +98,8 @@ flvalue( r , formalp )
                        putleaf( P2ICON , 0 , 0 ,
                            ADDTYPE( P2PTR , ADDTYPE( P2FTN , P2PTR|P2STRTY ) ) ,
                            "_FSAV" );
                        putleaf( P2ICON , 0 , 0 ,
                            ADDTYPE( P2PTR , ADDTYPE( P2FTN , P2PTR|P2STRTY ) ) ,
                            "_FSAV" );
-                       {
-                           char        extname[ BUFSIZ ];
-                           char        *starthere;
-                           int         i;
-
-                           starthere = &extname[0];
-                           for ( i = 1 ; i < bn ; i++ ) {
-                               sprintf( starthere , EXTFORMAT , enclosing[ i ] );
-                               starthere += strlen( enclosing[ i ] ) + 1;
-                           }
-                           sprintf( starthere , EXTFORMAT , p -> symbol );
-                           starthere += strlen( p -> symbol ) + 1;
-                           if ( starthere >= &extname[ BUFSIZ ] ) {
-                               panic( "flvalue namelength" );
-                           }
-                           putleaf( P2ICON , 0 , 0 , p2type( p ) , extname );
-                       }
+                       sextname( extname , p -> symbol , bn );
+                       putleaf( P2ICON , 0 , 0 , p2type( p ) , extname );
                        putleaf( P2ICON , bn , 0 , P2INT , 0 );
                        putop( P2LISTOP , P2INT );
                        putLV( 0 , cbn , tempoff , P2STRTY );
                        putleaf( P2ICON , bn , 0 , P2INT , 0 );
                        putop( P2LISTOP , P2INT );
                        putLV( 0 , cbn , tempoff , P2STRTY );
index b3d7c1c..380b53f 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.7 %G%";
+static char sccsid[] = "@(#)lab.c 1.8 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
index 8d9f138..e81c262 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[] = "@(#)stab.c 1.5 %G%";
+static char sccsid[] = "@(#)stab.c 1.6 %G%";
 
     /*
      * procedures to put out sdb symbol table information.
 
     /*
      * procedures to put out sdb symbol table information.
@@ -160,6 +160,7 @@ stabfunc( name , class , line , level )
     {
        int     type;
        long    i;
     {
        int     type;
        long    i;
+       char    extname[ BUFSIZ ];
 
            /*
             *  for separate compilation
 
            /*
             *  for separate compilation
@@ -181,11 +182,8 @@ stabfunc( name , class , line , level )
        }
        putprintf( "    .stabs  \"" , 1 );
        putprintf( NAMEFORMAT , 1 , name );
        }
        putprintf( "    .stabs  \"" , 1 );
        putprintf( NAMEFORMAT , 1 , name );
-       putprintf( "\",0x%x,0,0x%x," , 1 , N_FUN , line );
-       for ( i = 1 ; i < level ; i++ ) {
-           putprintf( EXTFORMAT , 1 , enclosing[ i ] );
-       }
-       putprintf( EXTFORMAT , 0 , name );
+       sextname( extname , name , level );
+       putprintf( "\",0x%x,0,0x%x,%s" , 0 , N_FUN , line , extname );
     }
 
     /*
     }
 
     /*