From 85dfac08f1a2b9d5f89d61e98c4ab05442263544 Mon Sep 17 00:00:00 2001 From: Ilya Rezvov Date: Sat, 2 Jun 2018 10:57:49 -0700 Subject: [PATCH] enforce type constraints for conversion operations --- src/Language/Wasm/Builder.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Language/Wasm/Builder.hs b/src/Language/Wasm/Builder.hs index a1f5dc8..42a4cb9 100644 --- a/src/Language/Wasm/Builder.hs +++ b/src/Language/Wasm/Builder.hs @@ -430,13 +430,13 @@ wrap big = do appendExpr [I32WrapI64] return Proxy -trunc_u :: (Producer f, IsInt (Proxy t) ~ True, ValueTypeable t) => Proxy t -> f -> GenFun (Proxy t) +trunc_u :: (Producer f, IsFloat (OutType f) ~ True, IsInt (Proxy t) ~ True, ValueTypeable t) => Proxy t -> f -> GenFun (Proxy t) trunc_u t float = do produce float appendExpr [ITruncFU (getSize $ getValueType t) (getSize $ asValueType float)] return Proxy -trunc_s :: (Producer f, IsInt (Proxy t) ~ True, ValueTypeable t) => Proxy t -> f -> GenFun (Proxy t) +trunc_s :: (Producer f, IsFloat (OutType f) ~ True, IsInt (Proxy t) ~ True, ValueTypeable t) => Proxy t -> f -> GenFun (Proxy t) trunc_s t float = do produce float appendExpr [ITruncFU (getSize $ getValueType t) (getSize $ asValueType float)] @@ -454,13 +454,13 @@ extend_s small = do appendExpr [I64ExtendUI32] return Proxy -convert_u :: (Producer f, IsFloat (Proxy t) ~ True, ValueTypeable t) => Proxy t -> f -> GenFun (Proxy t) +convert_u :: (Producer i, IsInt (OutType i) ~ True, IsFloat (Proxy t) ~ True, ValueTypeable t) => Proxy t -> i -> GenFun (Proxy t) convert_u t int = do produce int appendExpr [FConvertIU (getSize $ getValueType t) (getSize $ asValueType int)] return Proxy -convert_s :: (Producer f, IsFloat (Proxy t) ~ True, ValueTypeable t) => Proxy t -> f -> GenFun (Proxy t) +convert_s :: (Producer i, IsInt (OutType i) ~ True, IsFloat (Proxy t) ~ True, ValueTypeable t) => Proxy t -> i -> GenFun (Proxy t) convert_s t int = do produce int appendExpr [FConvertIS (getSize $ getValueType t) (getSize $ asValueType int)]