From 952fa3bd97a5552ebbed8a6b933fef9b5d5b7908 Mon Sep 17 00:00:00 2001 From: Ilya Rezvov Date: Tue, 20 Mar 2018 16:17:10 -0700 Subject: [PATCH] add types for script extention --- src/Language/Wasm/Parser.y | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/Language/Wasm/Parser.y b/src/Language/Wasm/Parser.y index 4f8e4cd..7188fe2 100644 --- a/src/Language/Wasm/Parser.y +++ b/src/Language/Wasm/Parser.y @@ -1286,6 +1286,46 @@ data Module = Module { exports :: [Export] } deriving (Show, Eq) +type Script = [Command] + +type Expression = [Instruction] + +data ModuleDef + = RawModDef Module + | TextModDef (Maybe TL.Text) [TL.Text] + | BinaryModDef (Maybe TL.Text) [TL.Text] + deriving (Show, Eq) + +data Command + = ModuleDef ModuleDef + | Action + | Assertion + | Meta + deriving (Show, Eq) + +data Action + = Invoke (Maybe TL.Text) TL.Text [Expression] + | Get (Maybe TL.Text) TL.Text + deriving (Show, Eq) + +type FailureString = TL.Text + +data Assertion + = AssertReturn Action Instruction + | AssertReturnCanonicalNaN Action + | AssertReturnArithmeticNaN Action + | AssertTrap (Either Action ModuleDef) FailureString + | AssertMalformed ModuleDef FailureString + | AssertInvalid ModuleDef FailureString + | AssertUnlinkable ModuleDef FailureString + deriving (Show, Eq) + +data Meta + = Script (Maybe TL.Text) Script + | Input (Maybe TL.Text) TL.Text + | Output (Maybe TL.Text) TL.Text + deriving (Show, Eq) + type Labels = [Maybe Ident] data FunCtx = FunCtx {