From d055a4ff6d3d4759cac58f1600a357006e865c6e Mon Sep 17 00:00:00 2001 From: Ilya Rezvov Date: Mon, 9 Apr 2018 21:41:17 -0700 Subject: [PATCH] fix call_indirect evaluation --- src/Language/Wasm/Interpreter.hs | 2 +- tests/Test.hs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Language/Wasm/Interpreter.hs b/src/Language/Wasm/Interpreter.hs index df15322..79b466d 100644 --- a/src/Language/Wasm/Interpreter.hs +++ b/src/Language/Wasm/Interpreter.hs @@ -572,7 +572,7 @@ eval store FunctionInstance { funcType, moduleInstance, code = Function { localT return $ Done ctx { stack = reverse res ++ (drop (length args) $ stack ctx) } step ctx@EvalCtx{ stack = (VI32 v): rest } (CallIndirect typeIdx) = do let funcType = funcTypes moduleInstance ! fromIntegral typeIdx - let TableInstance { elements } = tableInstances store ! (tableaddrs moduleInstance ! fromIntegral v) + let TableInstance { elements } = tableInstances store ! (tableaddrs moduleInstance ! 0) let funcAddr = elements !? fromIntegral v case funcAddr of Just (Just addr) -> do diff --git a/tests/Test.hs b/tests/Test.hs index 2c8073b..56a49f1 100644 --- a/tests/Test.hs +++ b/tests/Test.hs @@ -34,7 +34,7 @@ compile file = do main :: IO () main = do files <- Directory.listDirectory "tests/samples" - let files = ["linking.wast"] + -- let files = ["linking.wast"] scriptTestCases <- (`mapM` files) $ \file -> do content <- LBS.readFile $ "tests/samples/" ++ file let Right script = Parser.parseScript <$> Lexer.scanner content