[project @ 1998-01-08 18:03:08 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 _readHandle IOHandle.readHandle
47 # define _writeHandle IOHandle.writeHandle
48 # define _newHandle   IOHandle.newdHandle
49 # define MkST ST
50 # if __GLASGOW_HASKELL__ >= 209
51 #  define STATE_TOK(x)    x
52 #  define ST_RET(x,y)     STret (y) (x)
53 #  define unsafePerformST(x)  runST (x)
54 #  define ST_TO_PrimIO(x) (stToIO (x))
55 # else
56 #  define STATE_TOK(x)  (S# x)
57 #  define ST_RET(x,y)   (x,y)
58 #  define unsafePerformST(x) unsafePerformPrimIO(x)
59 #  define ST_TO_PrimIO(x) x
60 # endif
61 # define failWith fail
62 # define MkIOError(h,errt,msg) (IOError (Just h) errt msg)
63 # define CCALL_THEN thenIO_Prim
64 # define _filePtr IOHandle.filePtr
65 # define Text Show
66 # define IMP_FASTSTRING() import FastString
67 # if __GLASGOW_HASKELL__ >= 209
68 #  define IMP_Ubiq() import GlaExts ; import Addr(Addr(..)); import FastString
69 #  define CHK_Ubiq() import GlaExts ; import Addr(Addr(..)); import FastString
70 # else
71 #  define IMP_Ubiq() import GlaExts ; import FastString
72 #  define CHK_Ubiq() import GlaExts ; import FastString
73 # endif
74 # define minInt (minBound::Int)
75 # define maxInt (maxBound::Int)
76 #else
77 # define STATE_TOK(x)  (S# x)
78 # define ST_RET(x,y)   (x,y)
79 # define unsafePerformST(x) unsafePerformPrimIO(x)
80 # define ST_TO_PrimIO(x) x
81 # define SYN_IE(a) a(..)
82 # define EXP_MODULE(a) a..
83 # define IMPORT_DELOOPER(mod) import mod
84 # define IMPORT_1_3(mod) {--}
85 # define IMP_FASTSTRING() import FastString
86 # define IMP_Ubiq() IMPORT_DELOOPER(Ubiq) ; import FastString
87 # define CHK_Ubiq() IMPORT_DELOOPER(Ubiq) ; import FastString
88 # define MkST
89 # define CCALL_THEN thenPrimIO
90 # define MkIOError(h,errt,msg) (errt msg)
91 #endif
92
93 #if defined(__GLASGOW_HASKELL__)
94
95 -- Import the beggars
96 import GlaExts  ( Int(..), Int#, (+#), (-#), (*#), 
97                   quotInt#, negateInt#, (==#), (<#), (<=#), (>=#), (>#)
98                 )
99
100 #define FAST_INT Int#
101 #define ILIT(x) (x#)
102 #define IBOX(x) (I# (x))
103 #define _ADD_ +#
104 #define _SUB_ -#
105 #define _MUL_ *#
106 #define _QUOT_ `quotInt#`
107 #define _NEG_ negateInt#
108 #define _EQ_ ==#
109 #define _LT_ <#
110 #define _LE_ <=#
111 #define _GE_ >=#
112 #define _GT_ >#
113
114 #define FAST_BOOL Int#
115 #define _TRUE_ 1#
116 #define _FALSE_ 0#
117 #define _IS_TRUE_(x) ((x) _EQ_ 1#)
118
119 #else {- ! __GLASGOW_HASKELL__ -}
120
121 #define FAST_INT Int
122 #define ILIT(x) (x)
123 #define IBOX(x) (x)
124 #define _ADD_ +
125 #define _SUB_ -
126 #define _MUL_ *
127 #define _DIV_ `div`
128 #define _QUOT_ `quot`
129 #define _NEG_ -
130 #define _EQ_ ==
131 #define _LT_ <
132 #define _LE_ <=
133 #define _GE_ >=
134 #define _GT_ >
135
136 #define FAST_BOOL Bool
137 #define _TRUE_ True
138 #define _FALSE_ False
139 #define _IS_TRUE_(x) (x)
140
141 #endif  {- ! __GLASGOW_HASKELL__ -}
142
143 #if __GLASGOW_HASKELL__ >= 23
144
145 -- This #ifndef lets us switch off the "import FastString"
146 -- when compiling FastString itself
147 #ifndef COMPILING_FAST_STRING
148 -- 
149 import FastString       ( FastString, mkFastString, mkFastCharString#, nullFastString, 
150                           consFS, headFS, tailFS, lengthFS, unpackFS, appendFS, concatFS
151                         )
152 #endif
153
154 # define USE_FAST_STRINGS 1
155 # define FAST_STRING    FastString
156 # define SLIT(x)        (mkFastCharString# (x#))
157 # define _NULL_         nullFastString
158 # define _NIL_          (mkFastString "")
159 # define _CONS_         consFS
160 # define _HEAD_         headFS
161 # define _TAIL_         tailFS
162 # define _LENGTH_       lengthFS
163 # define _PK_           mkFastString
164 # define _UNPK_         unpackFS
165 # define _APPEND_       `appendFS`
166 # define _CONCAT_       concatFS
167 #else
168 # define FAST_STRING String
169 # define SLIT(x)      (x)
170 # define _CMP_STRING_ cmpString
171 # define _NULL_       null
172 # define _NIL_        ""
173 # define _CONS_       (:)
174 # define _HEAD_       head
175 # define _TAIL_       tail
176 # define _LENGTH_     length
177 # define _PK_         (\x->x)
178 # define _UNPK_       (\x->x)
179 # define _SUBSTR_     substr{-from Utils-}
180 # define _APPEND_     ++
181 # define _CONCAT_     concat
182 #endif
183
184 #endif