put in explicit scalar converts (sconv's) to make less code-generator dependent.
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Tue, 18 Jan 1983 05:58:23 +0000 (21:58 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Tue, 18 Jan 1983 05:58:23 +0000 (21:58 -0800)
SCCS-vsn: usr.bin/pascal/pc0/Makefile 1.37
SCCS-vsn: usr.bin/pascal/src/stkrval.c 1.5
SCCS-vsn: usr.bin/pascal/src/lval.c 1.9
SCCS-vsn: usr.bin/pascal/src/stat.c 1.9
SCCS-vsn: usr.bin/pascal/src/forop.c 1.12
SCCS-vsn: usr.bin/pascal/src/rval.c 1.14
SCCS-vsn: usr.bin/pascal/src/call.c 1.20

usr/src/usr.bin/pascal/pc0/Makefile
usr/src/usr.bin/pascal/src/call.c
usr/src/usr.bin/pascal/src/forop.c
usr/src/usr.bin/pascal/src/lval.c
usr/src/usr.bin/pascal/src/rval.c
usr/src/usr.bin/pascal/src/stat.c
usr/src/usr.bin/pascal/src/stkrval.c

index e12da03..a0f83dc 100644 (file)
@@ -1,4 +1,4 @@
-SCCSID = "@(#)Makefile 1.36 %G%"
+SCCSID = "@(#)Makefile 1.37 %G%"
 
 INSTALLDIR = $(DESTDIR)/usr/lib
 INSTALLNAME = ${INSTALLDIR}/pc0
 
 INSTALLDIR = $(DESTDIR)/usr/lib
 INSTALLNAME = ${INSTALLDIR}/pc0
index 21df4a5..34c80d7 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.19 %G%";
+static char sccsid[] = "@(#)call.c 1.20 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -226,22 +226,22 @@ call(p, argv, porf, psbn)
                                case TREC:
                                case TSET:
                                case TSTR:
                                case TREC:
                                case TSET:
                                case TSTR:
-                                   q = rvalue( argv[1] , p1 -> type , LREQ );
+                                   q = stkrval( argv[1] , p1 -> type , LREQ );
                                    break;
                                case TINT:
                                case TSCAL:
                                case TBOOL:
                                case TCHAR:
                                    precheck( p1 -> type , "_RANG4" , "_RSNG4" );
                                    break;
                                case TINT:
                                case TSCAL:
                                case TBOOL:
                                case TCHAR:
                                    precheck( p1 -> type , "_RANG4" , "_RSNG4" );
-                                   q = rvalue( argv[1] , p1 -> type , RREQ );
-                                   postcheck( p1 -> type );
+                                   q = stkrval( argv[1] , p1 -> type , RREQ );
+                                   postcheck(p1 -> type, P2INT);
+                                   break;
+                               case TDOUBLE:
+                                   q = stkrval( argv[1] , p1 -> type , RREQ );
+                                   sconv(p2type(q), P2DOUBLE);
                                    break;
                                default:
                                    q = rvalue( argv[1] , p1 -> type , RREQ );
                                    break;
                                default:
                                    q = rvalue( argv[1] , p1 -> type , RREQ );
-                                   if (  isa( p1 -> type  , "d" )
-                                      && isa( q , "i" ) ) {
-                                       putop( P2SCONV , P2DOUBLE );
-                                   }
                                    break;
                            }
 #                      endif PC
                                    break;
                            }
 #                      endif PC
index a3d2a30..09c15d4 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[] = "@(#)forop.c 1.11 %G%";
+static char sccsid[] = "@(#)forop.c 1.12 %G%";
 
 #include       "whoami.h"
 #include       "0.h"
 
 #include       "whoami.h"
 #include       "0.h"
@@ -148,6 +148,7 @@ nogood:
            goto byebye;
        }
 #      ifdef PC
            goto byebye;
        }
 #      ifdef PC
+           sconv(p2type(inittype), P2INT);
            putop( P2ASSIGN , P2INT );
            putdot( filename , line );
                /*
            putop( P2ASSIGN , P2INT );
            putdot( filename , line );
                /*
@@ -173,6 +174,7 @@ nogood:
            goto byebye;
        }
 #      ifdef PC
            goto byebye;
        }
 #      ifdef PC
+           sconv(p2type(termtype), P2INT);
            putop( P2ASSIGN , P2INT );
            putdot( filename , line );
                /*
            putop( P2ASSIGN , P2INT );
            putdot( filename , line );
                /*
@@ -204,8 +206,9 @@ nogood:
            putRV( 0 , cbn , initnlp -> value[ NL_OFFS ] ,
                    initnlp -> extra_flags , P2INT );
            if ( opt( 't' ) ) {
            putRV( 0 , cbn , initnlp -> value[ NL_OFFS ] ,
                    initnlp -> extra_flags , P2INT );
            if ( opt( 't' ) ) {
-               postcheck( fortype );
+               postcheck(fortype, nl+T4INT);
            }
            }
+           sconv(P2INT, p2type(fortype));
            putop( P2ASSIGN , p2type( fortype ) );
            putdot( filename , line );
 #      endif PC
            putop( P2ASSIGN , p2type( fortype ) );
            putdot( filename , line );
 #      endif PC
@@ -299,7 +302,7 @@ nogood:
            putleaf( P2ICON , 1 , 0 , P2INT , 0 );
            putop( ( arg[0] == T_FORU ? P2PLUS : P2MINUS ) , P2INT );
            if ( opt( 't' ) ) {
            putleaf( P2ICON , 1 , 0 , P2INT , 0 );
            putop( ( arg[0] == T_FORU ? P2PLUS : P2MINUS ) , P2INT );
            if ( opt( 't' ) ) {
-               postcheck( fortype );
+               postcheck(fortype, nl+T4INT);
            }
            putop( P2ASSIGN , P2INT );
            putdot( filename , line );
            }
            putop( P2ASSIGN , P2INT );
            putdot( filename , line );
index b9ca17b..5611a92 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[] = "@(#)lval.c 1.8 %G%";
+static char sccsid[] = "@(#)lval.c 1.9 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -345,7 +345,8 @@ arycod(np, el)
                            return (0);
                    }
 #                  ifdef PC
                            return (0);
                    }
 #                  ifdef PC
-                       postcheck( p );
+                       postcheck(p, ap);
+                       sconv(p2type(ap),P2INT);
 #                  endif PC
                }
                if (incompat(ap, p->type, el[1])) {
 #                  endif PC
                }
                if (incompat(ap, p->type, el[1])) {
index 6a85a8f..11ce35c 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[] = "@(#)rval.c 1.13 %G%";
+static char sccsid[] = "@(#)rval.c 1.14 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -289,11 +289,8 @@ cstrng:
                                        put(2, O_CON2, (short)p->range[0]);
 #                                  endif OBJ
 #                                  ifdef PC
                                        put(2, O_CON2, (short)p->range[0]);
 #                                  endif OBJ
 #                                  ifdef PC
-                                           /*
-                                            * make short constants ints
-                                            */
                                        putleaf( P2ICON , (short) p -> range[0]
                                        putleaf( P2ICON , (short) p -> range[0]
-                                               , 0 , P2INT , 0 );
+                                               , 0 , P2SHORT , 0 );
 #                                  endif PC
                                    break;
                            case 1:
 #                                  endif PC
                                    break;
                            case 1:
@@ -301,11 +298,8 @@ cstrng:
                                        put(2, O_CON1, p->value[0]);
 #                                  endif OBJ
 #                                  ifdef PC
                                        put(2, O_CON1, p->value[0]);
 #                                  endif OBJ
 #                                  ifdef PC
-                                           /*
-                                            * make char constants ints
-                                            */
                                        putleaf( P2ICON , p -> value[0] , 0
                                        putleaf( P2ICON , p -> value[0] , 0
-                                               , P2INT , 0 );
+                                               , P2CHAR , 0 );
 #                                  endif PC
                                    break;
                            default:
 #                                  endif PC
                                    break;
                            default:
@@ -406,7 +400,8 @@ cstrng:
                        put(1, O_NEG2 + (width(q) >> 2));
 #                  endif OBJ
 #                  ifdef PC
                        put(1, O_NEG2 + (width(q) >> 2));
 #                  endif OBJ
 #                  ifdef PC
-                       putop( P2UNARY P2MINUS , p2type( q ) );
+                       sconv(p2type(q), P2INT);
+                       putop( P2UNARY P2MINUS , P2INT );
 #                  endif PC
                    return (isa(q, "d") ? q : nl+T4INT);
                }
 #                  endif PC
                    return (isa(q, "d") ? q : nl+T4INT);
                }
@@ -424,14 +419,22 @@ cstrng:
                    put(1, O_NOT);
 #              endif OBJ
 #              ifdef PC
                    put(1, O_NOT);
 #              endif OBJ
 #              ifdef PC
-                   putop( P2NOT , P2INT );
+                   sconv(p2type(q), P2INT);
+                   putop( P2NOT , P2INT);
+                   sconv(P2INT, p2type(q));
 #              endif PC
                return (nl+T1BOOL);
 
        case T_AND:
        case T_OR:
                p = rvalue(r[2], NIL , RREQ );
 #              endif PC
                return (nl+T1BOOL);
 
        case T_AND:
        case T_OR:
                p = rvalue(r[2], NIL , RREQ );
+#              ifdef PC
+                   sconv(p2type(p),P2INT);
+#              endif PC
                p1 = rvalue(r[3], NIL , RREQ );
                p1 = rvalue(r[3], NIL , RREQ );
+#              ifdef PC
+                   sconv(p2type(p1),P2INT);
+#              endif PC
                if (p == NIL || p1 == NIL)
                        return (NIL);
                if (isnta(p, "b")) {
                if (p == NIL || p1 == NIL)
                        return (NIL);
                if (isnta(p, "b")) {
@@ -451,6 +454,7 @@ cstrng:
                         * to force evaluation of all the expressions.
                         */
                    putop( r[ 0 ] == T_AND ? P2AND : P2OR , P2INT );
                         * to force evaluation of all the expressions.
                         */
                    putop( r[ 0 ] == T_AND ? P2AND : P2OR , P2INT );
+                   sconv(P2INT, p2type(p));
 #              endif PC
                return (nl+T1BOOL);
 
 #              endif PC
                return (nl+T1BOOL);
 
@@ -464,13 +468,9 @@ cstrng:
                         *      force these to be doubles for the divide
                         */
                    p = rvalue( r[ 2 ] , NIL , RREQ );
                         *      force these to be doubles for the divide
                         */
                    p = rvalue( r[ 2 ] , NIL , RREQ );
-                   if ( isnta( p , "d" ) ) {
-                       putop( P2SCONV , P2DOUBLE );
-                   }
+                   sconv(p2type(p), P2DOUBLE);
                    p1 = rvalue( r[ 3 ] , NIL , RREQ );
                    p1 = rvalue( r[ 3 ] , NIL , RREQ );
-                   if ( isnta( p1 , "d" ) ) {
-                       putop( P2SCONV , P2DOUBLE );
-                   }
+                   sconv(p2type(p1), P2DOUBLE);
 #              endif PC
                if (p == NIL || p1 == NIL)
                        return (NIL);
 #              endif PC
                if (p == NIL || p1 == NIL)
                        return (NIL);
@@ -544,21 +544,10 @@ cstrng:
                        if ( ( p == NIL ) || ( p1 == NIL ) ) {
                            return NIL;
                        }
                        if ( ( p == NIL ) || ( p1 == NIL ) ) {
                            return NIL;
                        }
-                       if ( isa( p , "i" ) && isa( p1 , "d" ) ) {
-                           putop( P2SCONV , P2DOUBLE );
-                       }
+                       tuac(p, p1, &rettype, &ctype);
                        p1 = rvalue( r[ 3 ] , contype , RREQ );
                        p1 = rvalue( r[ 3 ] , contype , RREQ );
-                       if ( isa( p , "d" ) && isa( p1 , "i" ) ) {
-                           putop( P2SCONV , P2DOUBLE );
-                       }
+                       tuac(p1, p, &rettype, &ctype);
                        if ( isa( p , "id" ) ) {
                        if ( isa( p , "id" ) ) {
-                           if ( isa( p , "d" ) || isa( p1 , "d" ) ) {
-                               ctype = P2DOUBLE;
-                               rettype = nl + TDOUBLE;
-                           } else {
-                               ctype = P2INT;
-                               rettype = nl + T4INT;
-                           }
                            putop( mathop[ r[0] - T_MULT ] , ctype );
                            return rettype;
                        }
                            putop( mathop[ r[0] - T_MULT ] , ctype );
                            return rettype;
                        }
@@ -631,7 +620,13 @@ cstrng:
        case T_MOD:
        case T_DIV:
                p = rvalue(r[2], NIL , RREQ );
        case T_MOD:
        case T_DIV:
                p = rvalue(r[2], NIL , RREQ );
+#              ifdef PC
+                   sconv(p2type(p), P2INT);
+#              endif PC
                p1 = rvalue(r[3], NIL , RREQ );
                p1 = rvalue(r[3], NIL , RREQ );
+#              ifdef PC
+                   sconv(p2type(p1), P2INT);
+#              endif PC
                if (p == NIL || p1 == NIL)
                        return (NIL);
                if (isnta(p, "i")) {
                if (p == NIL || p1 == NIL)
                        return (NIL);
                if (isnta(p, "i")) {
@@ -775,16 +770,14 @@ cstrng:
                             *  long op double  or  double op long
                             * we may have to do some coercing.
                             */
                             *  long op double  or  double op long
                             * we may have to do some coercing.
                             */
-                       if ( isa( p , "i" ) && isa( p1 , "d" ) ) {
-                           putop( P2SCONV , P2DOUBLE );
-                       }
+                       tuac(p, p1, &rettype, &ctype);
                        p1 = rvalue( r[ 3 ] , p , RREQ );
                        if ( p1 == NIL ) {
                            return NIL;
                        }
                        p1 = rvalue( r[ 3 ] , p , RREQ );
                        if ( p1 == NIL ) {
                            return NIL;
                        }
-                       if ( isa( p , "d" ) && isa( p1 , "i" ) )
-                           putop( P2SCONV , P2DOUBLE );
+                       tuac(p1, p, &rettype, &ctype);
                        putop( relops[ r[0] - T_EQ ] , P2INT );
                        putop( relops[ r[0] - T_EQ ] , P2INT );
+                       sconv(P2INT, P2CHAR);
                    }
 #              endif PC
                c = classify(p);
                    }
 #              endif PC
                c = classify(p);
@@ -948,6 +941,7 @@ nonident:
                        postcset( r[3] , &csetd );
                    }
                    putop( P2CALL , P2INT );
                        postcset( r[3] , &csetd );
                    }
                    putop( P2CALL , P2INT );
+                   sconv(P2INT, P2CHAR);
 #              endif PC
                return (nl+T1BOOL);
        default:
 #              endif PC
                return (nl+T1BOOL);
        default:
@@ -976,25 +970,27 @@ conint:
                                return (NIL);
                        }
                        l = f;
                                return (NIL);
                        }
                        l = f;
-                       if (bytes(l, l) <= 2) {
-#                              ifdef OBJ
-                                   put(2, O_CON2, ( short ) l);
-#                              endif OBJ
-#                              ifdef PC
-                                       /*
-                                        * short constants are ints
-                                        */
-                                   putleaf( P2ICON , l , 0 , P2INT , 0 );
-#                              endif PC
-                               return (nl+T2INT);
-                       }
 #                      ifdef OBJ
 #                      ifdef OBJ
+                           if (bytes(l, l) <= 2) {
+                                   put(2, O_CON2, ( short ) l);
+                                   return (nl+T2INT);
+                           }
                            put(2, O_CON4, l); 
                            put(2, O_CON4, l); 
+                           return (nl+T4INT);
 #                      endif OBJ
 #                      ifdef PC
 #                      endif OBJ
 #                      ifdef PC
-                           putleaf( P2ICON , l , 0 , P2INT , 0 );
+                           switch (bytes(l, l)) {
+                               case 1:
+                                   putleaf(P2ICON, l, 0, P2CHAR, 0);
+                                   return nl+T1INT;
+                               case 2:
+                                   putleaf(P2ICON, l, 0, P2SHORT, 0);
+                                   return nl+T2INT;
+                               case 4:
+                                   putleaf(P2ICON, l, 0, P2INT, 0);
+                                   return nl+T4INT;
+                           }
 #                      endif PC
 #                      endif PC
-                       return (nl+T4INT);
        
                /*
                 * A floating point number
        
                /*
                 * A floating point number
index f9612c4..e5e68b7 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[] = "@(#)stat.c 1.8 %G%";
+static char sccsid[] = "@(#)stat.c 1.9 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -432,7 +432,8 @@ asgnop1(r, p)
                    case TBOOL:
                    case TCHAR:
                    case TSCAL:
                    case TBOOL:
                    case TCHAR:
                    case TSCAL:
-                           postcheck( p );
+                           postcheck(p, p1);
+                           sconv(p2type(p1), p2type(p));
                            putop( P2ASSIGN , p2type( p ) );
                            putdot( filename , line );
                            break;
                            putop( P2ASSIGN , p2type( p ) );
                            putdot( filename , line );
                            break;
@@ -441,9 +442,7 @@ asgnop1(r, p)
                            putdot( filename , line );
                            break;
                    case TDOUBLE:
                            putdot( filename , line );
                            break;
                    case TDOUBLE:
-                           if (isnta(p1,"d")) {
-                               putop( P2SCONV , P2DOUBLE );
-                           }
+                           sconv(p2type(p1), p2type(p));
                            putop( P2ASSIGN , p2type( p ) );
                            putdot( filename , line );
                            break;
                            putop( P2ASSIGN , p2type( p ) );
                            putdot( filename , line );
                            break;
index f25f1c2..13fb8cd 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[] = "@(#)stkrval.c 1.4 %G%";
+static char sccsid[] = "@(#)stkrval.c 1.5 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -105,7 +105,11 @@ stkrval(r, contype , required )
                             }
 #                      endif OBJ
 #                      ifdef PC
                             }
 #                      endif OBJ
 #                      ifdef PC
-                            return rvalue( r , contype , required );
+                           q = rvalue( r , contype , required );
+                           if (isa(q, "sbci")) {
+                               sconv(p2type(q),P2INT);
+                           }
+                           return q;
 #                      endif PC
 
                case WITHPTR:
 #                      endif PC
 
                case WITHPTR:
@@ -144,6 +148,9 @@ ind:
 #                      ifdef PC
                            if ( required == RREQ ) {
                                putop( P2UNARY P2MUL , p2type( q ) );
 #                      ifdef PC
                            if ( required == RREQ ) {
                                putop( P2UNARY P2MUL , p2type( q ) );
+                               if (isa(q,"sbci")) {
+                                   sconv(p2type(q),P2INT);
+                               }
                            }
                            return q;
 #                      endif PC
                            }
                            return q;
 #                      endif PC
@@ -196,7 +203,7 @@ cstrng:
                                put(2, O_CONC4, (int)p->value[0]);
 #                          endif OBJ
 #                          ifdef PC
                                put(2, O_CONC4, (int)p->value[0]);
 #                          endif OBJ
 #                          ifdef PC
-                               putleaf( P2ICON , p -> value[0] , 0 , P2CHAR , 0 );
+                               putleaf(P2ICON, p -> value[0], 0, P2INT, 0);
 #                          endif PC
                            return(q);
                        }
 #                          endif PC
                            return(q);
                        }
@@ -233,7 +240,11 @@ cstrng:
                            }
 #                      endif OBJ
 #                      ifdef PC
                            }
 #                      endif OBJ
 #                      ifdef PC
-                           return rvalue( r , contype , required );
+                           q = rvalue( r , contype , required );
+                           if (isa(q,"sbci")) {
+                               sconv(p2type(q),P2INT);
+                           }
+                           return q;
 #                      endif PC
 
                case FUNC:
 #                      endif PC
 
                case FUNC:
@@ -269,6 +280,9 @@ cstrng:
 #                      endif OBJ
 #                      ifdef PC
                            p = pcfunccod( r );
 #                      endif OBJ
 #                      ifdef PC
                            p = pcfunccod( r );
+                           if (isa(p,"sbci")) {
+                               sconv(p2type(p),P2INT);
+                           }
 #                      endif PC
                        return (p);
 
 #                      endif PC
                        return (p);
 
@@ -306,6 +320,11 @@ cstrng:
                    if (width(p) <= 2)
                            put(1, O_STOI);
 #              endif OBJ
                    if (width(p) <= 2)
                            put(1, O_STOI);
 #              endif OBJ
+#              ifdef PC
+                   if (isa(p,"sbci")) {
+                       sconv(p2type(p),P2INT);
+                   }
+#              endif PC
                return (p);
        case T_CSET:
                p = rvalue(r, contype , required );
                return (p);
        case T_CSET:
                p = rvalue(r, contype , required );
@@ -376,7 +395,7 @@ conint:
                                    put(2, O_CONC4, cp[0]);
 #                              endif OBJ
 #                              ifdef PC
                                    put(2, O_CONC4, cp[0]);
 #                              endif OBJ
 #                              ifdef PC
-                                   putleaf( P2ICON , cp[0] , 0 , P2CHAR , 0 );
+                                   putleaf( P2ICON , cp[0] , 0 , P2INT , 0 );
 #                              endif PC
                                return(nl+T1CHAR);
                        }
 #                              endif PC
                                return(nl+T1CHAR);
                        }