SCCS-vsn: usr.bin/pascal/src/rval.c 1.3
SCCS-vsn: usr.bin/pascal/src/p2put.c 1.3
/* Copyright (c) 1979 Regents of the University of California */
/* Copyright (c) 1979 Regents of the University of California */
-static char sccsid[] = "@(#)p2put.c 1.2 %G%";
+static char sccsid[] = "@(#)p2put.c 1.3 %G%";
/*
* functions to help pi put out
/*
* functions to help pi put out
* is stored as
* <ptr><ftn><int>
* so, we build types recursively
* is stored as
* <ptr><ftn><int>
* so, we build types recursively
+ * also, we know that /lib/f1 can only deal with 6 qualifications
+ * so we stop the recursion there. this stops infinite type recursion
+ * through mutually recursive pointer types.
+{
+
+ return typerecur( np , 0 );
+}
+typerecur( np , quals )
+ struct nl *np;
+ int quals;
- if ( np == NIL )
- return P2UNDEFINED;
+ if ( np == NIL || quals > MAXQUALS ) {
+ return P2UNDEF;
+ }
switch ( np -> class ) {
case SCAL :
case RANGE :
switch ( np -> class ) {
case SCAL :
case RANGE :
}
case STR :
return ( P2ARY | P2CHAR );
}
case STR :
return ( P2ARY | P2CHAR );
- /*
- return P2STRTY;
- */
case RECORD :
case SET :
return P2STRTY;
case RECORD :
case SET :
return P2STRTY;
case TYPE :
switch ( nloff( np ) ) {
case TNIL :
case TYPE :
switch ( nloff( np ) ) {
case TNIL :
- return ( P2PTR | P2UNDEFINED );
+ return ( P2PTR | P2UNDEF );
case TSTR :
return ( P2ARY | P2CHAR );
case TSTR :
return ( P2ARY | P2CHAR );
- /*
- return P2STRTY;
- */
case TSET :
return P2STRTY;
default :
case TSET :
return P2STRTY;
default :
case REF:
case WITHPTR:
case PTR :
case REF:
case WITHPTR:
case PTR :
- return ADDTYPE( p2type( np -> type ) , P2PTR );
+ return ADDTYPE( typerecur( np -> type , quals + 1 ) , P2PTR );
- return ADDTYPE( p2type( np -> type ) , P2ARY );
- /*
- return P2STRTY;
- */
+ return ADDTYPE( typerecur( np -> type , quals + 1 ) , P2ARY );
case FUNC :
/*
* functions are really pointers to functions
* which return their underlying type.
*/
case FUNC :
/*
* functions are really pointers to functions
* which return their underlying type.
*/
- return ADDTYPE( ADDTYPE( p2type( np -> type ) , P2FTN )
- , P2PTR );
+ return ADDTYPE( ADDTYPE( typerecur( np -> type , quals + 2 ) ,
+ P2FTN ) , P2PTR );
case PROC :
/*
* procedures are pointers to functions
case PROC :
/*
* procedures are pointers to functions
*/
return ADDTYPE( P2PTR , P2STRTY );
default :
*/
return ADDTYPE( P2PTR , P2STRTY );
default :
- fprintf( stderr , "[p2type] np -> class %d\n" , np -> class );
/* Copyright (c) 1979 Regents of the University of California */
/* Copyright (c) 1979 Regents of the University of California */
-static char sccsid[] = "@(#)rval.c 1.2 %G%";
+static char sccsid[] = "@(#)rval.c 1.3 %G%";
#include "whoami.h"
#include "0.h"
#include "whoami.h"
#include "0.h"
put(2, O_CON2, 0);
# endif OBJ
# ifdef PC
put(2, O_CON2, 0);
# endif OBJ
# ifdef PC
- putleaf( P2ICON , 0 , 0 , P2PTR|P2UNDEFINED , 0 );
+ putleaf( P2ICON , 0 , 0 , P2PTR|P2UNDEF , 0 );
# endif PC
return (nl+TNIL);
# endif PC
return (nl+TNIL);