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