@@ -344,6 +344,8 @@ mkVecUpdate ity count [vec, B32 i, newElem] = updateVec vec newElem
344 updateVec (B16V v) (B16 e) = Just . B16V $ V.unsafeUpdate v (V.singleton (fromIntegral i, e))
344 updateVec (B16V v) (B16 e) = Just . B16V $ V.unsafeUpdate v (V.singleton (fromIntegral i, e))
345 updateVec (B32V v) (B32 e) = Just . B32V $ V.unsafeUpdate v (V.singleton (fromIntegral i, e))
345 updateVec (B32V v) (B32 e) = Just . B32V $ V.unsafeUpdate v (V.singleton (fromIntegral i, e))
346 updateVec (B64V v) (B64 e) = Just . B64V $ V.unsafeUpdate v (V.singleton (fromIntegral i, e))
346 updateVec (B64V v) (B64 e) = Just . B64V $ V.unsafeUpdate v (V.singleton (fromIntegral i, e))
347+ updateVec _ _ = Nothing
348+mkVecUpdate _ _ _ = Nothing
348aTyName :: ArithTy -> String
350aTyName :: ArithTy -> String
349aTyName (ATInt t) = intTyName t
351aTyName (ATInt t) = intTyName t
@@ -532,20 +534,22 @@ toInt ITNative x = I (fromIntegral x)
532toInt ITChar x = Ch (chr $ fromIntegral x)
534toInt ITChar x = Ch (chr $ fromIntegral x)
534intToInt :: IntTy -> IntTy -> [Const] -> Maybe Const
536intToInt :: 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
536intToInt (ITFixed IT16) out [B16 x] = Just $ toInt out x
538intToInt (ITFixed IT16) out [B16 x] = Just $ toInt out x
537intToInt (ITFixed IT32) out [B32 x] = Just $ toInt out x
539intToInt (ITFixed IT32) out [B32 x] = Just $ toInt out x
538intToInt (ITFixed IT64) out [B64 x] = Just $ toInt out x
540intToInt (ITFixed IT64) out [B64 x] = Just $ toInt out x
539−intToInt ITBig out [BI x] = Just $ toInt out x
541+intToInt ITBig out [BI x] = Just $ toInt out x
540−intToInt ITNative out [I x] = Just $ toInt out x
542+intToInt ITNative out [I x] = Just $ toInt out x
541−intToInt ITChar out [Ch x] = Just $ toInt out (ord x)
543+intToInt ITChar out [Ch x] = Just $ toInt out (ord x)
542intToInt _ _ _ = Nothing
544intToInt _ _ _ = Nothing
544zext :: IntTy -> IntTy -> [Const] -> Maybe Const
546zext :: IntTy -> IntTy -> [Const] -> Maybe Const
545zext from ITBig val = intToInt from ITBig val
547zext from ITBig val = intToInt from ITBig val
546zext ITBig _ _ = Nothing
548zext ITBig _ _ = Nothing
547−zext from to val
549+zext f@(ITFixed from) t@(ITFixed to) val
548− | intTyWidth from < intTyWidth to = intToInt from 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
549zext _ _ _ = Nothing
553zext _ _ _ = Nothing
551sext :: IntTy -> IntTy -> [Const] -> Maybe Const
555sext :: IntTy -> IntTy -> [Const] -> Maybe Const
@@ -559,7 +563,9 @@ sext from to val = intToInt from to val
559trunc :: IntTy -> IntTy -> [Const] -> Maybe Const
563trunc :: IntTy -> IntTy -> [Const] -> Maybe Const
560trunc ITBig to val = intToInt ITBig to val
564trunc ITBig to val = intToInt ITBig to val
561trunc _ ITBig _ = Nothing
565trunc _ 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
563trunc _ _ _ = Nothing
569trunc _ _ _ = Nothing
565intToStr :: [Const] -> Maybe Const
571intToStr :: [Const] -> Maybe Const