Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
The loader
This module deals with the top-level issues of dynamic linking (loading), calling the object-code linker and the byte-code linker where necessary.
Synopsis
- newtype Loader = Loader {
- loader_state :: MVar (Maybe LoaderState)
- data LoaderState = LoaderState {
- closure_env :: ClosureEnv
- itbl_env :: !ItblEnv
- bcos_loaded :: ![Linkable]
- objs_loaded :: ![Linkable]
- pkgs_loaded :: ![UnitId]
- temp_sos :: ![(FilePath, String)]
- initLoaderState :: Interp -> HscEnv -> IO ()
- uninitializedLoader :: IO Loader
- showLoaderState :: Interp -> IO SDoc
- loadExpr :: Interp -> HscEnv -> SrcSpan -> UnlinkedBCO -> IO ForeignHValue
- loadDecls :: Interp -> HscEnv -> SrcSpan -> CompiledByteCode -> IO ()
- loadPackages :: Interp -> HscEnv -> [UnitId] -> IO ()
- loadModule :: Interp -> HscEnv -> Module -> IO ()
- loadCmdLineLibs :: Interp -> HscEnv -> IO ()
- loadName :: Interp -> HscEnv -> Name -> IO ForeignHValue
- unload :: Interp -> HscEnv -> [Linkable] -> IO ()
- withExtendedLoadedEnv :: ExceptionMonad m => Interp -> [(Name, ForeignHValue)] -> m a -> m a
- extendLoadedEnv :: Interp -> [(Name, ForeignHValue)] -> IO ()
- deleteFromLoadedEnv :: Interp -> [Name] -> IO ()
- extendLoadedPkgs :: Interp -> [UnitId] -> IO ()
Documentation
data LoaderState Source #
LoaderState | |
|
initLoaderState :: Interp -> HscEnv -> IO () Source #
Initialise the dynamic linker. This entails
a) Calling the C initialisation procedure,
b) Loading any packages specified on the command line,
c) Loading any packages specified on the command line, now held in the
-l
options in v_Opt_l
,
d) Loading any .o/.dll
files specified on the command line, now held
in ldInputs
,
e) Loading any MacOS frameworks.
NOTE: This function is idempotent; if called more than once, it does nothing. This is useful in Template Haskell, where we call it before trying to link.
Load & Unload
loadExpr :: Interp -> HscEnv -> SrcSpan -> UnlinkedBCO -> IO ForeignHValue Source #
Load a single expression, including first loading packages and modules that this expression depends on.
Raises an IO exception (ProgramError
) if it can't find a compiled
version of the dependents to load.
loadPackages :: Interp -> HscEnv -> [UnitId] -> IO () Source #
Load exactly the specified packages, and their dependents (unless of course they are already loaded). The dependents are loaded automatically, and it doesn't matter what order you specify the input packages.
loadName :: Interp -> HscEnv -> Name -> IO ForeignHValue Source #
Load the module containing the given Name and get its associated HValue
.
Throws a ProgramError
if loading fails or the name cannot be found.
Unloading old objects ready for a new compilation sweep.
The compilation manager provides us with a list of linkables that it considers "stable", i.e. won't be recompiled this time around. For each of the modules current linked in memory,
- if the linkable is stable (and it's the same one -- the user may have recompiled the module on the side), we keep it,
- otherwise, we unload it.
- we also implicitly unload all temporary bindings at this point.
LoadedEnv
withExtendedLoadedEnv :: ExceptionMonad m => Interp -> [(Name, ForeignHValue)] -> m a -> m a Source #
Temporarily extend the loaded env.
extendLoadedEnv :: Interp -> [(Name, ForeignHValue)] -> IO () Source #