From e3575292c02f1757e73922393a0aded18ca49376 Mon Sep 17 00:00:00 2001 From: Lemmih Date: Mon, 27 Mar 2006 03:09:50 +0000 Subject: [PATCH] Allow users of the GHC library to specify which packages have already been loaded. This is pretty important when using the linker/bytecode-compiler from binaries other than GHCi. --- ghc/compiler/ghci/Linker.lhs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ghc/compiler/ghci/Linker.lhs b/ghc/compiler/ghci/Linker.lhs index 15786f4..44efac8 100644 --- a/ghc/compiler/ghci/Linker.lhs +++ b/ghc/compiler/ghci/Linker.lhs @@ -16,7 +16,8 @@ necessary. {-# OPTIONS -optc-DNON_POSIX_SOURCE -#include "Linker.h" #-} module Linker ( HValue, showLinkerState, - linkExpr, unload, extendLinkEnv, + linkExpr, unload, extendLinkEnv, + extendLoadedPkgs, linkPackages, ) where @@ -47,7 +48,7 @@ import ErrUtils ( debugTraceMsg ) -- Standard libraries import Control.Monad ( when, filterM, foldM ) -import Data.IORef ( IORef, readIORef, writeIORef ) +import Data.IORef ( IORef, readIORef, writeIORef, modifyIORef ) import Data.List ( partition, nub ) import System.IO ( putStr, putStrLn, hPutStrLn, stderr, fixIO ) @@ -124,6 +125,10 @@ emptyPLS dflags = PersistentLinkerState { \end{code} \begin{code} +extendLoadedPkgs :: [PackageId] -> IO () +extendLoadedPkgs pkgs + = modifyIORef v_PersistentLinkerState (\s -> s{pkgs_loaded = pkgs ++ pkgs_loaded s}) + extendLinkEnv :: [(Name,HValue)] -> IO () -- Automatically discards shadowed bindings extendLinkEnv new_bindings -- 1.7.10.4