[project @ 2001-02-13 18:01:22 by simonmar]
[ghc-hetmet.git] / ghc / compiler / ghci / Linker.lhs
index c876b0a..533b6ac 100644 (file)
@@ -6,13 +6,15 @@
 \begin{code}
 {-# OPTIONS -#include "Linker.h" #-}
 module Linker ( 
+   initLinker,  -- :: IO ()
    loadObj,      -- :: String -> IO ()
    unloadObj,    -- :: String -> IO ()
-   lookupSymbol, -- :: String -> IO (Maybe Addr)
+   lookupSymbol, -- :: String -> IO (Maybe (Ptr a))
    resolveObjs,  -- :: IO ()
+   addDLL       -- :: String -> IO Bool
   )  where
 
-import Addr
+import Foreign         ( Ptr, nullPtr )
 import PrelByteArr
 import PrelPack        (packString)
 import Panic           ( panic )
@@ -23,7 +25,7 @@ import Panic          ( panic )
 
 lookupSymbol str = do
    addr <- c_lookupSymbol (packString str)
-   if addr == nullAddr
+   if addr == nullPtr
        then return Nothing
        else return (Just addr)
 
@@ -45,11 +47,14 @@ resolveObjs = do
        then panic "resolveObjs: failed"
        else return ()
 
+addDLL str = do
+   r <- c_addDLL (packString str)
+   return (r == 0)
 
 type PackedString = ByteArray Int
 
 foreign import "lookupSymbol" unsafe
-   c_lookupSymbol :: PackedString -> IO Addr
+   c_lookupSymbol :: PackedString -> IO (Ptr a)
 
 foreign import "loadObj" unsafe
    c_loadObj :: PackedString -> IO Int
@@ -59,4 +64,11 @@ foreign import "unloadObj" unsafe
 
 foreign import "resolveObjs" unsafe
    c_resolveObjs :: IO Int
+
+foreign import "initLinker" unsafe
+   initLinker :: IO ()
+
+foreign import "addDLL" unsafe 
+   c_addDLL :: PackedString -> IO Int
+
 \end{code}