forked from GitHub/haskell-wasm
fix elems validator
This commit is contained in:
@@ -56,7 +56,8 @@ runScript onAssertFail script = do
|
||||
("global_i32", globI32),
|
||||
("global_f32", globF32),
|
||||
("global_f64", globF64),
|
||||
("memory", Interpreter.HostMemory $ Struct.Limit 1 (Just 2))
|
||||
("memory", Interpreter.HostMemory $ Struct.Limit 1 (Just 2)),
|
||||
("table", Interpreter.HostTable $ Struct.Limit 10 (Just 20))
|
||||
]
|
||||
go script $ emptyState { store = st, moduleRegistery = Map.singleton "spectest" inst }
|
||||
where
|
||||
|
||||
@@ -539,7 +539,8 @@ elemsShouldBeValid m@Module { elems, functions, tables, imports } =
|
||||
then Valid
|
||||
else IndexOutOfRange
|
||||
in
|
||||
let funsLength = fromIntegral $ length functions in
|
||||
let funImports = filter isFuncImport imports in
|
||||
let funsLength = fromIntegral $ length functions + length funImports in
|
||||
let isFunsValid = foldMap (\i -> if i < funsLength then Valid else IndexOutOfRange) funs in
|
||||
isIniterValid <> isFunsValid <> isTableIndexValid
|
||||
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ compile file = do
|
||||
main :: IO ()
|
||||
main = do
|
||||
files <- Directory.listDirectory "tests/samples"
|
||||
-- let files = ["linking.wast"]
|
||||
-- let files = ["imports.wast"]
|
||||
scriptTestCases <- (`mapM` files) $ \file -> do
|
||||
content <- LBS.readFile $ "tests/samples/" ++ file
|
||||
let Right script = Parser.parseScript <$> Lexer.scanner content
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
;; (func (import "spectest" "print_i64") (param i64))
|
||||
(import "spectest" "print_i32" (func $print_i32 (param i32)))
|
||||
;; JavaScript can't handle i64 yet.
|
||||
;; (import "spectest" "print_i64" (func $print_i64 (param i64)))
|
||||
(import "spectest" "print_i64" (func $print_i64 (param i64)))
|
||||
(import "spectest" "print_f32" (func $print_f32 (param f32)))
|
||||
(import "spectest" "print_f64" (func $print_f64 (param f64)))
|
||||
(import "spectest" "print_i32_f32" (func $print_i32_f32 (param i32 f32)))
|
||||
|
||||
Reference in New Issue
Block a user