# 2.11BSD#431 - /usr/src/ucb/PORT/pascal/src/p2put.c

##### Functions

    p2name            X
    p2opname          X
    p2string          X
    p2type            X
    p2word            X
    printjbr          X
    put               X
    putCON8           X
    putCONG           X
    putLV             X
    putRV             X
    putdot            X
    puteof            X
    putjbr            X
    putlbracket       X
    putleaf           X
    putop             X
    putprintf         X
    putrbracket       X
    putstrop          X
    puttext           X
    str4len           X
    typerecur         X

##### Macros

    MAXQUALS          X

##### struct's

    p2op              X

       1: /*
       2:  * Copyright (c) 1980 Regents of the University of California.
       3:  * All rights reserved.  The Berkeley software License Agreement
       4:  * specifies the terms and conditions for redistribution.
       5:  */
       6:
       7: #ifndef lint
       8: static char sccsid[] = "@(#)p2put.c	5.3 (Berkeley) 6/21/85";
       9: #endif not lint
      10:
      11:     /*
      12:      *	functions to help pi put out
      13:      *	polish postfix binary portable c compiler intermediate code
      14:      *	thereby becoming the portable pascal compiler
      15:      */
      16:
      17: #include    "whoami.h"
      18: #ifdef PC
      19: #include    "0.h"
      20: #include    "objfmt.h"
      21: #include    <pcc.h>
      22: #include    "pc.h"
      23: #include    "align.h"
      24: #include    "tmps.h"
      25:
      26:     /*
      27:      *	emits an ftext operator and a string to the pcstream
      28:      */
      29: puttext( string )
      30:     char    *string;
      31:     {
      32:     int length = str4len( string );
      33:
      34:     if ( !CGENNING )
      35:         return;
      36:     p2word( PCCM_TRIPLE( PCCF_FTEXT , length , 0 ) );
      37: #	ifdef DEBUG
      38:         if ( opt( 'k' ) ) {
      39:         fprintf( stdout , "PCCF_FTEXT | %3d | 0	" , length );
      40:         }
      41: #	endif
      42:     p2string( string );
      43:     }
      44:
      45: int
      46: str4len( string )
      47:     char    *string;
      48:     {
      49:
      50:     return ( ( strlen( string ) + 3 ) / 4 );
      51:     }
      52:
      53:     /*
      54:      *	put formatted text into a buffer for printing to the pcstream.
      55:      *	a call to putpflush actually puts out the text.
      56:      *	none of arg1 .. arg5 need be present.
      57:      *	and you can add more if you need them.
      58:      */
      59: /* VARARGS */
      60: putprintf( format , incomplete , arg1 , arg2 , arg3 , arg4 , arg5 )
      61:     char    *format;
      62:     int     incomplete;
      63:     {
      64:     static char ppbuffer[ BUFSIZ ];
      65:     static char *ppbufp = ppbuffer;
      66:
      67:     if ( !CGENNING )
      68:         return;
      69:     sprintf( ppbufp , format , arg1 , arg2 , arg3 , arg4 , arg5 );
      70:     ppbufp = &( ppbuffer[ strlen( ppbuffer ) ] );
      71:     if ( ppbufp >= &( ppbuffer[ BUFSIZ ] ) )
      72:         panic( "putprintf" );
      73:     if ( ! incomplete ) {
      74:         puttext( ppbuffer );
      75:         ppbufp = ppbuffer;
      76:     }
      77:     }
      78:
      79:     /*
      80:      *	emit a left bracket operator to pcstream
      81:      *	with function number, the maximum temp register, and total local bytes
      82:      */
      83: putlbracket(ftnno, sizesp)
      84:     int     ftnno;
      85:     struct om   *sizesp;
      86: {
      87:     int maxtempreg;
      88:     int alignedframesize;
      89:
      90: #   ifdef vax
      91:     maxtempreg = sizesp->curtmps.next_avail[REG_GENERAL];
      92: #   endif vax
      93: #   ifdef mc68000
      94:         /*
      95: 	     *	this is how /lib/f1 wants it.
      96: 	     */
      97:     maxtempreg =    (sizesp->curtmps.next_avail[REG_ADDR] << 4)
      98:               | (sizesp->curtmps.next_avail[REG_DATA]);
      99: #   endif mc68000
     100:     alignedframesize = roundup((int)(BITSPERBYTE * -sizesp->curtmps.om_off),
     101:     (long)(BITSPERBYTE * A_STACK));
     102:     p2word( PCCM_TRIPLE( PCCF_FLBRAC , maxtempreg , ftnno ) );
     103:     p2word(alignedframesize);
     104: #   ifdef DEBUG
     105:     if ( opt( 'k' ) ) {
     106:         fprintf(stdout, "PCCF_FLBRAC | %3d | %d	%d\n",
     107:         maxtempreg, ftnno, alignedframesize);
     108:     }
     109: #   endif
     110: }
     111:
     112:     /*
     113:      *	emit a right bracket operator
     114:      *	which for the binary interface
     115:      *	forces the stack allocate and register mask
     116:      */
     117: putrbracket( ftnno )
     118:     int ftnno;
     119:     {
     120:
     121:     p2word( PCCM_TRIPLE( PCCF_FRBRAC , 0 , ftnno ) );
     122: #	ifdef DEBUG
     123:         if ( opt( 'k' ) ) {
     124:         fprintf( stdout , "PCCF_FRBRAC |   0 | %d\n" , ftnno );
     125:         }
     126: #	endif
     127:     }
     128:
     129:     /*
     130:      *	emit an eof operator
     131:      */
     132: puteof()
     133:     {
     134:
     135:     p2word( PCCF_FEOF );
     136: #	ifdef DEBUG
     137:         if ( opt( 'k' ) ) {
     138:         fprintf( stdout , "PCCF_FEOF\n" );
     139:         }
     140: #	endif
     141:     }
     142:
     143:     /*
     144:      *	emit a dot operator,
     145:      *	with a source file line number and name
     146:      *	if line is negative, there was an error on that line, but who cares?
     147:      */
     148: putdot( filename , line )
     149:     char    *filename;
     150:     int     line;
     151:     {
     152:     int length = str4len( filename );
     153:
     154:     if ( line < 0 ) {
     155:         line = -line;
     156:     }
     157:     p2word( PCCM_TRIPLE( PCCF_FEXPR , length , line ) );
     158: #	ifdef DEBUG
     159:         if ( opt( 'k' ) ) {
     160:         fprintf( stdout , "PCCF_FEXPR | %3d | %d	" , length , line );
     161:         }
     162: #	endif
     163:     p2string( filename );
     164:     }
     165:
     166:     /*
     167:      *	put out a leaf node
     168:      */
     169: putleaf( op , lval , rval , type , name )
     170:     int     op;
     171:     int     lval;
     172:     int     rval;
     173:     int     type;
     174:     char    *name;
     175:     {
     176:     if ( !CGENNING )
     177:         return;
     178:     switch ( op ) {
     179:         default:
     180:         panic( "[putleaf]" );
     181:         case PCC_ICON:
     182:         p2word( PCCM_TRIPLE( PCC_ICON , name != NIL , type ) );
     183:         p2word( lval );
     184: #		ifdef DEBUG
     185:             if ( opt( 'k' ) ) {
     186:             fprintf( stdout , "PCC_ICON | %3d | 0x%x	"
     187:                    , name != NIL , type );
     188:             fprintf( stdout , "%d\n" , lval );
     189:             }
     190: #		endif
     191:         if ( name )
     192:             p2name( name );
     193:         break;
     194:         case PCC_NAME:
     195:         p2word( PCCM_TRIPLE( PCC_NAME , lval != 0 , type ) );
     196:         if ( lval )
     197:             p2word( lval );
     198: #		ifdef DEBUG
     199:             if ( opt( 'k' ) ) {
     200:             fprintf( stdout , "PCC_NAME | %3d | 0x%x	"
     201:                    , lval != 0 , type );
     202:             if ( lval )
     203:                 fprintf( stdout , "%d	" , lval );
     204:             }
     205: #		endif
     206:         p2name( name );
     207:         break;
     208:         case PCC_REG:
     209:         p2word( PCCM_TRIPLE( PCC_REG , rval , type ) );
     210: #		ifdef DEBUG
     211:             if ( opt( 'k' ) ) {
     212:             fprintf( stdout , "PCC_REG | %3d | 0x%x\n" ,
     213:                 rval , type );
     214:             }
     215: #		endif
     216:         break;
     217:     }
     218:     }
     219:
     220:     /*
     221:      *	rvalues are just lvalues with indirection, except
     222:      *	special cases for registers and for named globals,
     223:      *	whose names are their rvalues.
     224:      */
     225: putRV( name , level , offset , other_flags , type )
     226:     char    *name;
     227:     int     level;
     228:     int     offset;
     229:     char    other_flags;
     230:     int     type;
     231:     {
     232:     char    extname[ BUFSIZ ];
     233:     char    *printname;
     234:
     235:     if ( !CGENNING )
     236:         return;
     237:     if ( other_flags & NREGVAR ) {
     238:         if ( ( offset < 0 ) || ( offset > P2FP ) ) {
     239:         panic( "putRV regvar" );
     240:         }
     241:         putleaf( PCC_REG , 0 , offset , type , (char *) 0 );
     242:         return;
     243:     }
     244:     if ( whereis( offset , other_flags ) == GLOBALVAR ) {
     245:         if ( name != 0 ) {
     246:         if ( name[0] != '_' ) {
     247:             sprintf( extname , EXTFORMAT , name );
     248:             printname = extname;
     249:         } else {
     250:             printname = name;
     251:         }
     252:         putleaf( PCC_NAME , offset , 0 , type , printname );
     253:         return;
     254:         } else {
     255:         panic( "putRV no name" );
     256:         }
     257:     }
     258:     putLV( name , level , offset , other_flags , type );
     259:     putop( PCCOM_UNARY PCC_MUL , type );
     260:     }
     261:
     262:     /*
     263:      *	put out an lvalue
     264:      *	given a level and offset
     265:      *	special case for
     266:      *	    named globals, whose lvalues are just their names as constants.
     267:      */
     268: putLV( name , level , offset , other_flags , type )
     269:     char    *name;
     270:     int     level;
     271:     int     offset;
     272:     char    other_flags;
     273:     int     type;
     274: {
     275:     char        extname[ BUFSIZ ];
     276:     char        *printname;
     277:
     278:     if ( !CGENNING )
     279:     return;
     280:     if ( other_flags & NREGVAR ) {
     281:     panic( "putLV regvar" );
     282:     }
     283:     switch ( whereis( offset , other_flags ) ) {
     284:     case GLOBALVAR:
     285:         if ( ( name != 0 ) ) {
     286:         if ( name[0] != '_' ) {
     287:             sprintf( extname , EXTFORMAT , name );
     288:             printname = extname;
     289:         } else {
     290:             printname = name;
     291:         }
     292:         putleaf( PCC_ICON , offset , 0 , PCCM_ADDTYPE( type , PCCTM_PTR )
     293:             , printname );
     294:         return;
     295:         } else {
     296:         panic( "putLV no name" );
     297:         }
     298:     case PARAMVAR:
     299:         if ( level == cbn ) {
     300:         putleaf( PCC_REG, 0, P2AP, PCCM_ADDTYPE( type , PCCTM_PTR ), (char *) 0 );
     301:         } else {
     302:         putleaf( PCC_NAME , (level * sizeof(struct dispsave)) + AP_OFFSET
     303:             , 0 , PCCTM_PTR | PCCT_CHAR , DISPLAYNAME );
     304:         parts[ level ] |= NONLOCALVAR;
     305:         }
     306:         putleaf( PCC_ICON , offset , 0 , PCCT_INT , (char *) 0 );
     307:         putop( PCC_PLUS , PCCTM_PTR | PCCT_CHAR );
     308:         break;
     309:     case LOCALVAR:
     310:         if ( level == cbn ) {
     311:         putleaf( PCC_REG, 0, P2FP, PCCM_ADDTYPE( type , PCCTM_PTR ), (char *) 0 );
     312:         } else {
     313:         putleaf( PCC_NAME , (level * sizeof(struct dispsave)) + FP_OFFSET
     314:             , 0 , PCCTM_PTR | PCCT_CHAR , DISPLAYNAME );
     315:         parts[ level ] |= NONLOCALVAR;
     316:         }
     317:         putleaf( PCC_ICON , -offset , 0 , PCCT_INT , (char *) 0 );
     318:         putop( PCC_MINUS , PCCTM_PTR | PCCT_CHAR );
     319:         break;
     320:     case NAMEDLOCALVAR:
     321:         if ( level == cbn ) {
     322:         putleaf( PCC_REG, 0, P2FP, PCCM_ADDTYPE( type , PCCTM_PTR ), (char *) 0 );
     323:         } else {
     324:         putleaf( PCC_NAME , (level * sizeof(struct dispsave)) + FP_OFFSET
     325:             , 0 , PCCTM_PTR | PCCT_CHAR , DISPLAYNAME );
     326:         parts[ level ] |= NONLOCALVAR;
     327:         }
     328:         putleaf( PCC_ICON , 0 , 0 , PCCT_INT , name );
     329:         putop( PCC_MINUS , PCCTM_PTR | PCCT_CHAR );
     330:         break;
     331:     }
     332:     return;
     333: }
     334:
     335:     /*
     336:      *	put out a floating point constant leaf node
     337:      *	the constant is declared in aligned data space
     338:      *	and a PCC_NAME leaf put out for it
     339:      */
     340: putCON8( val )
     341:     double  val;
     342:     {
     343:     char    *label;
     344:     char    name[ BUFSIZ ];
     345:
     346:     if ( !CGENNING )
     347:         return;
     348:     label = getlab();
     349:     putprintf( "	.data" , 0 );
     350:     aligndot(A_DOUBLE);
     351:     (void) putlab( label );
     352: #	ifdef vax
     353:         putprintf( "	.double 0d%.20e" , 0 , val );
     354: #	endif vax
     355: #	ifdef mc68000
     356:         putprintf( "	.long 	0x%x,0x%x", 0, val);
     357: #	endif mc68000
     358:     putprintf( "	.text" , 0 );
     359:     sprintf( name , PREFIXFORMAT , LABELPREFIX , label );
     360:     putleaf( PCC_NAME , 0 , 0 , PCCT_DOUBLE , name );
     361:     }
     362:
     363:     /*
     364: 	 * put out either an lvalue or an rvalue for a constant string.
     365: 	 * an lvalue (for assignment rhs's) is the name as a constant,
     366: 	 * an rvalue (for parameters) is just the name.
     367: 	 */
     368: putCONG( string , length , required )
     369:     char    *string;
     370:     int     length;
     371:     int     required;
     372:     {
     373:     char    name[ BUFSIZ ];
     374:     char    *label;
     375:     char    *cp;
     376:     int pad;
     377:     int others;
     378:
     379:     if ( !CGENNING )
     380:         return;
     381:     putprintf( "	.data" , 0 );
     382:     aligndot(A_STRUCT);
     383:     label = getlab();
     384:     (void) putlab( label );
     385:     cp = string;
     386:     while ( *cp ) {
     387:         putprintf( "	.byte	0%o" , 1 , *cp ++ );
     388:         for ( others = 2 ; ( others <= 8 ) && *cp ; others ++ ) {
     389:         putprintf( ",0%o" , 1 , *cp++ );
     390:         }
     391:         putprintf( "" , 0 );
     392:     }
     393:     pad = length - strlen( string );
     394:     while ( pad-- > 0 ) {
     395:         putprintf( "	.byte	0%o" , 1 , ' ' );
     396:         for ( others = 2 ; ( others <= 8 ) && ( pad-- > 0 ) ; others++ ) {
     397:         putprintf( ",0%o" , 1 , ' ' );
     398:         }
     399:         putprintf( "" , 0 );
     400:     }
     401:     putprintf( "	.byte	0" , 0 );
     402:     putprintf( "	.text"  , 0 );
     403:     sprintf( name , PREFIXFORMAT , LABELPREFIX , label );
     404:     if ( required == RREQ ) {
     405:         putleaf( PCC_NAME , 0 , 0 , PCCTM_ARY | PCCT_CHAR , name );
     406:     } else {
     407:         putleaf( PCC_ICON , 0 , 0 , PCCTM_PTR | PCCT_CHAR , name );
     408:     }
     409:     }
     410:
     411:     /*
     412:      *	map a pascal type to a c type
     413:      *	this would be tail recursive, but i unfolded it into a for (;;).
     414:      *	this is sort of like isa and lwidth
     415:      *	a note on the types used by the portable c compiler:
     416:      *	    they are divided into a basic type (char, short, int, long, etc.)
     417:      *	    and qualifications on those basic types (pointer, function, array).
     418:      *	    the basic type is kept in the low 4 bits of the type descriptor,
     419:      *	    and the qualifications are arranged in two bit chunks, with the
     420:      *	    most significant on the right,
     421:      *	    and the least significant on the left
     422:      *		e.g. int *foo();
     423:      *			(a function returning a pointer to an integer)
     424:      *		is stored as
     425:      *		    <ptr><ftn><int>
     426:      *	so, we build types recursively
     427:      *	also, we know that /lib/f1 can only deal with 6 qualifications
     428:      *	so we stop the recursion there.  this stops infinite type recursion
     429:      *	through mutually recursive pointer types.
     430:      */
     431: #define MAXQUALS    6
     432: int
     433: p2type( np )
     434:     struct nl   *np;
     435: {
     436:
     437:     return typerecur( np , 0 );
     438: }
     439: typerecur( np , quals )
     440:     struct nl   *np;
     441:     int     quals;
     442:     {
     443:
     444:     if ( np == NIL || quals > MAXQUALS ) {
     445:         return PCCT_UNDEF;
     446:     }
     447:     switch ( np -> class ) {
     448:         case SCAL :
     449:         case RANGE :
     450:         case CRANGE :
     451:         if ( np -> type == ( nl + TDOUBLE ) ) {
     452:             return PCCT_DOUBLE;
     453:         }
     454:         switch ( bytes( np -> range[0] , np -> range[1] ) ) {
     455:             case 1:
     456:             return PCCT_CHAR;
     457:             case 2:
     458:             return PCCT_SHORT;
     459:             case 4:
     460:             return PCCT_INT;
     461:             default:
     462:             panic( "p2type int" );
     463:             /* NOTREACHED */
     464:         }
     465:         case STR :
     466:         return ( PCCTM_ARY | PCCT_CHAR );
     467:         case RECORD :
     468:         case SET :
     469:         return PCCT_STRTY;
     470:         case FILET :
     471:         return ( PCCTM_PTR | PCCT_STRTY );
     472:         case CONST :
     473:         case VAR :
     474:         case FIELD :
     475:         return p2type( np -> type );
     476:         case TYPE :
     477:         switch ( nloff( np ) ) {
     478:             case TNIL :
     479:             return ( PCCTM_PTR | PCCT_UNDEF );
     480:             case TSTR :
     481:             return ( PCCTM_ARY | PCCT_CHAR );
     482:             case TSET :
     483:             return PCCT_STRTY;
     484:             default :
     485:             return ( p2type( np -> type ) );
     486:         }
     487:         case REF:
     488:         case WITHPTR:
     489:         case PTR :
     490:         return PCCM_ADDTYPE( typerecur( np -> type , quals + 1 ) , PCCTM_PTR );
     491:         case ARRAY :
     492:         return PCCM_ADDTYPE( typerecur( np -> type , quals + 1 ) , PCCTM_ARY );
     493:         case FUNC :
     494:             /*
     495: 		     * functions are really pointers to functions
     496: 		     * which return their underlying type.
     497: 		     */
     498:         return PCCM_ADDTYPE( PCCM_ADDTYPE( typerecur( np -> type , quals + 2 ) ,
     499:                     PCCTM_FTN ) , PCCTM_PTR );
     500:         case PROC :
     501:             /*
     502: 		     * procedures are pointers to functions
     503: 		     * which return integers (whether you look at them or not)
     504: 		     */
     505:         return PCCM_ADDTYPE( PCCM_ADDTYPE( PCCT_INT , PCCTM_FTN ) , PCCTM_PTR );
     506:         case FFUNC :
     507:         case FPROC :
     508:             /*
     509: 		     *	formal procedures and functions are pointers
     510: 		     *	to structures which describe their environment.
     511: 		     */
     512:         return ( PCCTM_PTR | PCCT_STRTY );
     513:         default :
     514:         panic( "p2type" );
     515:         /* NOTREACHED */
     516:     }
     517:     }
     518:
     519:     /*
     520:      *	put a typed operator to the pcstream
     521:      */
     522: putop( op , type )
     523:     int     op;
     524:     int     type;
     525:     {
     526:     extern char *p2opname();
     527:
     528:     if ( !CGENNING )
     529:         return;
     530:     p2word( PCCM_TRIPLE( op , 0 , type ) );
     531: #	ifdef DEBUG
     532:         if ( opt( 'k' ) ) {
     533:         fprintf( stdout , "%s (%d) |   0 | 0x%x\n"
     534:             , p2opname( op ) , op , type );
     535:         }
     536: #	endif
     537:     }
     538:
     539:     /*
     540:      *	put out a structure operator (STASG, STARG, STCALL, UNARY STCALL )
     541:      *	which looks just like a regular operator, only the size and
     542:      *	alignment go in the next consecutive words
     543:      */
     544: putstrop( op , type , size , alignment )
     545:     int op;
     546:     int type;
     547:     int size;
     548:     int alignment;
     549:     {
     550:     extern char *p2opname();
     551:
     552:     if ( !CGENNING )
     553:         return;
     554:     p2word( PCCM_TRIPLE( op , 0 , type ) );
     555:     p2word( size );
     556:     p2word( alignment );
     557: #	ifdef DEBUG
     558:         if ( opt( 'k' ) ) {
     559:         fprintf( stdout , "%s (%d) |   0 | 0x%x	%d %d\n"
     560:             , p2opname( op ) , op , type , size , alignment );
     561:         }
     562: #	endif
     563:     }
     564:
     565:     /*
     566:      *	the string names of p2ops
     567:      */
     568:
     569: struct p2op {
     570:     int op;
     571:     char *name;
     572: };
     573:
     574: static struct p2op  p2opnames[] = {
     575:     PCC_ERROR, "PCC_ERROR",
     576:     PCC_NAME, "PCC_NAME",
     577:     PCC_STRING, "PCC_STRING",
     578:     PCC_ICON, "PCC_ICON",
     579:     PCC_FCON, "PCC_FCON",
     580:     PCC_PLUS, "PCC_PLUS",
     581:     PCC_MINUS, "PCC_MINUS",
     582:     PCC_UMINUS, "PCC_UMINUS",
     583:     PCC_MUL, "PCC_MUL",
     584:     PCC_DEREF, "PCC_DEREF",
     585:     PCC_AND, "PCC_AND",
     586:     PCC_ADDROF, "PCC_ADDROF",
     587:     PCC_OR, "PCC_OR",
     588:     PCC_ER, "PCC_ER",
     589:     PCC_QUEST, "PCC_QUEST",
     590:     PCC_COLON, "PCC_COLON",
     591:     PCC_ANDAND, "PCC_ANDAND",
     592:     PCC_OROR, "PCC_OROR",
     593:     PCC_CM, "PCC_CM",
     594:     PCC_ASSIGN, "PCC_ASSIGN",
     595:     PCC_COMOP, "PCC_COMOP",
     596:     PCC_DIV, "PCC_DIV",
     597:     PCC_MOD, "PCC_MOD",
     598:     PCC_LS, "PCC_LS",
     599:     PCC_RS, "PCC_RS",
     600:     PCC_DOT, "PCC_DOT",
     601:     PCC_STREF, "PCC_STREF",
     602:     PCC_CALL, "PCC_CALL",
     603:     PCC_UCALL, "PCC_UCALL",
     604:     PCC_FORTCALL, "PCC_FORTCALL",
     605:     PCC_UFORTCALL, "PCC_UFORTCALL",
     606:     PCC_NOT, "PCC_NOT",
     607:     PCC_COMPL, "PCC_COMPL",
     608:     PCC_INCR, "PCC_INCR",
     609:     PCC_DECR, "PCC_DECR",
     610:     PCC_EQ, "PCC_EQ",
     611:     PCC_NE, "PCC_NE",
     612:     PCC_LE, "PCC_LE",
     613:     PCC_LT, "PCC_LT",
     614:     PCC_GE, "PCC_GE",
     615:     PCC_GT, "PCC_GT",
     616:     PCC_ULE, "PCC_ULE",
     617:     PCC_ULT, "PCC_ULT",
     618:     PCC_UGE, "PCC_UGE",
     619:     PCC_UGT, "PCC_UGT",
     620:     PCC_REG, "PCC_REG",
     621:     PCC_OREG, "PCC_OREG",
     622:     PCC_CCODES, "PCC_CCODES",
     623:     PCC_FREE, "PCC_FREE",
     624:     PCC_STASG, "PCC_STASG",
     625:     PCC_STARG, "PCC_STARG",
     626:     PCC_STCALL, "PCC_STCALL",
     627:     PCC_USTCALL, "PCC_USTCALL",
     628:     PCC_FLD, "PCC_FLD",
     629:     PCC_SCONV, "PCC_SCONV",
     630:     PCC_PCONV, "PCC_PCONV",
     631:     PCC_PMCONV, "PCC_PMCONV",
     632:     PCC_PVCONV, "PCC_PVCONV",
     633:     PCC_FORCE, "PCC_FORCE",
     634:     PCC_CBRANCH, "PCC_CBRANCH",
     635:     PCC_INIT, "PCC_INIT",
     636:     PCC_CAST, "PCC_CAST",
     637:     -1, ""
     638:     };
     639:
     640: char *
     641: p2opname( op )
     642:     register int    op;
     643:     {
     644:     static char     *p2map[PCC_MAXOP+1];
     645:     static bool     mapready = FALSE;
     646:     register struct p2op    *pp;
     647:
     648:     if ( mapready == FALSE ) {
     649:         for ( pp = p2opnames; pp->op >= 0; pp++ )
     650:         p2map[ pp->op ] = pp->name;
     651:         mapready = TRUE;
     652:     }
     653:     return ( p2map[ op ] ? p2map[ op ] : "unknown" );
     654:     }
     655:
     656:     /*
     657:      *	low level routines
     658:      */
     659:
     660:     /*
     661:      *	puts a long word on the pcstream
     662:      */
     663: p2word( word )
     664:     int     word;
     665:     {
     666:
     667:     putw( word , pcstream );
     668:     }
     669:
     670:     /*
     671:      *	put a length 0 mod 4 null padded string onto the pcstream
     672:      */
     673: p2string( string )
     674:     char    *string;
     675:     {
     676:     int slen = strlen( string );
     677:     int wlen = ( slen + 3 ) / 4;
     678:     int plen = ( wlen * 4 ) - slen;
     679:     char    *cp;
     680:     int p;
     681:
     682:     for ( cp = string ; *cp ; cp++ )
     683:         putc( *cp , pcstream );
     684:     for ( p = 1 ; p <= plen ; p++ )
     685:         putc( '\0' , pcstream );
     686: #	ifdef DEBUG
     687:         if ( opt( 'k' ) ) {
     688:         fprintf( stdout , "\"%s" , string );
     689:         for ( p = 1 ; p <= plen ; p++ )
     690:             fprintf( stdout , "\\0" );
     691:         fprintf( stdout , "\"\n" );
     692:         }
     693: #	endif
     694:     }
     695:
     696:     /*
     697:      *	puts a name on the pcstream
     698:      */
     699: p2name( name )
     700:     char    *name;
     701:     {
     702:     int pad;
     703:
     704:     fprintf( pcstream , NAMEFORMAT , name );
     705:     pad = strlen( name ) % sizeof (long);
     706:     for ( ; pad < sizeof (long) ; pad++ ) {
     707:         putc( '\0' , pcstream );
     708:     }
     709: #	ifdef DEBUG
     710:         if ( opt( 'k' ) ) {
     711:         fprintf( stdout , NAMEFORMAT , name );
     712:         pad = strlen( name ) % sizeof (long);
     713:         for ( ; pad < sizeof (long) ; pad++ ) {
     714:             fprintf( stdout , "\\0" );
     715:         }
     716:         fprintf( stdout , "\n" );
     717:         }
     718: #	endif
     719:     }
     720:
     721:     /*
     722:      *	put out a jump to a label
     723:      */
     724: putjbr( label )
     725:     long    label;
     726:     {
     727:
     728:     printjbr( LABELPREFIX , label );
     729:     }
     730:
     731:     /*
     732:      *	put out a jump to any kind of label
     733:      */
     734: printjbr( prefix , label )
     735:     char    *prefix;
     736:     long    label;
     737:     {
     738:
     739: #	ifdef vax
     740:         putprintf( "	jbr	" , 1 );
     741:         putprintf( PREFIXFORMAT , 0 , prefix , label );
     742: #	endif vax
     743: #	ifdef mc68000
     744:         putprintf( "	jra	" , 1 );
     745:         putprintf( PREFIXFORMAT , 0 , prefix , label );
     746: #	endif mc68000
     747:     }
     748:
     749:     /*
     750:      *	another version of put to catch calls to put
     751:      */
     752: /* VARARGS */
     753: put()
     754:     {
     755:
     756:     panic("put()");
     757:     }
     758:
     759: #endif PC

#### Defined functions

p2name defined in line 699; used 2 times

- in line 192, 206

p2opname defined in line 640; used 4 times

- in line 526, 534, 550, 560

p2string defined in line 673; used 2 times

- in line 42, 163

p2type defined in line 432; used 95 times

- in line 475, 485
- in /usr/src/ucb/PORT/pascal/src/call.c line 72, 140, 161, 178, 188, 310, 362, 394
- in /usr/src/ucb/PORT/pascal/src/conv.c line 304, 314-328(5)
- in /usr/src/ucb/PORT/pascal/src/fend.c line 256, 678, 916
- in /usr/src/ucb/PORT/pascal/src/flvalue.c line 67, 98
- in /usr/src/ucb/PORT/pascal/src/forop.c line 177, 207, 233
- in /usr/src/ucb/PORT/pascal/src/lval.c line 411, 474, 485, 492, 510
- in /usr/src/ucb/PORT/pascal/src/pccaseop.c line 117
- in /usr/src/ucb/PORT/pascal/src/pcfunc.c line 192, 203, 271, 315-320(2)
- in /usr/src/ucb/PORT/pascal/src/pclval.c line 113, 167, 196, 209, 247-250(2), 258
- in /usr/src/ucb/PORT/pascal/src/pcproc.c line 369, 376-377(2), 408-417(4), 780, 1011, 1020, 1029, 1037-1046(4), 1124-1125(2)
- in /usr/src/ucb/PORT/pascal/src/rval.c line 169-172(2), 209, 421, 443-445(2), 453-457(2), 478, 492-494(2), 651-655(2)
- in /usr/src/ucb/PORT/pascal/src/sconv.c line 35-36(2)
- in /usr/src/ucb/PORT/pascal/src/stab.c line 57, 73, 132
- in /usr/src/ucb/PORT/pascal/src/stat.c line 338, 485-499(8), 534-538(2), 546
- in /usr/src/ucb/PORT/pascal/src/stkrval.c line 99, 139-141(2), 235, 274, 315

p2word defined in line 663; used 15 times

- in line 36, 102-103(2), 121, 135, 157, 182-183(2), 195-197(2), 209, 530, 554-556(3)

printjbr defined in line 734; used 1 times

- in line 728

put defined in line 753; used 252 times

- in /usr/src/ucb/PORT/pascal/src/call.c line 93-95(2), 102, 296-300(3), 446-452(5)
- in /usr/src/ucb/PORT/pascal/src/case.c line 164-180(6), 222
- in /usr/src/ucb/PORT/pascal/src/conv.c line 35-42(3), 50, 190-204(5), 215-217(2)
- in /usr/src/ucb/PORT/pascal/src/cset.c line 427-432(2), 467-468(2)
- in /usr/src/ucb/PORT/pascal/src/fend.c line 105, 111-119(3), 204, 243-249(5), 418
- in /usr/src/ucb/PORT/pascal/src/fhdr.c line 236-238(3), 261
- in /usr/src/ucb/PORT/pascal/src/flvalue.c line 62, 87-89(2)
- in /usr/src/ucb/PORT/pascal/src/forop.c line 194, 221, 299-304(3), 312-313(2), 321-322(2), 422-424(3)
- in /usr/src/ucb/PORT/pascal/src/func.c line 91, 147, 159, 167-176(3), 208-217(3), 226, 233, 240, 247, 254
- in /usr/src/ucb/PORT/pascal/src/gen.c line 200-212(4), 218
- in /usr/src/ucb/PORT/pascal/src/lab.c line 97, 142
- in /usr/src/ucb/PORT/pascal/src/lval.c line 123, 179, 199-205(3), 212, 238-243(3), 313-318(3), 431, 448, 455-460(3), 542-551(3)
- in /usr/src/ucb/PORT/pascal/src/proc.c line 140, 154, 177, 201, 212-216(2), 333, 346-350(2), 391, 411-414(2), 434, 499, 521, 536, 554-576(9), 613-617(3), 623-628(4), 636-639(2), 659, 694, 702-706(2), 744-745(2), 751-760(4), 767-774(3), 784-786(2), 810, 829-830(2), 852, 870-879(4), 934, 950, 958, 982, 998-999(2), 1017-1020(2), 1043, 1057-1058(2), 1082, 1089, 1163-1166(4), 1172
- in /usr/src/ucb/PORT/pascal/src/rval.c line 107, 146-162(5), 192-204(5), 241, 259, 274, 284-287(2), 296, 305, 314, 364-369(4), 416, 440, 470, 952-954(2), 1010-1013(2), 1038, 1054
- in /usr/src/ucb/PORT/pascal/src/stat.c line 181, 196, 255, 275, 322, 465-474(3), 585, 604, 650, 660, 693
- in /usr/src/ucb/PORT/pascal/src/stkrval.c line 66, 121-133(5), 174, 192, 207, 214-226(5), 260-269(4), 311, 349, 358, 370, 386, 418-430(5)

putCON8 defined in line 340; used 4 times

- in /usr/src/ucb/PORT/pascal/src/rval.c line 277, 290, 1041
- in /usr/src/ucb/PORT/pascal/src/stkrval.c line 373

putCONG defined in line 368; used 5 times

- in /usr/src/ucb/PORT/pascal/src/fend.c line 257
- in /usr/src/ucb/PORT/pascal/src/pcproc.c line 642, 799
- in /usr/src/ucb/PORT/pascal/src/rval.c line 245
- in /usr/src/ucb/PORT/pascal/src/stkrval.c line 178

putLV defined in line 268; used 28 times

- in line 258
- in /usr/src/ucb/PORT/pascal/src/call.c line 470, 514, 530
- in /usr/src/ucb/PORT/pascal/src/fend.c line 255, 298, 627, 640, 704, 864, 877, 939
- in /usr/src/ucb/PORT/pascal/src/flvalue.c line 101
- in /usr/src/ucb/PORT/pascal/src/lab.c line 196-198(2), 205-207(2)
- in /usr/src/ucb/PORT/pascal/src/pclval.c line 166, 208, 246
- in /usr/src/ucb/PORT/pascal/src/pcproc.c line 194, 240, 249, 956, 965
- in /usr/src/ucb/PORT/pascal/src/rval.c line 171, 389, 602

putRV defined in line 225; used 79 times

- in /usr/src/ucb/PORT/pascal/src/call.c line 115-117(2), 150, 170, 308, 464, 512, 527
- in /usr/src/ucb/PORT/pascal/src/conv.c line 320-324(2)
- in /usr/src/ucb/PORT/pascal/src/fend.c line 689, 751-754(2), 927, 984-987(2)
- in /usr/src/ucb/PORT/pascal/src/flvalue.c line 65
- in /usr/src/ucb/PORT/pascal/src/forop.c line 190, 213, 240-242(2), 256, 265-273(3), 289, 370, 377-380(2), 393-396(2)
- in /usr/src/ucb/PORT/pascal/src/lval.c line 484, 491
- in /usr/src/ucb/PORT/pascal/src/pccaseop.c line 119, 213
- in /usr/src/ucb/PORT/pascal/src/pcfunc.c line 268-275(3)
- in /usr/src/ucb/PORT/pascal/src/pclval.c line 112, 249
- in /usr/src/ucb/PORT/pascal/src/pcproc.c line 192, 217, 238, 247, 430, 574, 588, 622-627(2), 638, 660, 669, 705, 817, 832-837(2), 856, 888, 898, 938, 954, 963, 1018, 1058, 1106, 1139, 1153, 1168, 1426, 1443, 1452
- in /usr/src/ucb/PORT/pascal/src/rval.c line 168
- in /usr/src/ucb/PORT/pascal/src/stat.c line 184, 218, 258, 337, 533-537(2), 545

putdot defined in line 148; used 79 times

- in /usr/src/ucb/PORT/pascal/src/call.c line 536
- in /usr/src/ucb/PORT/pascal/src/fend.c line 212, 268, 301, 632, 646, 668, 711-716(2), 757, 869, 883, 906, 946-951(2), 990
- in /usr/src/ucb/PORT/pascal/src/forop.c line 209, 235, 247, 259, 278, 292, 368-373(2), 385, 403
- in /usr/src/ucb/PORT/pascal/src/lab.c line 202, 210
- in /usr/src/ucb/PORT/pascal/src/pccaseop.c line 125, 216
- in /usr/src/ucb/PORT/pascal/src/pcproc.c line 148, 166, 191-196(2), 227, 243, 251, 413, 421, 433, 593, 807, 861, 904, 946, 959, 967, 1042, 1049, 1061, 1126, 1142, 1165-1170(2), 1218, 1284, 1292, 1312, 1324, 1354, 1372, 1392, 1419, 1438, 1457, 1494, 1582
- in /usr/src/ucb/PORT/pascal/src/stat.c line 187, 216-221(2), 279, 487-501(4), 550, 591, 655, 698

puteof defined in line 132; used 1 times

- in /usr/src/ucb/PORT/pascal/src/main.c line 385

putjbr defined in line 724; used 12 times

- in /usr/src/ucb/PORT/pascal/src/fend.c line 758, 991
- in /usr/src/ucb/PORT/pascal/src/forop.c line 407
- in /usr/src/ucb/PORT/pascal/src/pccaseop.c line 127, 205, 362, 388, 394-399(2), 439
- in /usr/src/ucb/PORT/pascal/src/stat.c line 608, 663

putlbracket defined in line 83; used 6 times

- in /usr/src/ucb/PORT/pascal/src/fend.c line 186
- in /usr/src/ucb/PORT/pascal/src/tmps.c line 110, 126, 140, 161, 204

putleaf defined in line 169; used 208 times

- in line 241, 252, 292, 300-328(9), 360, 405-407(2)
- in /usr/src/ucb/PORT/pascal/src/call.c line 161, 174, 314-318(3), 510
- in /usr/src/ucb/PORT/pascal/src/conv.c line 257-262(2), 306-310(2)
- in /usr/src/ucb/PORT/pascal/src/cset.c line 424, 440-442(2)
- in /usr/src/ucb/PORT/pascal/src/fend.c line 208-210(2), 252, 260-263(2), 293-296(3), 625-628(2), 638-644(3), 664-666(2), 703, 712, 750, 862-865(2), 875-881(3), 902-904(2), 938, 947, 983
- in /usr/src/ucb/PORT/pascal/src/flvalue.c line 92, 98-99(2)
- in /usr/src/ucb/PORT/pascal/src/forop.c line 245, 365, 371, 383, 399
- in /usr/src/ucb/PORT/pascal/src/lab.c line 189, 203
- in /usr/src/ucb/PORT/pascal/src/lval.c line 473, 496, 503
- in /usr/src/ucb/PORT/pascal/src/pccaseop.c line 212
- in /usr/src/ucb/PORT/pascal/src/pcfunc.c line 86, 105, 116-119(2), 189, 200, 212, 220, 231, 239, 247, 305-312(3), 318, 336, 346, 360-363(2), 372, 383
- in /usr/src/ucb/PORT/pascal/src/pclval.c line 171, 213, 254, 378-383(2)
- in /usr/src/ucb/PORT/pascal/src/pcproc.c line 146, 155, 189, 219, 366, 427, 571, 579, 585, 619-624(2), 632-635(2), 666, 675, 690-692(2), 702, 709-713(2), 720-722(2), 730-732(2), 746, 759-761(2), 786, 792, 814, 822, 835-840(2), 848-853(3), 885, 891-895(3), 940, 1007, 1055, 1103, 1111, 1136, 1154, 1166, 1183, 1209-1215(3), 1247, 1281-1289(3), 1302, 1320, 1333, 1351, 1362, 1380, 1389, 1400, 1427, 1440-1449(4), 1471, 1502, 1514, 1573-1579(4)
- in /usr/src/ucb/PORT/pascal/src/rval.c line 110, 262, 299, 308, 317, 381, 392-394(2), 588, 616, 737, 769, 918-922(2), 930, 959-961(2), 969-971(2), 1019-1027(3), 1057
- in /usr/src/ucb/PORT/pascal/src/stat.c line 185, 213, 219, 523, 541, 589, 653, 696
- in /usr/src/ucb/PORT/pascal/src/stkrval.c line 69, 195, 352, 361, 389

putop defined in line 522; used 275 times

- in line 259, 307, 318, 329
- in /usr/src/ucb/PORT/pascal/src/call.c line 119, 176, 187-192(2), 311-319(4), 432, 467-472(2), 488-491(2), 503, 509, 516-518(3), 533
- in /usr/src/ucb/PORT/pascal/src/conv.c line 308-313(3), 322-327(3)
- in /usr/src/ucb/PORT/pascal/src/cset.c line 441-453(5)
- in /usr/src/ucb/PORT/pascal/src/fend.c line 211, 259-267(4), 297-300(3), 630-631(2), 641-645(3), 667, 693, 713, 755-756(2), 867-868(2), 878-882(3), 905, 931, 948, 988-989(2)
- in /usr/src/ucb/PORT/pascal/src/flvalue.c line 100-104(3)
- in /usr/src/ucb/PORT/pascal/src/forop.c line 208, 234, 244-246(2), 277, 291, 367-372(2), 382-384(2), 400-402(2)
- in /usr/src/ucb/PORT/pascal/src/lab.c line 201, 208-209(2)
- in /usr/src/ucb/PORT/pascal/src/lval.c line 474, 486, 493-497(2), 504, 510
- in /usr/src/ucb/PORT/pascal/src/pccaseop.c line 123-124(2), 215
- in /usr/src/ucb/PORT/pascal/src/pcfunc.c line 108, 120, 193, 204, 213, 223, 235, 243, 250, 272-278(3), 311-319(4), 337, 349, 364-365(2), 375, 386
- in /usr/src/ucb/PORT/pascal/src/pclval.c line 173, 196-201(3), 215, 255-258(2)
- in /usr/src/ucb/PORT/pascal/src/pcproc.c line 147, 165, 190-195(2), 225-226(2), 242, 250, 375-377(2), 412, 432, 577, 590-592(3), 629-630(2), 640-645(2), 665, 691-701(5), 712-736(13), 760-765(4), 775, 782, 794-800(4), 806, 820, 836-842(3), 850-852(2), 858-860(3), 900-903(3), 944-945(2), 958, 966, 1020, 1028, 1041, 1060, 1113, 1120-1125(2), 1141, 1163-1169(3), 1212-1217(4), 1282-1283(2), 1290-1291(2), 1311, 1323, 1350-1353(3), 1371, 1390-1391(2), 1417-1418(2), 1436-1437(2), 1453-1456(3), 1491-1493(2), 1531, 1544, 1574-1581(5)
- in /usr/src/ucb/PORT/pascal/src/rval.c line 209, 393-397(3), 422-425(2), 444, 477, 510, 583, 606, 615-619(3), 671, 778-784(3), 804, 960-978(7)
- in /usr/src/ucb/PORT/pascal/src/sconv.c line 89, 119, 131, 143, 155
- in /usr/src/ucb/PORT/pascal/src/stat.c line 186, 215-220(2), 278, 486-495(3), 530, 539-549(5), 590, 654, 697
- in /usr/src/ucb/PORT/pascal/src/stkrval.c line 139

putprintf defined in line 60; used 282 times

- in line 349-358(4), 381, 387-402(8), 740-745(4)
- in /usr/src/ucb/PORT/pascal/src/cset.c line 410, 416-422(4)
- in /usr/src/ucb/PORT/pascal/src/fend.c line 432-437(5), 511-526(13), 537-545(5), 553-562(6), 581-594(9), 604, 611, 618, 651, 698-702(3), 725, 735-739(2), 747-749(3), 766-781(13), 789-796(7), 805-813(8), 831-837(6), 847, 854, 888-889(2), 936, 960, 977-982(5)
- in /usr/src/ucb/PORT/pascal/src/lab.c line 106, 163-166(2), 258
- in /usr/src/ucb/PORT/pascal/src/pccaseop.c line 277-283(5), 290, 301-304(3), 313-315(3), 324-326(3), 335-352(12), 392-398(4), 407-414(6), 431-436(4)
- in /usr/src/ucb/PORT/pascal/src/put.c line 443, 455, 463, 474, 503-512(5), 787-788(2)
- in /usr/src/ucb/PORT/pascal/src/stab.c line 53, 59-61(2), 75-77(2), 95-100(6), 118-123(6), 134-141(4), 158-163(6), 181, 194, 206-210(2), 218-229(6), 276-279(3), 291, 308, 318-328(9), 353, 363-368(6), 425, 437, 449-463(8), 472, 485-487(2), 508, 618-620(2), 637-641(2), 654-656(2), 670, 683, 702-704(2), 715, 723-727(2), 733, 740-742(2), 752-756(3), 762-765(2), 772, 786-790(2), 796, 849, 862-863(2)
- in /usr/src/ucb/PORT/pascal/src/var.c line 150-155(5), 383-387(2), 398

putrbracket defined in line 117; used 1 times

- in /usr/src/ucb/PORT/pascal/src/fend.c line 423

putstrop defined in line 544; used 8 times

- in /usr/src/ucb/PORT/pascal/src/call.c line 393, 495-498(2)
- in /usr/src/ucb/PORT/pascal/src/fend.c line 708, 943
- in /usr/src/ucb/PORT/pascal/src/pcproc.c line 416, 1045
- in /usr/src/ucb/PORT/pascal/src/stat.c line 499

puttext defined in line 29; used 1 times

- in line 74

str4len defined in line 45; used 2 times

- in line 32, 152

typerecur defined in line 439; used 4 times

- in line 437, 490-492(2), 498

#### Defined variables

p2opnames defined in line 574; used 1 times

- in line 649

sccsid defined in line 8; never used

#### Defined struct's

p2op defined in line 569; used 4 times

- in line 574(2), 646(2)

#### Defined macros

MAXQUALS defined in line 431; used 1 times

- in line 444

Last modified: 1985-06-22 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 2658 |