[project @ 2000-09-05 09:14:15 by simonmar]
[ghc-hetmet.git] / ghc / compiler / HsVersions.h
1 #ifndef HSVERSIONS_H
2 #define HSVERSIONS_H
3
4 #if 0
5
6 IMPORTANT!  If you put extra tabs/spaces in these macro definitions,
7 you will screw up the layout where they are used in case expressions!
8
9 (This is cpp-dependent, of course)
10
11 #endif
12
13 #define COMMA ,
14
15 #ifdef DEBUG
16 #define ASSERT(e) if (not (e)) then (assertPanic __FILE__ __LINE__) else
17 #define ASSERT2(e,msg) if (not (e)) then (assertPprPanic __FILE__ __LINE__ (msg)) else
18 #define WARN( e, msg ) (warnPprTrace (e) __FILE__ __LINE__ (msg))
19 #else
20 #define ASSERT(e)
21 #define ASSERT2(e,msg)
22 #define WARN(e,msg)
23 #endif
24
25 #if __STDC__
26 #define CAT2(a,b)a##b
27 #else
28 #define CAT2(a,b)a/**/b
29 #endif
30
31 #if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 202
32 # define failWith fail
33 # define MkIOError(h,errt,msg) (IOError (Just h) errt msg)
34 # define minInt (minBound::Int)
35 # define maxInt (maxBound::Int)
36 #else
37 # define MkIOError(h,errt,msg) (errt msg)
38 #endif
39
40 #if defined(__GLASGOW_HASKELL__)
41
42 -- Import the beggars
43 import GlaExts
44         ( Int(..), Int#, (+#), (-#), (*#), 
45           quotInt#, negateInt#, (==#), (<#), (<=#), (>=#), (>#)
46         )
47
48 #define FAST_INT Int#
49 #define ILIT(x) (x#)
50 #define IBOX(x) (I# (x))
51 #define _ADD_ +#
52 #define _SUB_ -#
53 #define _MUL_ *#
54 #define _QUOT_ `quotInt#`
55 #define _NEG_ negateInt#
56 #define _EQ_ ==#
57 #define _LT_ <#
58 #define _LE_ <=#
59 #define _GE_ >=#
60 #define _GT_ >#
61
62 #define FAST_BOOL Int#
63 #define _TRUE_ 1#
64 #define _FALSE_ 0#
65 #define _IS_TRUE_(x) ((x) _EQ_ 1#)
66
67 #else {- ! __GLASGOW_HASKELL__ -}
68
69 #define FAST_INT Int
70 #define ILIT(x) (x)
71 #define IBOX(x) (x)
72 #define _ADD_ +
73 #define _SUB_ -
74 #define _MUL_ *
75 #define _DIV_ `div`
76 #define _QUOT_ `quot`
77 #define _NEG_ -
78 #define _EQ_ ==
79 #define _LT_ <
80 #define _LE_ <=
81 #define _GE_ >=
82 #define _GT_ >
83
84 #define FAST_BOOL Bool
85 #define _TRUE_ True
86 #define _FALSE_ False
87 #define _IS_TRUE_(x) (x)
88
89 #endif  {- ! __GLASGOW_HASKELL__ -}
90
91 #if __GLASGOW_HASKELL__ >= 23
92
93 -- This #ifndef lets us switch off the "import FastString"
94 -- when compiling FastString itself
95 #ifndef COMPILING_FAST_STRING
96 -- 
97 import qualified FastString 
98 #endif
99
100 # define USE_FAST_STRINGS 1
101 # define FAST_STRING    FastString.FastString
102 # define SLIT(x)        (FastString.mkFastCharString# (x#))
103 # define _NULL_         FastString.nullFastString
104 # define _NIL_          (FastString.mkFastString "")
105 # define _CONS_         FastString.consFS
106 # define _HEAD_         FastString.headFS
107 # define _HEAD_INT_     FastString.headIntFS
108 # define _TAIL_         FastString.tailFS
109 # define _LENGTH_       FastString.lengthFS
110 # define _PK_           FastString.mkFastString
111 # define _PK_INT_       FastString.mkFastStringInt
112 # define _UNPK_         FastString.unpackFS
113 # define _UNPK_INT_     FastString.unpackIntFS
114 # define _APPEND_       `FastString.appendFS`
115 # define _CONCAT_       FastString.concatFS
116 #else
117 # error I think that FastString is now always used. If not, fix this.
118 # define FAST_STRING String
119 # define SLIT(x)      (x)
120 # define _CMP_STRING_ cmpString
121 # define _NULL_       null
122 # define _NIL_        ""
123 # define _CONS_       (:)
124 # define _HEAD_       head
125 # define _TAIL_       tail
126 # define _LENGTH_     length
127 # define _PK_         (\x->x)
128 # define _UNPK_       (\x->x)
129 # define _SUBSTR_     substr{-from Utils-}
130 # define _APPEND_     ++
131 # define _CONCAT_     concat
132 #endif
133
134 #if __HASKELL1__ > 4
135 # define FMAP fmap
136 # define ISALPHANUM isAlphaNum
137 # define IOERROR ioError
138 # define PSEQ seq
139 # define SAPPLY $!
140 #else
141 # define FMAP map
142 # define ISALPHANUM isAlphanum
143 # define IOERROR fail
144 # define PSEQ (\x y -> y)
145 # define SAPPLY $
146 #endif
147
148 #endif