(matches, _) <- globDir (map compile patterns) dir
return $ concat matches
+-- | Append one file to ClassPath forest
appendPath :: FilePath -> [Tree CPEntry] -> [Tree CPEntry]
appendPath path forest = merge $ forest ++ (mapF NotLoaded $ buildTree [path])
+-- | Add one directory to current ClassPath
addDirectory :: FilePath -> ClassPath ()
addDirectory dir = do
files <- liftIO $ glob dir ["*.class"]
let cp' = foldr appendPath cp files
St.put cp'
+-- | Run ClassPath monad
runClassPath :: ClassPath a -> IO a
runClassPath m = St.evalStateT m []
+-- | Run ClassPath monad and return resulting ClassPath
execClassPath :: ClassPath () -> IO [Tree CPEntry]
execClassPath m = St.execStateT m []
+-- | Load one class in current ClassPath
loadClass :: String -> ClassPath ()
loadClass path = do
cp <- St.get
| otherwise = return t
load ps (File _) = fail $ "Found file when expecting directory! " ++ show ps
+-- | Get one ClassPath entry
getEntry :: [Tree CPEntry] -> String -> IO (Maybe CPEntry)
getEntry cp path = get cp (split "/" path)
where
GHC=ghc --make -fwarn-unused-imports
-all: dump-class rebuild-class TestGen
+all: Hello.class dump-class rebuild-class TestGen
+
+Hello.class: Hello.java
+ javac $<
dump-class: dump-class.hs */*.hs
$(GHC) $<
invokeStatic Java.Lang.integer Java.Lang.valueOfInteger
aastore
invokeVirtual Java.IO.printStream Java.IO.printf
+ -- Call Hello.hello()
invokeStatic "Hello" helloJava
pop
i0 RETURN
JVM.Exceptions
Java.Lang
Java.IO
+ Java.ClassPath
+ Java.ClassPath.Types
+ Java.ClassPath.Common
+ Java.JAR.Archive
Build-Depends: base >= 3 && <= 5, containers, binary,
mtl, directory, filepath, utf8-string, array,
bytestring, data-binary-ieee754, binary-state,
- control-monad-exception, data-default
+ control-monad-exception, data-default, MissingH,
+ LibZip, Glob
ghc-options: -fwarn-unused-imports