Skip to content

Commit 130e8ae

Browse files
committed
Merge pull request purescript#323 from garyb/optimize-by-default
Optimize by default and use flags to disable
2 parents 285a55d + 4fd30a9 commit 130e8ae

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

psc-make/Main.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ inputFiles :: Term [FilePath]
9191
inputFiles = value $ posAny [] $ posInfo
9292
{ posDoc = "The input .ps files" }
9393

94-
tco :: Term Bool
95-
tco = value $ flag $ (optInfo [ "tco" ])
96-
{ optDoc = "Perform tail call optimizations" }
94+
noTco :: Term Bool
95+
noTco = value $ flag $ (optInfo [ "no-tco" ])
96+
{ optDoc = "Disable tail call optimizations" }
9797

9898
performRuntimeTypeChecks :: Term Bool
9999
performRuntimeTypeChecks = value $ flag $ (optInfo [ "runtime-type-checks" ])
@@ -103,9 +103,9 @@ noPrelude :: Term Bool
103103
noPrelude = value $ flag $ (optInfo [ "no-prelude" ])
104104
{ optDoc = "Omit the Prelude" }
105105

106-
magicDo :: Term Bool
107-
magicDo = value $ flag $ (optInfo [ "magic-do" ])
108-
{ optDoc = "Overload the do keyword to generate efficient code specifically for the Eff monad." }
106+
noMagicDo :: Term Bool
107+
noMagicDo = value $ flag $ (optInfo [ "no-magic-do" ])
108+
{ optDoc = "Disable the optimization that overloads the do keyword to generate efficient code specifically for the Eff monad." }
109109

110110
noOpts :: Term Bool
111111
noOpts = value $ flag $ (optInfo [ "no-opts" ])
@@ -116,7 +116,7 @@ browserNamespace = value $ opt "PS" $ (optInfo [ "browser-namespace" ])
116116
{ optDoc = "Specify the namespace that PureScript modules will be exported to when running in the browser." }
117117

118118
options :: 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 []
120120

121121
inputFilesAndPrelude :: FilePath -> Term [FilePath]
122122
inputFilesAndPrelude prelude = combine <$> (not <$> noPrelude) <*> inputFiles

psc/Main.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ externsFile :: Term (Maybe FilePath)
8686
externsFile = value $ opt Nothing $ (optInfo [ "e", "externs" ])
8787
{ optDoc = "The output .e.ps file" }
8888

89-
tco :: Term Bool
90-
tco = value $ flag $ (optInfo [ "tco" ])
91-
{ optDoc = "Perform tail call optimizations" }
89+
noTco :: Term Bool
90+
noTco = value $ flag $ (optInfo [ "no-tco" ])
91+
{ optDoc = "Disable tail call optimizations" }
9292

9393
performRuntimeTypeChecks :: Term Bool
9494
performRuntimeTypeChecks = value $ flag $ (optInfo [ "runtime-type-checks" ])
@@ -98,9 +98,9 @@ noPrelude :: Term Bool
9898
noPrelude = value $ flag $ (optInfo [ "no-prelude" ])
9999
{ optDoc = "Omit the Prelude" }
100100

101-
magicDo :: Term Bool
102-
magicDo = value $ flag $ (optInfo [ "magic-do" ])
103-
{ optDoc = "Overload the do keyword to generate efficient code specifically for the Eff monad." }
101+
noMagicDo :: Term Bool
102+
noMagicDo = value $ flag $ (optInfo [ "no-magic-do" ])
103+
{ optDoc = "Disable the optimization that overloads the do keyword to generate efficient code specifically for the Eff monad." }
104104

105105
runMain :: Term (Maybe String)
106106
runMain = value $ defaultOpt (Just "Main") Nothing $ (optInfo [ "main" ])
@@ -123,7 +123,7 @@ codeGenModules = value $ optAll [] $ (optInfo [ "codegen" ])
123123
{ optDoc = "A list of modules for which Javascript and externs should be generated. This argument can be used multiple times." }
124124

125125
options :: 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
127127

128128
stdInOrInputFiles :: FilePath -> Term (Maybe [FilePath])
129129
stdInOrInputFiles prelude = combine <$> useStdIn <*> (not <$> noPrelude) <*> inputFiles

src/Language/PureScript/Optimizer/MagicDo.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import Language.PureScript.Names
3030
import qualified Language.PureScript.Constants as C
3131

3232
magicDo :: Options -> JS -> JS
33-
magicDo opts | optionsMagicDo opts = inlineST . magicDo'
34-
| otherwise = id
33+
magicDo opts | optionsNoMagicDo opts = id
34+
| otherwise = inlineST . magicDo'
3535

3636
-- |
3737
-- Inline type class dictionaries for >>= and return for the Eff monad

src/Language/PureScript/Optimizer/TCO.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import Language.PureScript.CodeGen.JS.AST
2424
-- Eliminate tail calls
2525
--
2626
tco :: Options -> JS -> JS
27-
tco opts | optionsTco opts = tco'
28-
| otherwise = id
27+
tco opts | optionsNoTco opts = id
28+
| otherwise = tco'
2929

3030
tco' :: JS -> JS
3131
tco' = everywhere (mkT convert)

src/Language/PureScript/Options.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ module Language.PureScript.Options where
2020
--
2121
data Options = Options {
2222
-- |
23-
-- Perform tail-call elimination
23+
-- Disable tail-call elimination
2424
--
25-
optionsTco :: Bool
25+
optionsNoTco :: Bool
2626
-- |
2727
-- Perform type checks at runtime
2828
--
2929
, optionsPerformRuntimeTypeChecks :: Bool
3030
-- |
31-
-- Inline calls to ret and bind for the Eff monad
31+
-- Disable inlining of calls to return and bind for the Eff monad
3232
--
33-
, optionsMagicDo :: Bool
33+
, optionsNoMagicDo :: Bool
3434
-- |
3535
-- When specified, checks the type of `main` in the module, and generate a call to run main
3636
-- after the module definitions.

0 commit comments

Comments
 (0)