@@ -44,18 +44,15 @@ data AlexAddr = AlexA# Addr#
4444{-# INLINE alexIndexInt16OffAddr #-}
4545alexIndexInt16OffAddr :: AlexAddr -> Int # -> Int #
4646alexIndexInt16OffAddr (AlexA # arr) off =
47- #ifdef WORDS_BIGENDIAN
48- narrow16Int# i
49- where
50- i = word2Int# ((high `uncheckedShiftL# ` 8 # ) `or # ` low)
51- high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1 # )))
52- low = int2Word# (ord# (indexCharOffAddr# arr off'))
53- off' = off *# 2 #
54- #else
5547#if __GLASGOW_HASKELL__ >= 901
56- GHC.Exts. int16ToInt#
48+ GHC.Exts. int16ToInt# -- qualified import because it doesn't exist on older GHC's
5749#endif
58- (indexInt16OffAddr# arr off)
50+ #ifdef WORDS_BIGENDIAN
51+ (GHC.Exts. word16ToInt16# (GHC.Exts. wordToWord16# (GHC.Exts. byteSwap16# (GHC.Exts. word16ToWord# (GHC.Exts. int16ToWord16#
52+ #endif
53+ (indexInt16OffAddr# arr off)
54+ #ifdef WORDS_BIGENDIAN
55+ )))))
5956#endif
6057#else
6158alexIndexInt16OffAddr = (Data.Array. !)
@@ -65,22 +62,15 @@ alexIndexInt16OffAddr = (Data.Array.!)
6562{-# INLINE alexIndexInt32OffAddr #-}
6663alexIndexInt32OffAddr :: AlexAddr -> Int # -> Int #
6764alexIndexInt32OffAddr (AlexA # arr) off =
68- #ifdef WORDS_BIGENDIAN
69- narrow32Int# i
70- where
71- i = word2Int# ((b3 `uncheckedShiftL# ` 24 # ) `or # `
72- (b2 `uncheckedShiftL# ` 16 # ) `or # `
73- (b1 `uncheckedShiftL# ` 8 # ) `or # ` b0)
74- b3 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 3 # )))
75- b2 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 2 # )))
76- b1 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1 # )))
77- b0 = int2Word# (ord# (indexCharOffAddr# arr off'))
78- off' = off *# 4 #
79- #else
8065#if __GLASGOW_HASKELL__ >= 901
81- GHC.Exts. int32ToInt#
66+ GHC.Exts. int32ToInt# -- qualified import because it doesn't exist on older GHC's
8267#endif
83- (indexInt32OffAddr# arr off)
68+ #ifdef WORDS_BIGENDIAN
69+ (GHC.Exts. word32ToInt32# (GHC.Exts. wordToWord32# (GHC.Exts. byteSwap32# (GHC.Exts. word32ToWord# (GHC.Exts. int32ToWord32#
70+ #endif
71+ (indexInt32OffAddr# arr off)
72+ #ifdef WORDS_BIGENDIAN
73+ )))))
8474#endif
8575#else
8676alexIndexInt32OffAddr = (Data.Array. !)
0 commit comments