diff --git a/TODO b/TODO index 0072be2..0ba8312 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,14 @@ For 1.0 ---------- ++ broken on mac. +symbols with suspiciously many _ chars + ++ Add verbose versions of the load functions, to avoid -DDEBUG + ++ mention that you need .o archives, not .a ones. Use Cabal, ghc-pkg -u + or ld -r --whole-archive + + hs-plugins doesn't know to look for packages in the user packages, only in the global packages diff --git a/src/System/Eval/Haskell.hs b/src/System/Eval/Haskell.hs index 58fd19a..c109e07 100644 --- a/src/System/Eval/Haskell.hs +++ b/src/System/Eval/Haskell.hs @@ -53,9 +53,12 @@ import AltData.Typeable ( Typeable ) import Data.Either import Data.Map as Map +import Data.Char import System.IO import System.Directory +import System.Random +import System.IO.Unsafe -- import Foreign.C -- import Foreign @@ -158,7 +161,7 @@ unsafeEval src mods = do tmpf <- mkUniqueWith wrap src mods status <- make tmpf [] m_rsrc <- case status of - MakeSuccess _ obj -> do + MakeSuccess _ obj -> do m_v <- load obj [pwd] [] symbol case m_v of LoadFailure _ -> return Nothing LoadSuccess _ rsrc -> return $ Just rsrc @@ -235,8 +238,13 @@ dynwrap expr nm mods = "module "++nm++ "( resource ) where\n" ++ concatMap (\m-> "import "++m++"\n") mods ++ "import AltData.Dynamic\n" ++ - "resource = let { yhjulwwiefzojcbxybbruweejw = \n" ++ - "{-# LINE 1 \"\" #-}\n" ++ expr ++ ";} in toDyn yhjulwwiefzojcbxybbruweejw" + "resource = let { "++x++" = \n" ++ + "{-# LINE 1 \"\" #-}\n" ++ expr ++ ";} in toDyn "++x + where + x = ident () + +ident () = unsafePerformIO $ + sequence (take 3 (repeat $ getStdRandom (randomR (97,122)) >>= return . chr)) -- --------------------------------------------------------------------- -- unsafe wrapper @@ -245,8 +253,10 @@ wrap :: String -> String -> [Import] -> String wrap expr nm mods = "module "++nm++ "( resource ) where\n" ++ concatMap (\m-> "import "++m++"\n") mods ++ - "resource = let { yhjulwwiefzojcbxybbruweejw = \n" ++ - "{-# LINE 1 \"\" #-}\n" ++ expr ++ ";} in yhjulwwiefzojcbxybbruweejw" + "resource = let { "++x++" = \n" ++ + "{-# LINE 1 \"\" #-}\n" ++ expr ++ ";} in "++x + where + x = ident () -- what is this big variable name? -- its a random value, so that it won't clash if the accidently mistype