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