From: sewardj Date: Tue, 23 Nov 1999 18:08:21 +0000 (+0000) Subject: [project @ 1999-11-23 18:08:17 by sewardj] X-Git-Tag: Approximately_9120_patches~5503 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=a084f34d1e3d67d2a9fa1da36f2da5aa99657777;p=ghc-hetmet.git [project @ 1999-11-23 18:08:17 by sewardj] Bind namePmFromInteger, namePmSubtract, namePmLe to stuff in Prelude so that n+k patterns work. --- diff --git a/ghc/interpreter/Makefile b/ghc/interpreter/Makefile index 4fcc0e8..c73f9e1 100644 --- a/ghc/interpreter/Makefile +++ b/ghc/interpreter/Makefile @@ -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 diff --git a/ghc/interpreter/lib/Prelude.hs b/ghc/interpreter/lib/Prelude.hs index 69c9db6..e0bc1d1 100644 --- a/ghc/interpreter/lib/Prelude.hs +++ b/ghc/interpreter/lib/Prelude.hs @@ -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. diff --git a/ghc/interpreter/lift.c b/ghc/interpreter/lift.c index 8f237eb..df2cdd3 100644 --- a/ghc/interpreter/lift.c +++ b/ghc/interpreter/lift.c @@ -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 */ } diff --git a/ghc/interpreter/link.c b/ghc/interpreter/link.c index 22967fb..752e03f 100644 --- a/ghc/interpreter/link.c +++ b/ghc/interpreter/link.c @@ -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"); } } diff --git a/ghc/interpreter/machdep.c b/ghc/interpreter/machdep.c index cc69112..510aba0 100644 --- a/ghc/interpreter/machdep.c +++ b/ghc/interpreter/machdep.c @@ -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) { diff --git a/ghc/interpreter/translate.c b/ghc/interpreter/translate.c index 1ff953b..3af2fd5 100644 --- a/ghc/interpreter/translate.c +++ b/ghc/interpreter/translate.c @@ -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) */ diff --git a/ghc/lib/hugs/Prelude.hs b/ghc/lib/hugs/Prelude.hs index 69c9db6..e0bc1d1 100644 --- a/ghc/lib/hugs/Prelude.hs +++ b/ghc/lib/hugs/Prelude.hs @@ -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.