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