From 2082a8557f8285ea48904d64ada0370c6fe7ef8a Mon Sep 17 00:00:00 2001 From: Ilya Rezvov Date: Mon, 15 Mar 2021 22:59:10 -0700 Subject: [PATCH] start multivalue proposal implementation for block instruction --- src/Language/Wasm/Validate.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Language/Wasm/Validate.hs b/src/Language/Wasm/Validate.hs index 1279fc6..fd3c18b 100644 --- a/src/Language/Wasm/Validate.hs +++ b/src/Language/Wasm/Validate.hs @@ -200,6 +200,20 @@ getResultType (TypeIndex typeIdx) = do ======= >>>>>>> 40291c3 (more grammar fixes) +getBlockType :: BlockType -> Checker Arrow +getBlockType (Inline Nothing) = return $ empty ==> empty +getBlockType (Inline (Just valType)) = return $ empty ==> valType +getBlockType (TypeIndex typeIdx) = do + Ctx { types } <- ask + maybeToEither TypeIndexOutOfRange $ asArrow <$> types !? typeIdx + +getResultType :: BlockType -> Checker [ValueType] +getResultType (Inline Nothing) = return [] +getResultType (Inline (Just valType)) = return [valType] +getResultType (TypeIndex typeIdx) = do + Ctx { types } <- ask + maybeToEither TypeIndexOutOfRange $ results <$> types !? typeIdx + getInstrType :: Instruction Natural -> Checker Arrow getInstrType Unreachable = return $ Any ==> Any getInstrType Nop = return $ empty ==> empty