From 681e0e3ecaf6b68462dd64b03e497449acda6e85 Mon Sep 17 00:00:00 2001 From: Ilya Rezvov Date: Sat, 14 Apr 2018 16:31:21 -0700 Subject: [PATCH] fix br_if typing --- src/Language/Wasm/Validate.hs | 2 +- tests/Test.hs | 2 +- tests/samples/import.wast | 67 ----------------------------------- 3 files changed, 2 insertions(+), 69 deletions(-) delete mode 100644 tests/samples/import.wast diff --git a/src/Language/Wasm/Validate.hs b/src/Language/Wasm/Validate.hs index 73c0159..91a86a6 100644 --- a/src/Language/Wasm/Validate.hs +++ b/src/Language/Wasm/Validate.hs @@ -198,7 +198,7 @@ getInstrType (Br lbl) = do return $ (Any : r) ==> Any getInstrType (BrIf lbl) = do r <- map Val . maybeToList <$> getLabel lbl - return $ ([Val I32]) ==> empty + return $ (r ++ [Val I32]) ==> r getInstrType (BrTable lbls lbl) = do r <- getLabel lbl rs <- mapM getLabel lbls diff --git a/tests/Test.hs b/tests/Test.hs index 356adba..9ffdda3 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 = ["br_table.wast"] + -- let files = ["br_if.wast"] scriptTestCases <- (`mapM` files) $ \file -> do content <- LBS.readFile $ "tests/samples/" ++ file let Right script = Parser.parseScript <$> Lexer.scanner content diff --git a/tests/samples/import.wast b/tests/samples/import.wast deleted file mode 100644 index 8266439..0000000 --- a/tests/samples/import.wast +++ /dev/null @@ -1,67 +0,0 @@ -(module - (type $func_i32 (func (param i32))) - (type $func_i64 (func (param i64))) - (type $func_f32 (func (param f32))) - (type $func_f64 (func (param f64))) - - (import "spectest" "print" (func (param i32))) - ;; JavaScript can't handle i64 yet. - ;; (func (import "spectest" "print") (param i64)) - (import "spectest" "print" (func $print_i32 (param i32))) - ;; JavaScript can't handle i64 yet. - ;; (import "spectest" "print" (func $print_i64 (param i64))) - (import "spectest" "print" (func $print_f32 (param f32))) - (import "spectest" "print" (func $print_f64 (param f64))) - (import "spectest" "print" (func $print_i32_f32 (param i32 f32))) - (import "spectest" "print" (func $print_f64_f64 (param f64 f64))) - (func $print_i32-2 (import "spectest" "print") (param i32)) - (func $print_f64-2 (import "spectest" "print") (param f64)) - (import "test" "func-i64->i64" (func $i64->i64 (param i64) (result i64))) - - (func (export "p1") (import "spectest" "print") (param i32)) - (func $p (export "p2") (import "spectest" "print") (param i32)) - (func (export "p3") (export "p4") (import "spectest" "print") (param i32)) - (func (export "p5") (import "spectest" "print") (type 0)) - (func (export "p6") (import "spectest" "print") (type 0) (param i32) (result)) - - (import "spectest" "print" (func (type $forward))) - (func (import "spectest" "print") (type $forward)) - (type $forward (func (param i32))) - - (table anyfunc (elem $print_i32 $print_f64)) - ;; (table (export "my-table") anyfunc (elem $print_i32 $print_f64)) - ;; (table (export "my-table") (export "my-table2") anyfunc (elem $print_i32 $print_f64)) - ;; (table (import "external-mod" "external-table") 0 anyfunc) - ;; (table (export "my-table") (import "external-mod" "external-table") 0 anyfunc) - ;; (table (export "my-table") (export "my-table2") (import "external-mod" "external-table") 0 anyfunc) - - (func (export "print32") (param $i i32) - (local $x f32) - (set_local $x (f32.convert_s/i32 (get_local $i))) - (call 0 (get_local $i)) - (call $print_i32_f32 - (i32.add (get_local $i) (i32.const 1)) - (f32.const 42) - ) - (call $print_i32 (get_local $i)) - (call $print_i32-2 (get_local $i)) - (call $print_f32 (get_local $x)) - (call_indirect (type $func_i32) (get_local $i) (i32.const 0)) - ) - - (func (export "print64") (param $i i64) - (local $x f64) - (set_local $x (f64.convert_s/i64 (call $i64->i64 (get_local $i)))) - ;; JavaScript can't handle i64 yet. - ;; (call 1 (get_local $i)) - (call $print_f64_f64 - (f64.add (get_local $x) (f64.const 1)) - (f64.const 53) - ) - ;; JavaScript can't handle i64 yet. - ;; (call $print_i64 (get_local $i)) - (call $print_f64 (get_local $x)) - (call $print_f64-2 (get_local $x)) - (call_indirect (type $func_f64) (get_local $x) (i32.const 1)) - ) -) \ No newline at end of file