git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Optimize by default and use flags to disable
4fd30a9Gary Burgess
psc-make/Main.hs+7−7
@@ -91,9 +91,9 @@ inputFiles :: Term [FilePath]
91inputFiles = value $ posAny [] $ posInfo
91inputFiles = value $ posAny [] $ posInfo
92 { posDoc = "The input .ps files" }
92 { posDoc = "The input .ps files" }
93
93
94−tco :: Term Bool
94+noTco :: Term Bool
95−tco = value $ flag $ (optInfo [ "tco" ])
95+noTco = value $ flag $ (optInfo [ "no-tco" ])
96− { optDoc = "Perform tail call optimizations" }
96+ { optDoc = "Disable tail call optimizations" }
97
97
98performRuntimeTypeChecks :: Term Bool
98performRuntimeTypeChecks :: Term Bool
99performRuntimeTypeChecks = value $ flag $ (optInfo [ "runtime-type-checks" ])
99performRuntimeTypeChecks = value $ flag $ (optInfo [ "runtime-type-checks" ])
@@ -103,9 +103,9 @@ noPrelude :: Term Bool
103noPrelude = value $ flag $ (optInfo [ "no-prelude" ])
103noPrelude = value $ flag $ (optInfo [ "no-prelude" ])
104 { optDoc = "Omit the Prelude" }
104 { optDoc = "Omit the Prelude" }
105
105
106−magicDo :: Term Bool
106+noMagicDo :: Term Bool
107−magicDo = value $ flag $ (optInfo [ "magic-do" ])
107+noMagicDo = value $ flag $ (optInfo [ "no-magic-do" ])
108− { optDoc = "Overload the do keyword to generate efficient code specifically for the Eff monad." }
108+ { optDoc = "Disable the optimization that overloads the do keyword to generate efficient code specifically for the Eff monad." }
109
109
110noOpts :: Term Bool
110noOpts :: Term Bool
111noOpts = value $ flag $ (optInfo [ "no-opts" ])
111noOpts = value $ flag $ (optInfo [ "no-opts" ])
@@ -116,7 +116,7 @@ browserNamespace = value $ opt "PS" $ (optInfo [ "browser-namespace" ])
116 { optDoc = "Specify the namespace that PureScript modules will be exported to when running in the browser." }
116 { optDoc = "Specify the namespace that PureScript modules will be exported to when running in the browser." }
117
117
118options :: Term P.Options
118options :: Term P.Options
119−options = P.Options <$> tco <*> performRuntimeTypeChecks <*> magicDo <*> pure Nothing <*> noOpts <*> browserNamespace <*> pure [] <*> pure []
119+options = P.Options <$> noTco <*> performRuntimeTypeChecks <*> noMagicDo <*> pure Nothing <*> noOpts <*> browserNamespace <*> pure [] <*> pure []
120
120
121inputFilesAndPrelude :: FilePath -> Term [FilePath]
121inputFilesAndPrelude :: FilePath -> Term [FilePath]
122inputFilesAndPrelude prelude = combine <$> (not <$> noPrelude) <*> inputFiles
122inputFilesAndPrelude prelude = combine <$> (not <$> noPrelude) <*> inputFiles
psc/Main.hs+7−7
@@ -86,9 +86,9 @@ externsFile :: Term (Maybe FilePath)
86externsFile = value $ opt Nothing $ (optInfo [ "e", "externs" ])
86externsFile = value $ opt Nothing $ (optInfo [ "e", "externs" ])
87 { optDoc = "The output .e.ps file" }
87 { optDoc = "The output .e.ps file" }
88
88
89−tco :: Term Bool
89+noTco :: Term Bool
90−tco = value $ flag $ (optInfo [ "tco" ])
90+noTco = value $ flag $ (optInfo [ "no-tco" ])
91− { optDoc = "Perform tail call optimizations" }
91+ { optDoc = "Disable tail call optimizations" }
92
92
93performRuntimeTypeChecks :: Term Bool
93performRuntimeTypeChecks :: Term Bool
94performRuntimeTypeChecks = value $ flag $ (optInfo [ "runtime-type-checks" ])
94performRuntimeTypeChecks = value $ flag $ (optInfo [ "runtime-type-checks" ])
@@ -98,9 +98,9 @@ noPrelude :: Term Bool
98noPrelude = value $ flag $ (optInfo [ "no-prelude" ])
98noPrelude = value $ flag $ (optInfo [ "no-prelude" ])
99 { optDoc = "Omit the Prelude" }
99 { optDoc = "Omit the Prelude" }
100
100
101−magicDo :: Term Bool
101+noMagicDo :: Term Bool
102−magicDo = value $ flag $ (optInfo [ "magic-do" ])
102+noMagicDo = value $ flag $ (optInfo [ "no-magic-do" ])
103− { optDoc = "Overload the do keyword to generate efficient code specifically for the Eff monad." }
103+ { optDoc = "Disable the optimization that overloads the do keyword to generate efficient code specifically for the Eff monad." }
104
104
105runMain :: Term (Maybe String)
105runMain :: Term (Maybe String)
106runMain = value $ defaultOpt (Just "Main") Nothing $ (optInfo [ "main" ])
106runMain = value $ defaultOpt (Just "Main") Nothing $ (optInfo [ "main" ])
@@ -123,7 +123,7 @@ codeGenModules = value $ optAll [] $ (optInfo [ "codegen" ])
123 { optDoc = "A list of modules for which Javascript and externs should be generated. This argument can be used multiple times." }
123 { optDoc = "A list of modules for which Javascript and externs should be generated. This argument can be used multiple times." }
124
124
125options :: Term P.Options
125options :: Term P.Options
126−options = P.Options <$> tco <*> performRuntimeTypeChecks <*> magicDo <*> runMain <*> noOpts <*> browserNamespace <*> dceModules <*> codeGenModules
126+options = P.Options <$> noTco <*> performRuntimeTypeChecks <*> noMagicDo <*> runMain <*> noOpts <*> browserNamespace <*> dceModules <*> codeGenModules
127
127
128stdInOrInputFiles :: FilePath -> Term (Maybe [FilePath])
128stdInOrInputFiles :: FilePath -> Term (Maybe [FilePath])
129stdInOrInputFiles prelude = combine <$> useStdIn <*> (not <$> noPrelude) <*> inputFiles
129stdInOrInputFiles prelude = combine <$> useStdIn <*> (not <$> noPrelude) <*> inputFiles
src/Language/PureScript/Optimizer/MagicDo.hs+2−2
@@ -30,8 +30,8 @@ import Language.PureScript.Names
30import qualified Language.PureScript.Constants as C
30import qualified Language.PureScript.Constants as C
31
31
32magicDo :: Options -> JS -> JS
32magicDo :: Options -> JS -> JS
33+magicDo opts | optionsNoMagicDo opts = id
33−magicDo opts | optionsMagicDo opts = inlineST . magicDo'
34+ | otherwise = inlineST . magicDo'
34− | otherwise = id
35
35
36-- |
36-- |
37-- Inline type class dictionaries for >>= and return for the Eff monad
37-- Inline type class dictionaries for >>= and return for the Eff monad
src/Language/PureScript/Optimizer/TCO.hs+2−2
@@ -24,8 +24,8 @@ import Language.PureScript.CodeGen.JS.AST
24-- Eliminate tail calls
24-- Eliminate tail calls
25--
25--
26tco :: Options -> JS -> JS
26tco :: Options -> JS -> JS
27−tco opts | optionsTco opts = tco'
27+tco opts | optionsNoTco opts = id
28− | otherwise = id
28+ | otherwise = tco'
29
29
30tco' :: JS -> JS
30tco' :: JS -> JS
31tco' = everywhere (mkT convert)
31tco' = everywhere (mkT convert)
src/Language/PureScript/Options.hs+4−4
@@ -20,17 +20,17 @@ module Language.PureScript.Options where
20--
20--
21data Options = Options {
21data Options = Options {
22 -- |
22 -- |
23− -- Perform tail-call elimination
23+ -- Disable tail-call elimination
24 --
24 --
25− optionsTco :: Bool
25+ optionsNoTco :: Bool
26 -- |
26 -- |
27 -- Perform type checks at runtime
27 -- Perform type checks at runtime
28 --
28 --
29 , optionsPerformRuntimeTypeChecks :: Bool
29 , optionsPerformRuntimeTypeChecks :: Bool
30 -- |
30 -- |
31− -- Inline calls to ret and bind for the Eff monad
31+ -- Disable inlining of calls to return and bind for the Eff monad
32 --
32 --
33− , optionsMagicDo :: Bool
33+ , optionsNoMagicDo :: Bool
34 -- |
34 -- |
35 -- When specified, checks the type of `main` in the module, and generate a call to run main
35 -- When specified, checks the type of `main` in the module, and generate a call to run main
36 -- after the module definitions.
36 -- after the module definitions.