on master help sign in
Merge branch 'master' of github.com:edwinb/Idris-dev
d7d31d1Edwin Brady
.gitignore−1
@@ -10,7 +10,6 @@ cabal-dev/
10*~
10*~
11.DS_Store
11.DS_Store
12custom.mk
12custom.mk
13−java/executable_pom.xml
14test/output
13test/output
15test/test???/output
14test/test???/output
16test/reg???/output
15test/reg???/output
.travis.yml+2
@@ -14,3 +14,5 @@ script:
14 - cabal copy
14 - cabal copy
15 - make test
15 - make test
16 - make test_llvm
16 - make test_llvm
17+ - make test_java
18+
idris.cabal+1−1
@@ -57,6 +57,7 @@ Data-files: jsrts/Runtime-browser.js
57 rts/idris_rts.h
57 rts/idris_rts.h
58 rts/idris_stdfgn.h
58 rts/idris_stdfgn.h
59 rts/libtest.c
59 rts/libtest.c
60+ java/*.xml
60
61
61Extra-source-files:
62Extra-source-files:
62 Makefile
63 Makefile
@@ -86,7 +87,6 @@ Extra-source-files:
86 effects/Effect/*.idr
87 effects/Effect/*.idr
87 effects/*.idr
88 effects/*.idr
88
89
89− java/*.xml
90
90
91 javascript/*.idr
91 javascript/*.idr
92 javascript/JavaScript/*.idr
92 javascript/JavaScript/*.idr
java/executable_pom_template.xml → java/executable_pom.xmlrenamed+1−1
@@ -15,7 +15,7 @@
15 <dependency>
15 <dependency>
16 <groupId>org.idris-lang</groupId>
16 <groupId>org.idris-lang</groupId>
17 <artifactId>idris</artifactId>
17 <artifactId>idris</artifactId>
18− <version>0.9.10-alpha-1</version>
18+ <version>0.9.10-alpha-2</version>
19 </dependency>
19 </dependency>
20$DEPENDENCIES$
20$DEPENDENCIES$
21 </dependencies>
21 </dependencies>
src/Core/Execute.hs+10−19
@@ -409,10 +409,7 @@ data Foreign = FFun String [FType] FType deriving Show
409call :: Foreign -> [ExecVal] -> Exec (Maybe ExecVal)
409call :: Foreign -> [ExecVal] -> Exec (Maybe ExecVal)
410call (FFun name argTypes retType) args =
410call (FFun name argTypes retType) args =
411 do fn <- findForeign name
411 do fn <- findForeign name
412− case fn of
413− Nothing -> return Nothing
414− Just f -> do res <- call' f args retType
412+ maybe (return Nothing) (\f -> Just . ioWrap <$> call' f args retType) fn
415− return . Just . ioWrap $ res
416 where call' :: ForeignFun -> [ExecVal] -> FType -> Exec ExecVal
413 where call' :: ForeignFun -> [ExecVal] -> FType -> Exec ExecVal
417 call' (Fun _ h) args (FArith (ATInt ITNative)) = do
414 call' (Fun _ h) args (FArith (ATInt ITNative)) = do
418 res <- execIO $ callFFI h retCInt (prepArgs args)
415 res <- execIO $ callFFI h retCInt (prepArgs args)
@@ -440,10 +437,9 @@ call (FFun name argTypes retType) args =
440-- lift $ free res
437-- lift $ free res
441 return (EConstant (Str hStr))
438 return (EConstant (Str hStr))
442
439
443− call' (Fun _ h) args FPtr = do res <- execIO $ callFFI h (retPtr retVoid) (prepArgs args)
440+ call' (Fun _ h) args FPtr = EPtr <$> (execIO $ callFFI h (retPtr retVoid) (prepArgs args))
444− return (EPtr res)
445− call' (Fun _ h) args FUnit = do res <- execIO $ callFFI h retVoid (prepArgs args)
441+ call' (Fun _ h) args FUnit = do _ <- execIO $ callFFI h retVoid (prepArgs args)
446− return (EP Ref unitCon EErased)
442+ return $ EP Ref unitCon EErased
447-- call' (Fun _ h) args other = fail ("Unsupported foreign return type " ++ show other)
443-- call' (Fun _ h) args other = fail ("Unsupported foreign return type " ++ show other)
448
444
449
445
@@ -511,21 +507,16 @@ toConst (Constant c) = Just c
511toConst _ = Nothing
507toConst _ = Nothing
512
508
513stepForeign :: [ExecVal] -> Exec (Maybe ExecVal)
509stepForeign :: [ExecVal] -> Exec (Maybe ExecVal)
514−stepForeign (ty:fn:args) = do let ffun = foreignFromTT fn
510+stepForeign (ty:fn:args) = let ffun = foreignFromTT fn
515− f' <- case (call <$> ffun) of
511+ in case (call <$> ffun) of
516− Just f -> f args
512+ Just f -> f args
517− Nothing -> return Nothing
513+ Nothing -> return Nothing
518− return f'
519stepForeign _ = fail "Tried to call foreign function that wasn't mkForeignPrim"
514stepForeign _ = fail "Tried to call foreign function that wasn't mkForeignPrim"
520
515
521−mapMaybeM :: Monad m => (a -> m (Maybe b)) -> [a] -> m [b]
516+mapMaybeM :: (Functor m, Monad m) => (a -> m (Maybe b)) -> [a] -> m [b]
522mapMaybeM f [] = return []
517mapMaybeM f [] = return []
523mapMaybeM f (x:xs) = do rest <- mapMaybeM f xs
518mapMaybeM f (x:xs) = do rest <- mapMaybeM f xs
524− x' <- f x
519+ maybe rest (:rest) <$> f x
525− case x' of
526− Just x'' -> return (x'':rest)
527− Nothing -> return rest
528−
529findForeign :: String -> Exec (Maybe ForeignFun)
520findForeign :: String -> Exec (Maybe ForeignFun)
530findForeign fn = do est <- getExecState
521findForeign fn = do est <- getExecState
531 let libs = exec_dynamic_libs est
522 let libs = exec_dynamic_libs est
src/Util/System.hs+1−1
@@ -84,4 +84,4 @@ getIncFlags = do dir <- getDataDir
84 return $ "-I" ++ dir </> "rts"
84 return $ "-I" ++ dir </> "rts"
85
85
86getExecutablePom = do dir <- getDataDir
86getExecutablePom = do dir <- getDataDir
87− return $ dir </> "executable_pom.xml"
87+ return $ dir </> "java" </> "executable_pom.xml"