[project @ 1999-11-23 18:08:17 by sewardj]
authorsewardj <unknown>
Tue, 23 Nov 1999 18:08:21 +0000 (18:08 +0000)
committersewardj <unknown>
Tue, 23 Nov 1999 18:08:21 +0000 (18:08 +0000)
Bind namePmFromInteger, namePmSubtract, namePmLe to stuff in Prelude
so that n+k patterns work.

ghc/interpreter/Makefile
ghc/interpreter/lib/Prelude.hs
ghc/interpreter/lift.c
ghc/interpreter/link.c
ghc/interpreter/machdep.c
ghc/interpreter/translate.c
ghc/lib/hugs/Prelude.hs

index 4fcc0e8..c73f9e1 100644 (file)
@@ -1,6 +1,6 @@
 
 # --------------------------------------------------------------------------- #
-# $Id: Makefile,v 1.20 1999/11/22 16:44:32 sewardj Exp $                      #
+# $Id: Makefile,v 1.21 1999/11/23 18:08:17 sewardj Exp $                      #
 # --------------------------------------------------------------------------- #
 
 TOP = ..
@@ -20,7 +20,7 @@ LIB_DL=-ldl
 endif
 
 ifeq "$(HaveLibReadline)$" "YES"
-LIB_READLINE=-lreadline
+LIB_READLINE=-lreadline -ltermcap
 else
 LIB_READLINE=
 endif
index 69c9db6..e0bc1d1 100644 (file)
@@ -1571,12 +1571,17 @@ primCreateAdjThunk fun typestr callconv
         return a
 
 -- The following primitives are only needed if (n+k) patterns are enabled:
-primPmNpk        :: Integral a => Int -> a -> Maybe a
-primPmNpk n x     = if n'<=x then Just (x-n') else Nothing
-                   where n' = fromInt n
+primPmSub           :: Integral a => Int -> a -> a
+primPmSub n x        = x - fromInt n
 
-primPmSub        :: Integral a => Int -> a -> a
-primPmSub n x     = x - fromInt n
+primPmFromInteger   :: Integral a => Integer -> a
+primPmFromInteger    = fromIntegral
+
+primPmSubtract      :: Integral a => a -> a -> a
+primPmSubtract x y   = x - y
+
+primPmLe            :: Integral a => a -> a -> Bool
+primPmLe x y         = x <= y
 
 -- Unpack strings generated by the Hugs code generator.
 -- Strings can contain \0 provided they're coded right.
index 8f237eb..df2cdd3 100644 (file)
@@ -12,8 +12,8 @@
  * included in the distribution.
  *
  * $RCSfile: lift.c,v $
- * $Revision: 1.7 $
- * $Date: 1999/11/12 17:32:40 $
+ * $Revision: 1.8 $
+ * $Date: 1999/11/23 18:08:17 $
  * ------------------------------------------------------------------------*/
 
 #include "prelude.h"
@@ -174,6 +174,11 @@ List liftBinds( List binds )
 
     for(bs=binds; nonNull(bs); bs=tl(bs)) {
         StgVar bind = hd(bs);
+#if 0
+        fprintf(stderr, "\n");
+        if (lastModule() != modulePrelude) ppStg(hd(bs));
+        fprintf(stderr, "\n");
+#endif
         freeVarsBind(NIL,bind);
         stgVarInfo(bind) = NONE; /* mark as top level */
     }
index 22967fb..752e03f 100644 (file)
@@ -9,8 +9,8 @@
  * included in the distribution.
  *
  * $RCSfile: link.c,v $
- * $Revision: 1.17 $
- * $Date: 1999/11/23 15:12:08 $
+ * $Revision: 1.18 $
+ * $Date: 1999/11/23 18:08:17 $
  * ------------------------------------------------------------------------*/
 
 #include "prelude.h"
@@ -494,6 +494,10 @@ Void linkPreludeNames(void) {           /* Hook to names defined in Prelude */
         namePmInt          = linkName("primPmInt");
         namePmInteger      = linkName("primPmInteger");
         namePmDouble       = linkName("primPmDouble");
+        namePmFromInteger = linkName("primPmFromInteger");
+        namePmSubtract    = linkName("primPmSubtract");
+        namePmLe          = linkName("primPmLe");
     }
 }
 
index cc69112..510aba0 100644 (file)
@@ -13,8 +13,8 @@
  * included in the distribution.
  *
  * $RCSfile: machdep.c,v $
- * $Revision: 1.10 $
- * $Date: 1999/11/17 16:57:41 $
+ * $Revision: 1.11 $
+ * $Date: 1999/11/23 18:08:18 $
  * ------------------------------------------------------------------------*/
 
 #ifdef HAVE_SIGNAL_H
@@ -653,7 +653,7 @@ Bool findFilesForModule (
    Int    nPath;
    Bool   literate;
    String peStart, peEnd;
-   String augdPath;       /* .:defaultLibDir:hugsPath */
+   String augdPath;       /* .:hugsPath:defaultLibDir */
 
    *path = *sExt = NULL;
    *sAvail = *iAvail = *oAvail = FALSE;
@@ -665,10 +665,10 @@ Bool findFilesForModule (
    augdPath[0] = '.';
    augdPath[1] = PATHSEP;
    augdPath[2] = 0;
-   strcat ( augdPath, defaultLibDir );
-   augdPath[2+strlen(defaultLibDir)] = PATHSEP;
-   augdPath[3+strlen(defaultLibDir)] = 0;
-   strcat(augdPath,hugsPath);
+   strcat ( augdPath, hugsPath );
+   augdPath[2+strlen(hugsPath)] = PATHSEP;
+   augdPath[3+strlen(hugsPath)] = 0;
+   strcat(augdPath,defaultLibDir);
 
    peEnd = augdPath-1;
    while (1) {
index 1ff953b..3af2fd5 100644 (file)
@@ -10,8 +10,8 @@
  * included in the distribution.
  *
  * $RCSfile: translate.c,v $
- * $Revision: 1.18 $
- * $Date: 1999/11/23 09:48:46 $
+ * $Revision: 1.19 $
+ * $Date: 1999/11/23 18:08:19 $
  * ------------------------------------------------------------------------*/
 
 #include "prelude.h"
@@ -211,6 +211,7 @@ StgExpr failExpr;
             Cell   scrut = stgOffset(o,sc);
             Cell   h     = getHead(discr);
             Int    da    = discrArity(discr);
+            char   str[30];
 
 #if NPLUSK
             if (whatIs(h) == ADDPAT && argCount == 1) {
@@ -233,8 +234,10 @@ StgExpr failExpr;
                     dIntegral = mkStgVar(dIntegral,NIL);
                     binds = cons(dIntegral,binds);
                 }
+
                 /* box number */
-                n = mkStgVar(mkStgCon(nameMkInteger,singleton(n)),NIL);
+                sprintf(str, "%d", n);
+                n = mkStgVar(mkStgCon(nameMkInteger,singleton(stringToBignum(str))),NIL);
                 binds = cons(n,binds);
 
                 /* coerce number to right type (using Integral dict) */
index 69c9db6..e0bc1d1 100644 (file)
@@ -1571,12 +1571,17 @@ primCreateAdjThunk fun typestr callconv
         return a
 
 -- The following primitives are only needed if (n+k) patterns are enabled:
-primPmNpk        :: Integral a => Int -> a -> Maybe a
-primPmNpk n x     = if n'<=x then Just (x-n') else Nothing
-                   where n' = fromInt n
+primPmSub           :: Integral a => Int -> a -> a
+primPmSub n x        = x - fromInt n
 
-primPmSub        :: Integral a => Int -> a -> a
-primPmSub n x     = x - fromInt n
+primPmFromInteger   :: Integral a => Integer -> a
+primPmFromInteger    = fromIntegral
+
+primPmSubtract      :: Integral a => a -> a -> a
+primPmSubtract x y   = x - y
+
+primPmLe            :: Integral a => a -> a -> Bool
+primPmLe x y         = x <= y
 
 -- Unpack strings generated by the Hugs code generator.
 -- Strings can contain \0 provided they're coded right.