X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fghci%2FByteCodeLink.lhs;h=fabd5d1785a89a6c88e9a9b5759e523da52a5b2b;hp=7304d0290bf32702215815ff69013287de73a127;hb=66579ff945831c5fc9a17c58c722ff01f2268d76;hpb=cdce647711c0f46f5799b24de087622cb77e647f diff --git a/compiler/ghci/ByteCodeLink.lhs b/compiler/ghci/ByteCodeLink.lhs index 7304d02..fabd5d1 100644 --- a/compiler/ghci/ByteCodeLink.lhs +++ b/compiler/ghci/ByteCodeLink.lhs @@ -6,10 +6,17 @@ ByteCodeLink: Bytecode assembler and linker \begin{code} {-# OPTIONS -optc-DNON_POSIX_SOURCE #-} +{-# OPTIONS -w #-} +-- The above warning supression flag is a temporary kludge. +-- While working on this module you are encouraged to remove it and fix +-- any warnings in the module. See +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings +-- for details + module ByteCodeLink ( HValue, ClosureEnv, emptyClosureEnv, extendClosureEnv, - linkBCO, lookupStaticPtr + linkBCO, lookupStaticPtr, lookupName ,lookupIE ) where @@ -27,10 +34,7 @@ import Module import PackageConfig import FastString import Panic - -#ifdef DEBUG import Outputable -#endif -- Standard libraries import GHC.Word ( Word(..) ) @@ -38,7 +42,6 @@ import GHC.Word ( Word(..) ) import Data.Array.Base import GHC.Arr ( STArray(..) ) -import Control.Exception ( throwDyn ) import Control.Monad ( zipWithM ) import Control.Monad.ST ( stToIO ) @@ -58,7 +61,7 @@ import GHC.Base ( writeArray#, RealWorld, Int(..), Word# ) \begin{code} type ClosureEnv = NameEnv (Name, HValue) -newtype HValue = HValue (forall a . a) +newtype HValue = HValue Any emptyClosureEnv = emptyNameEnv @@ -117,11 +120,11 @@ linkBCO' ie ce (UnlinkedBCO nm arity insns_barr bitmap literalsSS ptrsSS) ptrs_arr <- mkPtrsArray ie ce n_ptrs ptrs let - ptrs_parr = case ptrs_arr of Array lo hi parr -> parr + ptrs_parr = case ptrs_arr of Array _lo _hi _n parr -> parr literals_arr = listArray (0, n_literals-1) linked_literals :: UArray Int Word - literals_barr = case literals_arr of UArray lo hi barr -> barr + literals_barr = case literals_arr of UArray _lo _hi _n barr -> barr (I# arity#) = arity @@ -153,6 +156,7 @@ newtype IOArray i e = IOArray (STArray RealWorld i e) instance MArray IOArray e IO where getBounds (IOArray marr) = stToIO $ getBounds marr + getNumElements (IOArray marr) = stToIO $ getNumElements marr newArray lu init = stToIO $ do marr <- newArray lu init; return (IOArray marr) newArray_ lu = stToIO $ do @@ -162,7 +166,7 @@ instance MArray IOArray e IO where -- XXX HACK: we should really have a new writeArray# primop that takes a BCO#. writeArrayBCO :: IOArray Int a -> Int -> BCO# -> IO () -writeArrayBCO (IOArray (STArray _ _ marr#)) (I# i#) bco# = IO $ \s# -> +writeArrayBCO (IOArray (STArray _ _ _ marr#)) (I# i#) bco# = IO $ \s# -> case (unsafeCoerce# writeArray#) marr# i# bco# s# of { s# -> (# s#, () #) } @@ -240,7 +244,7 @@ lookupIE ie con_nm linkFail :: String -> String -> IO a linkFail who what - = throwDyn (ProgramError $ + = ghcError (ProgramError $ unlines [ "" , "During interactive linking, GHCi couldn't find the following symbol:" , ' ' : ' ' : what @@ -261,7 +265,7 @@ nameToCLabel n suffix else qual_name where pkgid = modulePackageId mod - mod = nameModule n + mod = ASSERT( isExternalName n ) nameModule n package_part = unpackFS (zEncodeFS (packageIdFS (modulePackageId mod))) module_part = unpackFS (zEncodeFS (moduleNameFS (moduleName mod))) occ_part = unpackFS (zEncodeFS (occNameFS (nameOccName n))) @@ -270,7 +274,7 @@ nameToCLabel n suffix primopToCLabel :: PrimOp -> String{-suffix-} -> String primopToCLabel primop suffix - = let str = "base_GHCziPrimopWrappers_" ++ unpackFS (zEncodeFS (occNameFS (primOpOcc primop))) ++ '_':suffix + = let str = "ghczmprim_GHCziPrimopWrappers_" ++ unpackFS (zEncodeFS (occNameFS (primOpOcc primop))) ++ '_':suffix in --trace ("primopToCLabel: " ++ str) str \end{code}