BSD 4 release
[unix-history] / usr / src / cmd / pi / func.c
index 3fffbda..c99b600 100644 (file)
@@ -1,13 +1,12 @@
 /* Copyright (c) 1979 Regents of the University of California */
 /* Copyright (c) 1979 Regents of the University of California */
-#
-/*
- * pi - Pascal interpreter code translator
- *
- * Charles Haley, Bill Joy UCB
- * Version 1.2 November 1978
- */
 
 
-#include "whoami"
+static char sccsid[] = "@(#)func.c 1.3 10/19/80";
+
+#include "whoami.h"
+#ifdef OBJ
+    /*
+     * the rest of the file
+     */
 #include "0.h"
 #include "tree.h"
 #include "opcode.h"
 #include "0.h"
 #include "tree.h"
 #include "opcode.h"
@@ -38,7 +37,7 @@ funccod(r)
                rvlist(r[3]);
                return (NIL);
        }
                rvlist(r[3]);
                return (NIL);
        }
-       if (p->class != FUNC) {
+       if (p->class != FUNC && p->class != FFUNC) {
                error("%s is not a function", p->symbol);
                rvlist(r[3]);
                return (NIL);
                error("%s is not a function", p->symbol);
                rvlist(r[3]);
                return (NIL);
@@ -108,7 +107,7 @@ funccod(r)
        /*
         * Evaluate the argmument
         */
        /*
         * Evaluate the argmument
         */
-       p1 = rvalue((int *) argv[1], NLNIL);
+       p1 = stkrval((int *) argv[1], NLNIL , RREQ );
        if (p1 == NIL)
                return (NIL);
        switch (op) {
        if (p1 == NIL)
                return (NIL);
        switch (op) {
@@ -139,7 +138,6 @@ funccod(r)
                                error("seed's argument must be an integer, not %s", nameof(p1));
                                return (NIL);
                        }
                                error("seed's argument must be an integer, not %s", nameof(p1));
                                return (NIL);
                        }
-                       convert(p1, nl+T4INT);
                        put1(op);
                        return (nl+T4INT);
                case O_ROUND:
                        put1(op);
                        return (nl+T4INT);
                case O_ROUND:
@@ -163,15 +161,9 @@ funccod(r)
                        error("%s's argument must be an integer or real, not %s", p->symbol, nameof(p1));
                        return (NIL);
                case O_ORD2:
                        error("%s's argument must be an integer or real, not %s", p->symbol, nameof(p1));
                        return (NIL);
                case O_ORD2:
-                       if (isa(p1, "bcis") || classify(p1) == TPTR)
-                               switch (width(p1)) {
-                                       case 1:
-                                               return (nl+T1INT);
-                                       case 2:
-                                               return (nl+T2INT);
-                                       case 4:
-                                               return (nl+T4INT);
-                               }
+                       if (isa(p1, "bcis") || classify(p1) == TPTR) {
+                               return (nl+T4INT);
+                       }
                        error("ord's argument must be of scalar type or a pointer, not %s", nameof(p1));
                        return (NIL);
                case O_SUCC2:
                        error("ord's argument must be of scalar type or a pointer, not %s", nameof(p1));
                        return (NIL);
                case O_SUCC2:
@@ -210,8 +202,8 @@ funccod(r)
                        return (nl+TCHAR);
                case O_CARD:
                        if (isnta(p1, "t")) {
                        return (nl+TCHAR);
                case O_CARD:
                        if (isnta(p1, "t")) {
-                               error("Argument to card must be a set, not %s", nameof(p1));
-                               return (NIL);
+                           error("Argument to card must be a set, not %s", nameof(p1));
+                           return (NIL);
                        }
                        put2(O_CARD, width(p1));
                        return (nl+T2INT);
                        }
                        put2(O_CARD, width(p1));
                        return (nl+T2INT);
@@ -235,3 +227,4 @@ funccod(r)
                        panic("func1");
        }
 }
                        panic("func1");
        }
 }
+#endif OBJ