BSD 4_3 release
[unix-history] / usr / src / ucb / pascal / src / clas.c
index 17aba5c..9a0e937 100644 (file)
@@ -1,10 +1,16 @@
-/* Copyright (c) 1979 Regents of the University of California */
-
-static char sccsid[] = "@(#)clas.c 1.6 11/11/82";
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
 
 
+#ifndef lint
+static char sccsid[] = "@(#)clas.c     5.2 (Berkeley) 6/5/85";
+#endif not lint
 #include "whoami.h"
 #include "0.h"
 #include "tree.h"
 #include "whoami.h"
 #include "0.h"
 #include "tree.h"
+#include "tree_ty.h"
 
 /*
  * This is the array of class
 
 /*
  * This is the array of class
@@ -48,7 +54,7 @@ classify(p1)
 
        p = p1;
 swit:
 
        p = p1;
 swit:
-       if (p == NIL) {
+       if (p == NLNIL) {
                nocascade();
                return (NIL);
        }
                nocascade();
                return (NIL);
        }
@@ -68,6 +74,7 @@ swit:
                        return (TSTR);
                case SET:
                        return (TSET);
                        return (TSTR);
                case SET:
                        return (TSET);
+               case CRANGE:
                case RANGE:
                        p = p->type;
                        goto swit;
                case RANGE:
                        p = p->type;
                        goto swit;
@@ -82,7 +89,10 @@ swit:
                case SCAL:
                        return (TSCAL);
                default:
                case SCAL:
                        return (TSCAL);
                default:
-                       panic("clas");
+                       {
+                           panic("clas");
+                           return(NIL);
+                       }
        }
 }
 
        }
 }
 
@@ -104,19 +114,20 @@ text(p)
  * its argument if its argument
  * is a SCALar else NIL.
  */
  * its argument if its argument
  * is a SCALar else NIL.
  */
+struct nl *
 scalar(p1)
        struct nl *p1;
 {
        register struct nl *p;
 
        p = p1;
 scalar(p1)
        struct nl *p1;
 {
        register struct nl *p;
 
        p = p1;
-       if (p == NIL)
-               return (NIL);
-       if (p->class == RANGE)
+       if (p == NLNIL)
+               return (NLNIL);
+       if (p->class == RANGE || p->class == CRANGE)
                p = p->type;
                p = p->type;
-       if (p == NIL)
-               return (NIL);
-       return (p->class == SCAL ? p : NIL);
+       if (p == NLNIL)
+               return (NLNIL);
+       return (p->class == SCAL ? p : NLNIL);
 }
 
 /*
 }
 
 /*
@@ -141,8 +152,9 @@ isa(p, s)
         * map ranges down to
         * the base type
         */
         * map ranges down to
         * the base type
         */
-       if (p->class == RANGE)
+       if (p->class == RANGE) {
                p = p->type;
                p = p->type;
+       }
        /*
         * the following character/class
         * associations are made:
        /*
         * the following character/class
         * associations are made:
@@ -161,6 +173,19 @@ isa(p, s)
                case SCAL:
                        i = 0;
                        break;
                case SCAL:
                        i = 0;
                        break;
+               case CRANGE:
+                       /*
+                        * find the base type of a conformant array range
+                        */
+                       switch (classify(p->type)) {
+                               case TBOOL: i = 1; break;
+                               case TCHAR: i = 2; break;
+                               case TINT: i = 3; break;
+                               case TSCAL: i = 0; break;
+                               default:
+                                       panic( "isa" );
+                       }
+                       break;
                default:
                        i = p - nl;
        }
                default:
                        i = p - nl;
        }
@@ -178,6 +203,8 @@ isa(p, s)
  * Isnta is !isa
  */
 isnta(p, s)
  * Isnta is !isa
  */
 isnta(p, s)
+    struct nl *p;
+    char *s;
 {
 
        return (!isa(p, s));
 {
 
        return (!isa(p, s));
@@ -186,18 +213,22 @@ isnta(p, s)
 /*
  * "shorthand"
  */
 /*
  * "shorthand"
  */
+char *
 nameof(p)
 nameof(p)
+struct nl *p;
 {
 
        return (clnames[classify(p)]);
 }
 
 #ifndef PI0
 {
 
        return (clnames[classify(p)]);
 }
 
 #ifndef PI0
-nowexp(r)
-       int *r;
+/* find out for sure what kind of node this is being passed
+   possibly several different kinds of node are passed to it */
+int nowexp(r)
+       struct tnode *r;
 {
 {
-       if (r[0] == T_WEXP) {
-               if (r[2] == NIL)
+       if (r->tag == T_WEXP) {
+               if (r->var_node.cptr == NIL)
                        error("Oct/hex allowed only on writeln/write calls");
                else
                        error("Width expressions allowed only in writeln/write calls");
                        error("Oct/hex allowed only on writeln/write calls");
                else
                        error("Width expressions allowed only in writeln/write calls");
@@ -214,8 +245,8 @@ nowexp(r)
      *     positives are parameters
      *     negative evens are locals
      */
      *     positives are parameters
      *     negative evens are locals
      */
-whereis( level , offset , other_flags )
-    int                level;
+/*ARGSUSED*/
+whereis( offset , other_flags )
     int                offset;
     char       other_flags;
 {
     int                offset;
     char       other_flags;
 {
@@ -225,6 +256,8 @@ whereis( level , offset , other_flags )
 #   endif OBJ
 #   ifdef PC
        switch ( other_flags & ( NGLOBAL | NPARAM | NLOCAL | NNLOCAL) ) {
 #   endif OBJ
 #   ifdef PC
        switch ( other_flags & ( NGLOBAL | NPARAM | NLOCAL | NNLOCAL) ) {
+           default:
+               panic( "whereis" );
            case NGLOBAL:
                return GLOBALVAR;
            case NPARAM:
            case NGLOBAL:
                return GLOBALVAR;
            case NPARAM:
@@ -233,8 +266,6 @@ whereis( level , offset , other_flags )
                return NAMEDLOCALVAR;
            case NLOCAL:
                return LOCALVAR;
                return NAMEDLOCALVAR;
            case NLOCAL:
                return LOCALVAR;
-           default:
-               panic( "whereis" );
        }
 #   endif PC
 }
        }
 #   endif PC
 }