@@ -41,7 +41,8 @@ module Language.Wasm.Builder (
41
41
memorySize , growMemory ,
42
42
nop , Language.Wasm.Builder. drop , select ,
43
43
call , callIndirect , finish , br , brIf , brTable ,
44
- {- if', loop, block, when, for, while,-}
44
+ if' ,
45
+ {- , loop, block, when, for, while,-}
45
46
trap , unreachable ,
46
47
appendExpr , after ,
47
48
Producer , OutType , produce , Consumer , (.=)
@@ -51,7 +52,7 @@ import Prelude hiding (and, or)
51
52
import qualified Data.List as List
52
53
import qualified Data.Maybe as Maybe
53
54
import Control.Monad.State (State , execState , get , gets , put , modify )
54
- import Control.Monad.Reader (ReaderT , ask , runReaderT )
55
+ import Control.Monad.Reader (ReaderT , ask , asks , runReaderT )
55
56
import Numeric.Natural
56
57
import Data.Word (Word32 , Word64 )
57
58
import Data.Int (Int32 , Int64 )
@@ -709,17 +710,17 @@ while pred body = do
709
710
label :: GenFun (Label t )
710
711
label = Label <$> ask
711
712
712
- -- if' :: (Producer pred, OutType pred ~ Proxy I32, Returnable res)
713
- -- => res
714
- -- -> pred
715
- -- -> GenFun res
716
- -- -> GenFun res
717
- -- -> GenFun res
718
- -- if' res pred true false = do
719
- -- produce pred
720
- -- deep <- (+1) <$> ask
721
- -- appendExpr [If (asResultValue res) (genExpr deep $ true) (genExpr deep $ false)]
722
- -- return returnableValue
713
+ if' :: (Producer pred , OutType pred ~ Proxy I32 , Returnable res )
714
+ => BlockType
715
+ -> pred
716
+ -> GenFun res
717
+ -> GenFun res
718
+ -> GenFun res
719
+ if' blockType pred true false = do
720
+ produce pred
721
+ deep <- asks (+ 1 )
722
+ appendExpr [If blockType (genExpr deep true) (genExpr deep false)]
723
+ return returnableValue
723
724
724
725
-- loop :: (Returnable res) => res -> GenFun res -> GenFun res
725
726
-- loop res body = do
0 commit comments