@@ -32,9 +32,17 @@ data ModuleTree = MTree { mod_path :: IFileType,
32 mod_deps :: [ModuleTree] }
32 mod_deps :: [ModuleTree] }
33 deriving Show
33 deriving Show
35−latest :: UTCTime -> [ModuleTree] -> UTCTime
35+latest :: UTCTime -> [IFileType] -> [ModuleTree] -> UTCTime
36−latest tm [] = tm
36+latest tm done [] = tm
37+latest tm done (m : ms)
38+ | mod_path m `elem` done = latest tm done ms
37−latest tm (m : ms) = latest (max tm (mod_time m)) (ms ++ mod_deps m)
39+ | otherwise = latest (max tm (mod_time m)) (mod_path m : done)
42+modName :: IFileType -> String
44+modName (LIDR fp) = fp
45+modName (IBC fp src) = modName src
39-- | Given a module tree, return the list of files to be loaded. If
47-- | Given a module tree, return the list of files to be loaded. If
40-- any module has a descendent which needs reloading, return its
48-- any module has a descendent which needs reloading, return its
@@ -46,17 +54,17 @@ getModuleFiles ts = nub $ execState (modList ts) [] where
46 modList (m : ms) = do modTree [] m; modList ms
54 modList (m : ms) = do modTree [] m; modList ms
48 modTree path (MTree p rechk tm deps)
56 modTree path (MTree p rechk tm deps)
49− = do let file = chkReload rechk p
57+ = do let file = chkReload rechk p
50− -- Needs rechecking if 'rechk' is true, or if any of the
58+ -- Needs rechecking if 'rechk' is true, or if any of the
51− -- modification times in 'deps' are later than tm
59+ -- modification times in 'deps' are later than tm
52− let depMod = latest tm deps
60+ let depMod = latest tm [] deps
53− let needsRechk = rechk || depMod > tm
61+ let needsRechk = rechk || depMod > tm
55− st <- get
63+ st <- get
56− if needsRechk then put $ nub (getSrc file : updateToSrc path st)
64+ if needsRechk then put $ nub (getSrc file : updateToSrc path st)
57− else put $ nub (file : st)
65+ else put $ nub (file : st)
58−-- when (not (ibc p) || rechk) $
66+ st <- get
59− mapM_ (modTree (getSrc p : path)) deps
67+ mapM_ (modTree (getSrc p : path)) deps
61 chkReload False p = p
69 chkReload False p = p
62 chkReload True (IBC fn src) = chkReload True src
70 chkReload True (IBC fn src) = chkReload True src