Refactored System.Plugins.Load.loadFunction
This commit is contained in:
parent
dfa37bb45f
commit
a7991e8cb6
@ -42,6 +42,7 @@ module System.Plugins.Load (
|
|||||||
, initLinker -- start it up
|
, initLinker -- start it up
|
||||||
, loadModule -- load a vanilla .o
|
, loadModule -- load a vanilla .o
|
||||||
, loadFunction -- retrieve a function from an object
|
, loadFunction -- retrieve a function from an object
|
||||||
|
, loadFunction_ -- retrieve a function from an object
|
||||||
, loadPackage -- load a ghc library and its cbits
|
, loadPackage -- load a ghc library and its cbits
|
||||||
, unloadPackage -- unload a ghc library and its cbits
|
, unloadPackage -- unload a ghc library and its cbits
|
||||||
, loadPackageWith -- load a pkg using the package.conf provided
|
, loadPackageWith -- load a pkg using the package.conf provided
|
||||||
@ -402,13 +403,18 @@ reload m@(Module{path = p, iface = hi}) sym = do
|
|||||||
--
|
--
|
||||||
-- | Load a function from a module (which must be loaded and resolved first).
|
-- | Load a function from a module (which must be loaded and resolved first).
|
||||||
--
|
--
|
||||||
|
|
||||||
loadFunction :: Module -- ^ The module the value is in
|
loadFunction :: Module -- ^ The module the value is in
|
||||||
-> String -- ^ Symbol name of value
|
-> String -- ^ Symbol name of value
|
||||||
-> IO (Maybe a) -- ^ The value you want
|
-> IO (Maybe a) -- ^ The value you want
|
||||||
|
|
||||||
loadFunction (Module { iface = i }) valsym
|
loadFunction (Module { iface = i }) valsym
|
||||||
= do let m = mi_module i
|
= loadFunction_ (mi_module i) valsym
|
||||||
symbol = symbolise m
|
|
||||||
|
loadFunction_ :: String
|
||||||
|
-> String
|
||||||
|
-> IO (Maybe a)
|
||||||
|
loadFunction_ m valsym
|
||||||
|
= do let symbol = prefixUnderscore++m++"_"++(encode valsym)++"_closure"
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
putStrLn $ "Looking for <<"++symbol++">>"
|
putStrLn $ "Looking for <<"++symbol++">>"
|
||||||
#endif
|
#endif
|
||||||
@ -417,8 +423,6 @@ loadFunction (Module { iface = i }) valsym
|
|||||||
then return Nothing
|
then return Nothing
|
||||||
else case addrToHValue# addr of
|
else case addrToHValue# addr of
|
||||||
(# hval #) -> return ( Just hval )
|
(# hval #) -> return ( Just hval )
|
||||||
where
|
|
||||||
symbolise m = prefixUnderscore++m++"_"++(encode valsym)++"_closure"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user