X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fghci%2FLinker.lhs;h=38d584a633f7cb46a94161c67654573a0f5b8998;hp=37fe289c1f95bf607e603ed1343affec0347e2b8;hb=cdce647711c0f46f5799b24de087622cb77e647f;hpb=7d6dffe542bdad5707a929ae7ac25813c586766d diff --git a/compiler/ghci/Linker.lhs b/compiler/ghci/Linker.lhs index 37fe289..38d584a 100644 --- a/compiler/ghci/Linker.lhs +++ b/compiler/ghci/Linker.lhs @@ -18,7 +18,7 @@ module Linker ( HValue, getHValue, showLinkerState, linkExpr, unload, extendLinkEnv, withExtendedLinkEnv, extendLoadedPkgs, linkPackages,initDynLinker, - recoverDataCon + dataConInfoPtrToName ) where #include "HsVersions.h" @@ -28,8 +28,9 @@ import ByteCodeLink import ByteCodeItbls import ByteCodeAsm import RtClosureInspect +import CgInfoTbls +import SMRep import IfaceEnv -import OccName import TcRnMonad import Packages import DriverPhases @@ -38,6 +39,7 @@ import HscTypes import Name import NameEnv import NameSet +import qualified OccName import UniqFM import Module import ListSetOps @@ -52,6 +54,7 @@ import ErrUtils import DriverPhases import SrcLoc import UniqSet +import Constants -- Standard libraries import Control.Monad @@ -68,13 +71,6 @@ import System.Directory import Control.Exception import Data.Maybe - -#if __GLASGOW_HASKELL__ >= 503 -import GHC.IOBase ( IO(..) ) -#else -import PrelIOBase ( IO(..) ) -#endif - \end{code} @@ -158,12 +154,13 @@ extendLinkEnv new_bindings -- We use this string to lookup the interpreter's internal representation of the name -- using the lookupOrig. -recoverDataCon :: a -> TcM Name -recoverDataCon x = do +dataConInfoPtrToName :: Ptr () -> TcM Name +dataConInfoPtrToName x = do theString <- ioToTcRn $ do - let ptr = getInfoTablePtr x + let ptr = castPtr x :: Ptr StgInfoTable conDescAddress <- getConDescAddress ptr - peekCString conDescAddress + str <- peekCString conDescAddress + return str let (pkg, mod, occ) = parse theString occName = mkOccName OccName.dataName occ modName = mkModule (stringToPackageId pkg) (mkModuleName mod) @@ -213,17 +210,11 @@ recoverDataCon x = do getConDescAddress :: Ptr StgInfoTable -> IO (Ptr CChar) getConDescAddress ptr = do - peek $ intPtrToPtr $ (ptrToIntPtr ptr) + offset #ifdef GHCI_TABLES_NEXT_TO_CODE - where - -- subtract a word number of bytes - offset = negate (fromIntegral SIZEOF_VOID_P) -#endif -#ifndef GHCI_TABLES_NEXT_TO_CODE - where - -- add the standard info table size in bytes - infoTableSizeBytes = sTD_ITBL_SIZE * wORD_SIZE - offset = infoTableSizeBytes + offsetToString <- peek $ ptr `plusPtr` (- wORD_SIZE) + return $ (ptr `plusPtr` stdInfoTableSizeB) `plusPtr` (fromIntegral (offsetToString :: StgWord)) +#else + peek $ intPtrToPtr $ (ptrToIntPtr ptr) + stdInfoTableSizeB #endif -- parsing names is a little bit fiddly because we have a string in the form: