fix arguments order on function call

This commit is contained in:
Ilya Rezvov
2018-04-10 09:17:26 -07:00
parent 147f4224d3
commit f4e008ab9a
3 changed files with 7 additions and 3 deletions
+2 -2
View File
@@ -570,7 +570,7 @@ eval store FunctionInstance { funcType, moduleInstance, code = Function { localT
let funInst = funcInstances store ! (funcaddrs moduleInstance ! fromIntegral fun)
let ft = Language.Wasm.Interpreter.funcType funInst
let args = params ft
res <- eval store funInst (zipWith checkValType args $ take (length args) $ stack ctx)
res <- eval store funInst (zipWith checkValType args $ reverse $ take (length args) $ stack ctx)
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
@@ -579,7 +579,7 @@ eval store FunctionInstance { funcType, moduleInstance, code = Function { localT
case funcAddr of
Just (Just addr) -> do
let args = params funcType
res <- invoke store addr (zipWith checkValType args $ take (length args) rest)
res <- invoke store addr (zipWith checkValType args $ reverse $ take (length args) rest)
return $ Done ctx { stack = reverse res ++ (drop (length args) rest) }
_ -> return Trap
step ctx@EvalCtx{ stack = (_:rest) } Drop = return $ Done ctx { stack = rest }