[project @ 1998-02-03 17:13:54 by simonm]
[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 #else
19 #define ASSERT(e)
20 #define ASSERT2(e,msg)
21 #endif
22
23 #if __STDC__
24 #define CAT2(a,b)a##b
25 #else
26 #define CAT2(a,b)a/**/b
27 #endif
28
29 #if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 202
30 # define REALLY_HASKELL_1_3
31 # define SYN_IE(a) a
32 # define EXP_MODULE(a) module a
33 # define IMPORT_DELOOPER(mod) import mod
34 # define IMPORT_1_3(mod) import mod
35 # define _Addr Addr
36 # define _ByteArray GlaExts.ByteArray
37 # define _MutableByteArray GlaExts.MutableByteArray
38 # define _MutableArray GlaExts.MutableArray
39 # define _RealWorld GlaExts.RealWorld
40 # define _ST GlaExts.ST
41 # define _ForeignObj Foreign.ForeignObj
42 # define _runST ST.runST
43 # define seqStrictlyST seqST
44 # define thenStrictlyST thenST
45 # define returnStrictlyST return
46 # define MkST ST
47 # if __GLASGOW_HASKELL__ >= 209
48 #  define STATE_TOK(x)    x
49 #  define ST_RET(x,y)     STret (y) (x)
50 #  define unsafePerformST(x)  runST (x)
51 #  define ST_TO_PrimIO(x) (stToIO (x))
52 # else
53 #  define STATE_TOK(x)  (S# x)
54 #  define ST_RET(x,y)   (x,y)
55 #  define unsafePerformST(x) unsafePerformPrimIO(x)
56 #  define ST_TO_PrimIO(x) x
57 # endif
58 # define failWith fail
59 # define MkIOError(h,errt,msg) (IOError (Just h) errt msg)
60 # define CCALL_THEN thenIO_Prim
61 # define Text Show
62 # define IMP_FASTSTRING() import FastString
63 # if __GLASGOW_HASKELL__ >= 209
64 #  define IMP_Ubiq() import GlaExts ; import Addr(Addr(..)); import FastString
65 #  define CHK_Ubiq() import GlaExts ; import Addr(Addr(..)); import FastString
66 # else
67 #  define IMP_Ubiq() import GlaExts ; import FastString
68 #  define CHK_Ubiq() import GlaExts ; import FastString
69 # endif
70 # define minInt (minBound::Int)
71 # define maxInt (maxBound::Int)
72 #else
73 # define STATE_TOK(x)  (S# x)
74 # define ST_RET(x,y)   (x,y)
75 # define unsafePerformST(x) unsafePerformPrimIO(x)
76 # define ST_TO_PrimIO(x) x
77 # define SYN_IE(a) a(..)
78 # define EXP_MODULE(a) a..
79 # define IMPORT_DELOOPER(mod) import mod
80 # define IMPORT_1_3(mod) {--}
81 # define IMP_FASTSTRING() import FastString
82 # define IMP_Ubiq() IMPORT_DELOOPER(Ubiq) ; import FastString
83 # define CHK_Ubiq() IMPORT_DELOOPER(Ubiq) ; import FastString
84 # define MkST
85 # define CCALL_THEN thenPrimIO
86 # define MkIOError(h,errt,msg) (errt msg)
87 #endif
88
89 #if defined(__GLASGOW_HASKELL__)
90
91 -- Import the beggars
92 import GlaExts
93         ( Int(..), Int#, (+#), (-#), (*#), 
94           quotInt#, negateInt#, (==#), (<#), (<=#), (>=#), (>#)
95         )
96
97 #define FAST_INT Int#
98 #define ILIT(x) (x#)
99 #define IBOX(x) (I# (x))
100 #define _ADD_ +#
101 #define _SUB_ -#
102 #define _MUL_ *#
103 #define _QUOT_ `quotInt#`
104 #define _NEG_ negateInt#
105 #define _EQ_ ==#
106 #define _LT_ <#
107 #define _LE_ <=#
108 #define _GE_ >=#
109 #define _GT_ >#
110
111 #define FAST_BOOL Int#
112 #define _TRUE_ 1#
113 #define _FALSE_ 0#
114 #define _IS_TRUE_(x) ((x) _EQ_ 1#)
115
116 #else {- ! __GLASGOW_HASKELL__ -}
117
118 #define FAST_INT Int
119 #define ILIT(x) (x)
120 #define IBOX(x) (x)
121 #define _ADD_ +
122 #define _SUB_ -
123 #define _MUL_ *
124 #define _DIV_ `div`
125 #define _QUOT_ `quot`
126 #define _NEG_ -
127 #define _EQ_ ==
128 #define _LT_ <
129 #define _LE_ <=
130 #define _GE_ >=
131 #define _GT_ >
132
133 #define FAST_BOOL Bool
134 #define _TRUE_ True
135 #define _FALSE_ False
136 #define _IS_TRUE_(x) (x)
137
138 #endif  {- ! __GLASGOW_HASKELL__ -}
139
140 #if __GLASGOW_HASKELL__ >= 23
141
142 -- This #ifndef lets us switch off the "import FastString"
143 -- when compiling FastString itself
144 #ifndef COMPILING_FAST_STRING
145 -- 
146 import qualified FastString 
147 #endif
148
149 # define USE_FAST_STRINGS 1
150 # define FAST_STRING    FastString.FastString
151 # define SLIT(x)        (FastString.mkFastCharString# (x#))
152 # define _NULL_         FastString.nullFastString
153 # define _NIL_          (FastString.mkFastString "")
154 # define _CONS_         FastString.consFS
155 # define _HEAD_         FastString.headFS
156 # define _TAIL_         FastString.tailFS
157 # define _LENGTH_       FastString.lengthFS
158 # define _PK_           FastString.mkFastString
159 # define _UNPK_         FastString.unpackFS
160 # define _APPEND_       `FastString.appendFS`
161 # define _CONCAT_       FastString.concatFS
162 #else
163 # define FAST_STRING String
164 # define SLIT(x)      (x)
165 # define _CMP_STRING_ cmpString
166 # define _NULL_       null
167 # define _NIL_        ""
168 # define _CONS_       (:)
169 # define _HEAD_       head
170 # define _TAIL_       tail
171 # define _LENGTH_     length
172 # define _PK_         (\x->x)
173 # define _UNPK_       (\x->x)
174 # define _SUBSTR_     substr{-from Utils-}
175 # define _APPEND_     ++
176 # define _CONCAT_     concat
177 #endif
178
179 #endif