Refactor.
[hs-java.git] / Java / ClassPath / Types.hs
1
2 module Java.ClassPath.Types where
3
4 import Control.Monad.State
5 import Data.List
6
7 import JVM.ClassFile
8
9 data Tree a =
10     Directory FilePath [Tree a]
11   | File a
12   deriving (Eq)
13
14 instance Show a => Show (Tree a) where
15   show (Directory dir forest) = dir ++ "/{" ++ intercalate ", " (map show forest) ++ "}"
16   show (File a) = show a
17
18 data CPEntry =
19     NotLoaded FilePath
20   | Loaded FilePath (Class Direct)
21   | NotLoadedJAR FilePath FilePath
22   | LoadedJAR FilePath (Class Direct)
23   deriving (Eq)
24
25 instance Show CPEntry where
26   show (NotLoaded path) = "<Not loaded file: " ++ path ++ ">"
27   show (Loaded path cls) = "<Loaded from " ++ path ++ ": " ++ toString (thisClass cls) ++ ">"
28   show (NotLoadedJAR jar path) = "<Not loaded JAR: " ++ jar ++ ": " ++ path ++ ">"
29   show (LoadedJAR path cls) = "<Read JAR: " ++ path ++ ": " ++ toString (thisClass cls) ++ ">"
30
31 type ClassPath a = StateT [Tree CPEntry] IO a
32