loading code progress
This commit is contained in:
parent
5373ddaf9c
commit
8df4670d80
@ -14,11 +14,12 @@ import Encoding
|
|||||||
|
|
||||||
type PluginSet = M.HashMap String Plugin
|
type PluginSet = M.HashMap String Plugin
|
||||||
|
|
||||||
data Plugin = Plugin { wew :: Int,
|
data Plugin = Plugin { pluginEvent :: String, -- e.g. PRIVMSG
|
||||||
lad :: Int }
|
pluginEntry :: Int }
|
||||||
|
|
||||||
load :: PluginSet -> IO (Either String (IO PluginSet))
|
load :: PluginSet -> String -> IO (Either String PluginSet)
|
||||||
load = do initObjLinker RetainCAFs
|
load set path = do
|
||||||
|
initObjLinker RetainCAFs
|
||||||
loadObj "Plugin.o"
|
loadObj "Plugin.o"
|
||||||
_ret <- resolveObjs
|
_ret <- resolveObjs
|
||||||
ptr <- lookupSymbol (mangleSymbol Nothing "Plugin" "f")
|
ptr <- lookupSymbol (mangleSymbol Nothing "Plugin" "f")
|
||||||
@ -27,11 +28,15 @@ load = do initObjLinker RetainCAFs
|
|||||||
Just (Ptr addr) -> case addrToAny# addr of
|
Just (Ptr addr) -> case addrToAny# addr of
|
||||||
(# f #) -> return $ Right f
|
(# f #) -> return $ Right f
|
||||||
|
|
||||||
unload :: String -> IO PluginSet
|
unload :: PluginSet -> String -> IO PluginSet
|
||||||
unload plugin = catch (unloadObj $ plugin <> ".o") exceptionHandler
|
unload set plugin = catch unloadPlugin exceptionHandler
|
||||||
|
where exceptionHandler :: ErrorCall -> IO PluginSet
|
||||||
|
exceptionHandler _ = return set
|
||||||
|
|
||||||
exceptionHandler :: ErrorCall -> IO PluginSet
|
unloadPlugin :: IO PluginSet
|
||||||
exceptionHandler _ = return ()
|
unloadPlugin = do
|
||||||
|
unloadObj $ plugin <> ".o"
|
||||||
|
return $ M.delete plugin set
|
||||||
|
|
||||||
mangleSymbol :: Maybe String -> String -> String -> String
|
mangleSymbol :: Maybe String -> String -> String -> String
|
||||||
mangleSymbol pkg module' valsym =
|
mangleSymbol pkg module' valsym =
|
||||||
|
Loading…
Reference in New Issue
Block a user