Finally separate the compiler from hslibs.
Mainly import wibbles, and use the new POSIX library when
bootstrapping.
#define TRACE Debug.Trace
#define DATA_IOREF Data.IORef
#define FIX_IO System.IO
+#define MONAD_ST Control.Monad.ST
+#define ST_ARRAY Data.Array.ST
#else
#define TRACE IOExts
#define DATA_IOREF IOExts
#define FIX_IO IOExts
+#define MONAD_ST ST
+#define ST_ARRAY ST
#endif
# -----------------------------------------------------------------------------
-# $Id: Makefile,v 1.220 2002/08/29 15:44:12 simonmar Exp $
+# $Id: Makefile,v 1.221 2002/09/06 14:35:43 simonmar Exp $
TOP = ..
# Only include GHCi if we're bootstrapping with at least version 411
ifeq "$(GhcWithInterpreter)" "YES"
ifeq "$(bootstrapped)" "YES"
-SRC_HC_OPTS += -DGHCI
+SRC_HC_OPTS += -DGHCI -package readline
+ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
+SRC_HC_OPTS += -package unix
+endif
ALL_DIRS += ghci
endif
endif
# which needs it).
SRC_MKDEPENDHS_OPTS += -I$(GHC_INCLUDE_DIR)
+# When bootstrapped, we don't make use of *any* packages
+# (except possibly readline if GHCi is enabled, see above)
+ifneq "$(bootstrapped)" "YES"
ifneq "$(mingw32_HOST_OS)" "1"
SRC_HC_OPTS += -package concurrent -package posix -package util
else
SRC_HC_OPTS += -package concurrent -package util
endif
+endif
SRC_CC_OPTS += -Iparser -I. -I$(TOP)/includes -O
SRC_HC_OPTS += -recomp $(GhcHcOpts)
#endif
import GLAEXTS
-import ST
+import MONAD_ST
infixr 9 `thenTE`
\end{code}
-- the result type will be
-- State# RealWorld -> (# State# RealWorld #)
--- Here is where we arrange that ForeignPtrs which are passed to a 'safe'
--- foreign import don't get finalized until the call returns. For each
--- argument of type ForeignObj# we arrange to touch# the argument after
--- the call. The arg_ids passed in are the Ids passed to the actual ccall.
-
boxResult arg_ids result_ty
= case tcSplitTyConApp_maybe result_ty of
-- This split absolutely has to be a tcSplit, because we must
where
mk_alt return_result (Nothing, wrap_result)
= -- The ccall returns ()
- let
- rhs_fun state_id = return_result (Var state_id)
- (wrap_result (panic "boxResult"))
- in
newSysLocalDs realWorldStatePrimTy `thenDs` \ state_id ->
- mkTouches arg_ids state_id rhs_fun `thenDs` \ the_rhs ->
let
+ the_rhs = return_result (Var state_id)
+ (wrap_result (panic "boxResult"))
+
ccall_res_ty = mkTyConApp unboxedSingletonTyCon [realWorldStatePrimTy]
the_alt = (DataAlt unboxedSingletonDataCon, [state_id], the_rhs)
in
mk_alt return_result (Just prim_res_ty, wrap_result)
= -- The ccall returns a non-() value
newSysLocalDs prim_res_ty `thenDs` \ result_id ->
- let
- rhs_fun state_id = return_result (Var state_id)
- (wrap_result (Var result_id))
- in
newSysLocalDs realWorldStatePrimTy `thenDs` \ state_id ->
- mkTouches arg_ids state_id rhs_fun `thenDs` \ the_rhs ->
let
+ the_rhs = return_result (Var state_id)
+ (wrap_result (Var result_id))
+
ccall_res_ty = mkTyConApp unboxedPairTyCon [realWorldStatePrimTy, prim_res_ty]
the_alt = (DataAlt unboxedPairDataCon, [state_id, result_id], the_rhs)
in
returnDs (ccall_res_ty, the_alt)
-touchzh = mkPrimOpId TouchOp
-
-mkTouches [] s cont = returnDs (cont s)
-mkTouches (v:vs) s cont
- | not (idType v `eqType` foreignObjPrimTy) = mkTouches vs s cont
- | otherwise = newSysLocalDs realWorldStatePrimTy `thenDs` \s' ->
- mkTouches vs s' cont `thenDs` \ rest ->
- returnDs (Case (mkApps (Var touchzh) [Type foreignObjPrimTy,
- Var v, Var s]) s'
- [(DEFAULT, [], rest)])
resultWrapper :: Type
-> (Maybe Type, -- Type of the expected result, if any
{-# OPTIONS -#include "Linker.h" -#include "SchedAPI.h" #-}
-----------------------------------------------------------------------------
--- $Id: InteractiveUI.hs,v 1.132 2002/08/29 15:44:14 simonmar Exp $
+-- $Id: InteractiveUI.hs,v 1.133 2002/09/06 14:35:44 simonmar Exp $
--
-- GHC Interactive User Interface
--
import Config
#ifndef mingw32_TARGET_OS
-import Posix
+import System.Posix
#endif
#if HAVE_READLINE_HEADERS && HAVE_READLINE_LIBS
-import Readline
+import System.Console.Readline as Readline
#endif
--import SystemExts
{-# OPTIONS -fno-warn-incomplete-patterns -optc-DNON_POSIX_SOURCE #-}
-----------------------------------------------------------------------------
--- $Id: Main.hs,v 1.109 2002/08/29 15:44:15 simonmar Exp $
+-- $Id: Main.hs,v 1.110 2002/09/06 14:35:44 simonmar Exp $
--
-- GHC Driver program
--
import EXCEPTION ( throwTo )
# endif
+#if __GLASGOW_HASKELL__ > 504
+import System.Posix.Signals
+#else
import Posix ( Handler(Catch), installHandler, sigINT, sigQUIT )
+#endif
+
import DYNAMIC ( toDyn )
#endif
{
module ParsePkgConf( loadPackageConfig ) where
+#include "HsVersions.h"
+
import Packages ( PackageConfig(..), defaultPackageConfig )
import Lex
import FastString
import SrcLoc
import Outputable
import Panic ( GhcException(..) )
-import Exception ( throwDyn )
-
-#include "HsVersions.h"
+import EXCEPTION ( throwDyn )
}
#endif
#ifndef mingw32_HOST_OS
+#if __GLASGOW_HASKELL__ > 504
+import qualified GHC.Posix
+#else
import qualified Posix
+#endif
#else
import List ( isPrefixOf )
import Util ( dropList )
import MarshalArray
import Foreign
-import Foreign.C.String
+import CString
#endif
#ifdef mingw32_HOST_OS
#ifdef mingw32_HOST_OS
foreign import "_getpid" unsafe getProcessID :: IO Int -- relies on Int == Int32 on Windows
+#elif __GLASGOW_HASKELL__ > 504
+getProcessID :: IO Int
+getProcessID = GHC.Posix.c_getpid >>= return . fromIntegral
#else
getProcessID :: IO Int
getProcessID = Posix.getProcessID
import MutableArray
#endif
-import ST
+import MONAD_ST
import Char ( chr, ord )
import Maybe ( isJust )
{- -*-haskell-*-
-----------------------------------------------------------------------------
-$Id: Parser.y,v 1.100 2002/06/07 07:16:05 chak Exp $
+$Id: Parser.y,v 1.101 2002/09/06 14:35:44 simonmar Exp $
Haskell grammar.
{
module Parser ( parseModule, parseStmt, parseIdentifier, parseIface ) where
+#include "HsVersions.h"
+
import HsSyn
import HsTypes ( mkHsTupCon )
NewOrData(..), StrictnessMark(..), Activation(..) )
import Panic
-import GlaExts
+import GLAEXTS
import CStrings ( CLabelString )
import FastString
import Maybes ( orElse )
import Outputable
-#include "HsVersions.h"
}
{-
import Util ( sortLt )
-- Extensions
-import ST
+import MONAD_ST
-- std interfaces
import Maybe
import Array
import List
import Outputable
+
+#if __GLASGOW_HASKELL__ >= 504
+import Data.Array.ST hiding ( indices, bounds )
+#else
+import ST
+#endif
\end{code}
%************************************************************************
\begin{code}
+#if __GLASGOW_HASKELL__ >= 504
+newSTArray :: Ix i => (i,i) -> e -> ST s (STArray s i e)
+newSTArray = newArray
+
+readSTArray :: Ix i => STArray s i e -> i -> ST s e
+readSTArray = readArray
+
+writeSTArray :: Ix i => STArray s i e -> i -> e -> ST s ()
+writeSTArray = writeArray
+#endif
+
type Set s = STArray s Vertex Bool
mkEmpty :: Bounds -> ST s (Set s)
import PrimPacked
import GLAEXTS
import UNSAFE_IO ( unsafePerformIO )
-import ST ( stToIO )
+import MONAD_ST ( stToIO )
import DATA_IOREF ( IORef, newIORef, readIORef, writeIORef )
#if __GLASGOW_HASKELL__ < 503
import GLAEXTS
import UNSAFE_IO ( unsafePerformIO )
-import ST
+import MONAD_ST
import Foreign
#if __GLASGOW_HASKELL__ < 503