diff options
| author | bringert <bringert@cs.chalmers.se> | 2005-11-30 17:40:11 +0000 |
|---|---|---|
| committer | bringert <bringert@cs.chalmers.se> | 2005-11-30 17:40:11 +0000 |
| commit | 94b99219b8a438c4f29f68a0c19ee86caa608904 (patch) | |
| tree | be4b24127d99a385295fe096020474f96f8ce727 /src/Transfer/CompilerAPI.hs | |
| parent | 3139bd2a2ef47a7959122328e75256442b802094 (diff) | |
Transfer compiler: don't load the same module twice.
Diffstat (limited to 'src/Transfer/CompilerAPI.hs')
| -rw-r--r-- | src/Transfer/CompilerAPI.hs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Transfer/CompilerAPI.hs b/src/Transfer/CompilerAPI.hs index e1ef32f62..020393a02 100644 --- a/src/Transfer/CompilerAPI.hs +++ b/src/Transfer/CompilerAPI.hs @@ -11,6 +11,7 @@ import Transfer.SyntaxToCore import Transfer.PathUtil +import Data.List import System.Directory @@ -33,16 +34,18 @@ compile m = return (printTree $ declsToCore m) loadModule :: [FilePath] -- ^ directories to look for imported modules in -> FilePath -- ^ source module file -> IO [Decl] -loadModule path f = +loadModule = loadModule_ [] + where + loadModule_ ms path f = do s <- readFile f Module is ds <- case pModule (myLLexer s) of Bad e -> fail $ "Parse error in " ++ f ++ ": " ++ e Ok m -> return m - let deps = [ i | Import (Ident i) <- is ] + let load = [ i | Import (Ident i) <- is ] \\ ms let path' = directoryOf f : path - files <- mapM (findFile path' . (++".tr")) deps - dss <- mapM (loadModule path) files + files <- mapM (findFile path' . (++".tr")) load + dss <- mapM (loadModule_ (load++ms) path) files return $ concat (dss++[ds]) myLLexer :: String -> [Token] |
