This repository was archived by the owner on Nov 1, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlagOpts.hs
140 lines (134 loc) · 8.5 KB
/
FlagOpts.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
module FlagOpts(Flag(..),process,helpMsg,helpFlags) where
import qualified Data.Set as Set
-- | Flags
data Flag =
BangPatterns -- ^ - bang patterns
| Boehm -- ^ use Boehm garbage collector
| Controlled -- ^ with the '-f' flag, the following options are availible, you can
| Cpp -- ^ pass haskell source through c preprocessor
| Debug -- ^ enable debugging code in generated executable
| Defaulting -- ^ perform defaulting of ambiguous types
| Exists -- ^ exists keyword for existential types recognized
| Ffi -- ^ support foreign function declarations
| Forall -- ^ forall keyword for rank-n types and explicit quantification
| FullInt -- ^ extend Int and Word to 32 bits on a 32 bit machine (rather than 30)
| GlobalOptimize -- ^ perform whole program E optimization
| InlinePragmas -- ^ use inline pragmas
| Jgc -- ^ use the jgc garbage collector
| Lint -- ^ perform lots of extra type checks
| M4 -- ^ pass haskell source through m4 preprocessor
| MonomorphismRestriction -- ^ enforce monomorphism restriction
| Negate -- ^ any particular one by prepending 'no-' to it.
| Prelude -- ^ implicitly import Prelude
| Profile -- ^ enable profiling code in generated executable
| Raw -- ^ just evaluate main to WHNF and nothing else.
| Rules -- ^ use rules
| Standalone -- ^ compile to a standalone executable
| Sugar -- ^ disable all desugarings, only unboxed literals allowed.
| TypeAnalysis -- ^ perform a basic points-to analysis on types right after method generation
| TypeFamilies -- ^ type\/data family support
| UnboxedTuples -- ^ allow unboxed tuple syntax to be recognized
| UnboxedValues -- ^ allow unboxed value syntax
| UserKinds -- ^ user defined kinds
| Wrapper -- ^ wrap main in exception handler
| Never -- ^ Will never be set
deriving(Eq,Ord,Bounded)
instance Show Flag where
show BangPatterns = "bang-patterns"
show Boehm = "boehm"
show Controlled = "controlled"
show Cpp = "cpp"
show Debug = "debug"
show Defaulting = "defaulting"
show Exists = "exists"
show Ffi = "ffi"
show Forall = "forall"
show FullInt = "full-int"
show GlobalOptimize = "global-optimize"
show InlinePragmas = "inline-pragmas"
show Jgc = "jgc"
show Lint = "lint"
show M4 = "m4"
show MonomorphismRestriction = "monomorphism-restriction"
show Negate = "negate"
show Prelude = "prelude"
show Profile = "profile"
show Raw = "raw"
show Rules = "rules"
show Standalone = "standalone"
show Sugar = "sugar"
show TypeAnalysis = "type-analysis"
show TypeFamilies = "type-families"
show UnboxedTuples = "unboxed-tuples"
show UnboxedValues = "unboxed-values"
show UserKinds = "user-kinds"
show Wrapper = "wrapper"
show Never = "never"
one "bang-patterns" = Right $ Set.insert BangPatterns
one "no-bang-patterns" = Right $ Set.delete BangPatterns
one "boehm" = Right $ Set.insert Boehm
one "no-boehm" = Right $ Set.delete Boehm
one "controlled" = Right $ Set.insert Controlled
one "no-controlled" = Right $ Set.delete Controlled
one "cpp" = Right $ Set.insert Cpp
one "no-cpp" = Right $ Set.delete Cpp
one "debug" = Right $ Set.insert Debug
one "no-debug" = Right $ Set.delete Debug
one "default" = Right $ foldr (.) id [ f | Right f <- [ one "inline-pragmas",one "rules",one "wrapper",one "defaulting",one "type-analysis",one "monomorphism-restriction",one "global-optimize",one "full-int",one "prelude",one "sugar"]]
one "defaulting" = Right $ Set.insert Defaulting
one "no-defaulting" = Right $ Set.delete Defaulting
one "exists" = Right $ Set.insert Exists
one "no-exists" = Right $ Set.delete Exists
one "ffi" = Right $ Set.insert Ffi
one "no-ffi" = Right $ Set.delete Ffi
one "forall" = Right $ Set.insert Forall
one "no-forall" = Right $ Set.delete Forall
one "full-int" = Right $ Set.insert FullInt
one "no-full-int" = Right $ Set.delete FullInt
one "glasgow-exts" = Right $ foldr (.) id [ f | Right f <- [ one "forall",one "ffi",one "unboxed-tuples"]]
one "global-optimize" = Right $ Set.insert GlobalOptimize
one "no-global-optimize" = Right $ Set.delete GlobalOptimize
one "inline-pragmas" = Right $ Set.insert InlinePragmas
one "no-inline-pragmas" = Right $ Set.delete InlinePragmas
one "jgc" = Right $ Set.insert Jgc
one "no-jgc" = Right $ Set.delete Jgc
one "lint" = Right $ Set.insert Lint
one "no-lint" = Right $ Set.delete Lint
one "m4" = Right $ Set.insert M4
one "no-m4" = Right $ Set.delete M4
one "monomorphism-restriction" = Right $ Set.insert MonomorphismRestriction
one "no-monomorphism-restriction" = Right $ Set.delete MonomorphismRestriction
one "negate" = Right $ Set.insert Negate
one "no-negate" = Right $ Set.delete Negate
one "prelude" = Right $ Set.insert Prelude
one "no-prelude" = Right $ Set.delete Prelude
one "profile" = Right $ Set.insert Profile
one "no-profile" = Right $ Set.delete Profile
one "raw" = Right $ Set.insert Raw
one "no-raw" = Right $ Set.delete Raw
one "rules" = Right $ Set.insert Rules
one "no-rules" = Right $ Set.delete Rules
one "standalone" = Right $ Set.insert Standalone
one "no-standalone" = Right $ Set.delete Standalone
one "sugar" = Right $ Set.insert Sugar
one "no-sugar" = Right $ Set.delete Sugar
one "type-analysis" = Right $ Set.insert TypeAnalysis
one "no-type-analysis" = Right $ Set.delete TypeAnalysis
one "type-families" = Right $ Set.insert TypeFamilies
one "no-type-families" = Right $ Set.delete TypeFamilies
one "unboxed-tuples" = Right $ Set.insert UnboxedTuples
one "no-unboxed-tuples" = Right $ Set.delete UnboxedTuples
one "unboxed-values" = Right $ Set.insert UnboxedValues
one "no-unboxed-values" = Right $ Set.delete UnboxedValues
one "user-kinds" = Right $ Set.insert UserKinds
one "no-user-kinds" = Right $ Set.delete UserKinds
one "wrapper" = Right $ Set.insert Wrapper
one "no-wrapper" = Right $ Set.delete Wrapper
one x = Left x
{-# NOINLINE process #-}
process s xs = foldr f (s,[]) (map one xs) where
f (Right g) (s,xs) = (g s,xs)
f (Left x) (s,xs) = (s,x:xs)
{-# NOINLINE helpMsg #-}
helpMsg = "\n-- Code options --\nbang-patterns - bang patterns\ncpp pass haskell source through c preprocessor\nexists exists keyword for existential types recognized\nffi support foreign function declarations\nforall forall keyword for rank-n types and explicit\n quantification\nm4 pass haskell source through m4 preprocessor\nprelude implicitly import Prelude\nsugar disable all desugarings, only unboxed literals allowed.\ntype-families type/data family support\nunboxed-tuples allow unboxed tuple syntax to be recognized\nunboxed-values allow unboxed value syntax\nuser-kinds user defined kinds\n\n-- Typechecking --\ndefaulting perform defaulting of ambiguous types\nmonomorphism-restriction enforce monomorphism restriction\n\n-- Debugging --\nlint perform lots of extra type checks\n\n-- Optimization Options --\nglobal-optimize perform whole program E optimization\ninline-pragmas use inline pragmas\nrules use rules\ntype-analysis perform a basic points-to analysis on types right after\n method generation\n\n-- Code Generation --\nboehm use Boehm garbage collector\ndebug enable debugging code in generated executable\nfull-int extend Int and Word to 32 bits on a 32 bit machine\n (rather than 30)\njgc use the jgc garbage collector\nprofile enable profiling code in generated executable\nraw just evaluate main to WHNF and nothing else.\nstandalone compile to a standalone executable\nwrapper wrap main in exception handler\n\n-- Default settings --\ndefault inline-pragmas rules wrapper defaulting type-analysis\n monomorphism-restriction global-optimize full-int\n prelude sugar\nglasgow-exts forall ffi unboxed-tuples\n"
helpFlags = ["bang-patterns", "boehm", "controlled", "cpp", "debug", "default", "defaulting", "exists", "ffi", "forall", "full-int", "glasgow-exts", "global-optimize", "inline-pragmas", "jgc", "lint", "m4", "monomorphism-restriction", "negate", "prelude", "profile", "raw", "rules", "standalone", "sugar", "type-analysis", "type-families", "unboxed-tuples", "unboxed-values", "user-kinds", "wrapper"]