on master help sign in
Cleanup
commitaa42f713578182483639e3fca9598b5adbebce2c authorBenjamin Saunders <besaunde@sfu.ca> dateFri 12 Jul 2013, 16:16 (13 years ago) parentf0c1e19
1 file changed+13−7
src/Idris/Primitives.hs+13−7
src/Idris/Primitives.hs+13−7
@@ -344,6 +344,8 @@ mkVecUpdate ity count [vec, B32 i, newElem] = updateVec vec newElem
344344 updateVec (B16V v) (B16 e) = Just . B16V $ V.unsafeUpdate v (V.singleton (fromIntegral i, e))
345345 updateVec (B32V v) (B32 e) = Just . B32V $ V.unsafeUpdate v (V.singleton (fromIntegral i, e))
346346 updateVec (B64V v) (B64 e) = Just . B64V $ V.unsafeUpdate v (V.singleton (fromIntegral i, e))
347+ updateVec _ _ = Nothing
348+mkVecUpdate _ _ _ = Nothing
347349
348350aTyName :: ArithTy -> String
349351aTyName (ATInt t) = intTyName t
@@ -532,20 +534,22 @@ toInt ITNative x = I (fromIntegral x)
532534toInt ITChar x = Ch (chr $ fromIntegral x)
533535
534536intToInt :: IntTy -> IntTy -> [Const] -> Maybe Const
535−intToInt (ITFixed IT8) out [B8 x] = Just $ toInt out x
537+intToInt (ITFixed IT8) out [B8 x] = Just $ toInt out x
536538intToInt (ITFixed IT16) out [B16 x] = Just $ toInt out x
537539intToInt (ITFixed IT32) out [B32 x] = Just $ toInt out x
538540intToInt (ITFixed IT64) out [B64 x] = Just $ toInt out x
539−intToInt ITBig out [BI x] = Just $ toInt out x
540−intToInt ITNative out [I x] = Just $ toInt out x
541−intToInt ITChar out [Ch x] = Just $ toInt out (ord x)
541+intToInt ITBig out [BI x] = Just $ toInt out x
542+intToInt ITNative out [I x] = Just $ toInt out x
543+intToInt ITChar out [Ch x] = Just $ toInt out (ord x)
542544intToInt _ _ _ = Nothing
543545
544546zext :: IntTy -> IntTy -> [Const] -> Maybe Const
545547zext from ITBig val = intToInt from ITBig val
546548zext ITBig _ _ = Nothing
547−zext from to val
548− | intTyWidth from < intTyWidth to = intToInt from to val
549+zext f@(ITFixed from) t@(ITFixed to) val
550+ | nativeTyWidth from < nativeTyWidth to = intToInt f t val
551+zext ITNative to [I x] = Just $ toInt to (fromIntegral x :: Word)
552+zext from ITNative val = intToInt from ITNative val
549553zext _ _ _ = Nothing
550554
551555sext :: IntTy -> IntTy -> [Const] -> Maybe Const
@@ -559,7 +563,9 @@ sext from to val = intToInt from to val
559563trunc :: IntTy -> IntTy -> [Const] -> Maybe Const
560564trunc ITBig to val = intToInt ITBig to val
561565trunc _ ITBig _ = Nothing
562−trunc from to val | intTyWidth from > intTyWidth to = intToInt from to val
566+trunc f@(ITFixed from) t@(ITFixed to) val | nativeTyWidth from > nativeTyWidth to = intToInt f t val
567+trunc ITNative to [I x] = Just $ toInt to x
568+trunc from ITNative val = intToInt from ITNative val
563569trunc _ _ _ = Nothing
564570
565571intToStr :: [Const] -> Maybe Const