on master help sign in
avoid confusion between the compiler and codegens
18450ffСухарик
codegen/idris-c/Main.hs → codegen/idris-codegen-c/Main.hsrenamed+11−9
@@ -16,17 +16,19 @@ import Paths_idris
16
16
17import Util.System
17import Util.System
18
18
19+data Opts = Opts { really :: Bool,
19−data Opts = Opts { inputs :: [FilePath],
20+ inputs :: [FilePath],
20 interface :: Bool,
21 interface :: Bool,
21 output :: FilePath }
22 output :: FilePath }
22
23
23−showUsage = do putStrLn "Usage: idris-c <ibc-files> [-o <output-file>]"
24+showUsage = do putStrLn "Usage: idris-codegen-c --yes-really <ibc-files> [-o <output-file>]"
24 exitWith ExitSuccess
25 exitWith ExitSuccess
25
26
26getOpts :: IO Opts
27getOpts :: IO Opts
27getOpts = do xs <- getArgs
28getOpts = do xs <- getArgs
28− return $ process (Opts [] False "a.out") xs
29+ return $ process (Opts False [] False "a.out") xs
29 where
30 where
31+ process opts ("--yes-really":xs) = process (opts { really = True }) xs
30 process opts ("-o":o:xs) = process (opts { output = o }) xs
32 process opts ("-o":o:xs) = process (opts { output = o }) xs
31 process opts ("--interface":xs) = process (opts { interface = True }) xs
33 process opts ("--interface":xs) = process (opts { interface = True }) xs
32 process opts (x:xs) = process (opts { inputs = x:inputs opts }) xs
34 process opts (x:xs) = process (opts { inputs = x:inputs opts }) xs
@@ -36,7 +38,7 @@ c_main :: Opts -> Idris ()
36c_main opts = do runIO setupBundledCC
38c_main opts = do runIO setupBundledCC
37 elabPrims
39 elabPrims
38 loadInputs (inputs opts) Nothing
40 loadInputs (inputs opts) Nothing
39− mainProg <- if interface opts
41+ mainProg <- if interface opts
40 then liftM Just elabMain
42 then liftM Just elabMain
41 else return Nothing
43 else return Nothing
42 ir <- compile (Via "c") (output opts) mainProg
44 ir <- compile (Via "c") (output opts) mainProg
@@ -44,9 +46,9 @@ c_main opts = do runIO setupBundledCC
44
46
45main :: IO ()
47main :: IO ()
46main = do opts <- getOpts
48main = do opts <- getOpts
47− if (null (inputs opts))
49+ if (null (inputs opts))
48 then showUsage
50 then showUsage
51+ else if (not $ really opts)
52+ then do putStrLn "This is not what you may expect it is."
53+ showUsage
49− else runMain (c_main opts)
54+ else runMain (c_main opts)
50−
51−
52−
codegen/idris-javascript/Main.hs → codegen/idris-codegen-javascript/Main.hsrenamed+9−4
@@ -13,17 +13,19 @@ import System.Exit
13
13
14import Paths_idris
14import Paths_idris
15
15
16+data Opts = Opts { really :: Bool
16−data Opts = Opts { inputs :: [FilePath]
17+ , inputs :: [FilePath]
17 , output :: FilePath
18 , output :: FilePath
18 }
19 }
19
20
20−showUsage = do putStrLn "Usage: idris-javascript <ibc-files> [-o <output-file>]"
21+showUsage = do putStrLn "Usage: idris-codegen-javascript --yes-really <ibc-files> [-o <output-file>]"
21 exitWith ExitSuccess
22 exitWith ExitSuccess
22
23
23getOpts :: IO Opts
24getOpts :: IO Opts
24getOpts = do xs <- getArgs
25getOpts = do xs <- getArgs
25− return $ process (Opts [] "main.js") xs
26+ return $ process (Opts False [] "main.js") xs
26 where
27 where
28+ process opts ("--yes-really":xs) = process (opts { really = True }) xs
27 process opts ("-o":o:xs) = process (opts { output = o }) xs
29 process opts ("-o":o:xs) = process (opts { output = o }) xs
28 process opts (x:xs) = process (opts { inputs = x:inputs opts }) xs
30 process opts (x:xs) = process (opts { inputs = x:inputs opts }) xs
29 process opts [] = opts
31 process opts [] = opts
@@ -39,4 +41,7 @@ main :: IO ()
39main = do opts <- getOpts
41main = do opts <- getOpts
40 if (null (inputs opts))
42 if (null (inputs opts))
41 then showUsage
43 then showUsage
44+ else if (not $ really opts)
45+ then do putStrLn "This is not what you may expect it is."
46+ showUsage
42− else runMain (jsMain opts)
47+ else runMain (jsMain opts)
codegen/idris-node/Main.hs → codegen/idris-codegen-node/Main.hsrenamed+9−4
@@ -13,17 +13,19 @@ import System.Exit
13
13
14import Paths_idris
14import Paths_idris
15
15
16+data Opts = Opts { really :: Bool
16−data Opts = Opts { inputs :: [FilePath]
17+ , inputs :: [FilePath]
17 , output :: FilePath
18 , output :: FilePath
18 }
19 }
19
20
20−showUsage = do putStrLn "Usage: idris-node <ibc-files> [-o <output-file>]"
21+showUsage = do putStrLn "Usage: idris-codegen-node --yes-really <ibc-files> [-o <output-file>]"
21 exitWith ExitSuccess
22 exitWith ExitSuccess
22
23
23getOpts :: IO Opts
24getOpts :: IO Opts
24getOpts = do xs <- getArgs
25getOpts = do xs <- getArgs
25− return $ process (Opts [] "main.js") xs
26+ return $ process (Opts False [] "main.js") xs
26 where
27 where
28+ process opts ("--yes-really":xs) = process (opts { really = True }) xs
27 process opts ("-o":o:xs) = process (opts { output = o }) xs
29 process opts ("-o":o:xs) = process (opts { output = o }) xs
28 process opts (x:xs) = process (opts { inputs = x:inputs opts }) xs
30 process opts (x:xs) = process (opts { inputs = x:inputs opts }) xs
29 process opts [] = opts
31 process opts [] = opts
@@ -39,4 +41,7 @@ main :: IO ()
39main = do opts <- getOpts
41main = do opts <- getOpts
40 if (null (inputs opts))
42 if (null (inputs opts))
41 then showUsage
43 then showUsage
44+ else if (not $ really opts)
45+ then do putStrLn "This is not what you may expect it is."
46+ showUsage
42− else runMain (jsMain opts)
47+ else runMain (jsMain opts)
idris.cabal+6−6
@@ -991,9 +991,9 @@ Executable idris
991 ghc-prof-options: -auto-all -caf-all
991 ghc-prof-options: -auto-all -caf-all
992 ghc-options: -threaded -rtsopts -funbox-strict-fields
992 ghc-options: -threaded -rtsopts -funbox-strict-fields
993
993
994−Executable idris-c
994+Executable idris-codegen-c
995 Main-is: Main.hs
995 Main-is: Main.hs
996− hs-source-dirs: codegen/idris-c
996+ hs-source-dirs: codegen/idris-codegen-c
997
997
998 Build-depends: idris
998 Build-depends: idris
999 , base
999 , base
@@ -1004,9 +1004,9 @@ Executable idris-c
1004 ghc-prof-options: -auto-all -caf-all
1004 ghc-prof-options: -auto-all -caf-all
1005 ghc-options: -threaded -rtsopts -funbox-strict-fields
1005 ghc-options: -threaded -rtsopts -funbox-strict-fields
1006
1006
1007−Executable idris-javascript
1007+Executable idris-codegen-javascript
1008 Main-is: Main.hs
1008 Main-is: Main.hs
1009− hs-source-dirs: codegen/idris-javascript
1009+ hs-source-dirs: codegen/idris-codegen-javascript
1010
1010
1011 Build-depends: idris
1011 Build-depends: idris
1012 , base
1012 , base
@@ -1017,9 +1017,9 @@ Executable idris-javascript
1017 ghc-prof-options: -auto-all -caf-all
1017 ghc-prof-options: -auto-all -caf-all
1018 ghc-options: -threaded -rtsopts -funbox-strict-fields
1018 ghc-options: -threaded -rtsopts -funbox-strict-fields
1019
1019
1020−Executable idris-node
1020+Executable idris-codegen-node
1021 Main-is: Main.hs
1021 Main-is: Main.hs
1022− hs-source-dirs: codegen/idris-node
1022+ hs-source-dirs: codegen/idris-codegen-node
1023
1023
1024 Build-depends: idris
1024 Build-depends: idris
1025 , base
1025 , base
src/IRTS/Compiler.hs+2−2
@@ -135,8 +135,8 @@ generate codegen mainmod ir
135 -- Built-in code generators (FIXME: lift these out!)
135 -- Built-in code generators (FIXME: lift these out!)
136 Via "c" -> codegenC ir
136 Via "c" -> codegenC ir
137 -- Any external code generator
137 -- Any external code generator
138− Via cg -> do let cmd = "idris-" ++ cg
138+ Via cg -> do let cmd = "idris-codegen-" ++ cg
139− args = [mainmod, "-o", outputFile ir] ++ compilerFlags ir
139+ args = ["--yes-really", mainmod, "-o", outputFile ir] ++ compilerFlags ir
140 exit <- rawSystem cmd args
140 exit <- rawSystem cmd args
141 when (exit /= ExitSuccess) $
141 when (exit /= ExitSuccess) $
142 putStrLn ("FAILURE: " ++ show cmd ++ " " ++ show args)
142 putStrLn ("FAILURE: " ++ show cmd ++ " " ++ show args)