summaryrefslogtreecommitdiff
path: root/test/ctor-eval
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2019-05-24 16:39:52 -0700
committerGitHub <noreply@github.com>2019-05-24 16:39:52 -0700
commit899263882c48dba8e34717af1e28005f8888dca7 (patch)
tree1cea8fa707526b4408a247db5cade5b50e6fa667 /test/ctor-eval
parentdc37d7b74edde1876f2114ad8edd10ab076e778f (diff)
downloadbinaryen-899263882c48dba8e34717af1e28005f8888dca7.tar.gz
binaryen-899263882c48dba8e34717af1e28005f8888dca7.tar.bz2
binaryen-899263882c48dba8e34717af1e28005f8888dca7.zip
Refactor type and function parsing (#2143)
- Refactored & fixed typeuse parsing rules so now the rules more closely follow the spec. There have been multiple parsing rules that were different in subtle ways, which are supposed to be the same according to the spec. - Duplicate types, i.e., types with the same signature, in the type section are allowed as long as they don't have the same given name. If a name is given, we use it; if type name is not given, we generate one in the form of `$FUNCSIG$` + signature string. If the same generated name already exists in the type section, we append `_` at the end. This causes most of the changes in the autogenerated type names in test outputs. - A typeuse has to be in the order of (type) -> (param) -> (result), if more than one of them exist. In case of function definitions, (local) has to be after all of these. Fixed some test cases that violate this rule. - When only (param)/(result) are given, its type will be the type with the smallest existing type index whose parameter and result are the same. If there's no such type, a new type will be created and inserted. - Added a test case `duplicate_types.wast` to test type namings for duplicate types. - Refactored `parseFunction` function. - Add more overrides to helper functions: `getSig` and `ensureFunctionType`.
Diffstat (limited to 'test/ctor-eval')
-rw-r--r--test/ctor-eval/bad-indirect-call2.wast.out8
-rw-r--r--test/ctor-eval/imported2.wast.out6
-rw-r--r--test/ctor-eval/imported3.wast.out4
-rw-r--r--test/ctor-eval/indirect-call3.wast.out4
-rw-r--r--test/ctor-eval/just_some.wast.out6
-rw-r--r--test/ctor-eval/no_partial.wast.out4
-rw-r--r--test/ctor-eval/unsafe_call.wast.out6
7 files changed, 19 insertions, 19 deletions
diff --git a/test/ctor-eval/bad-indirect-call2.wast.out b/test/ctor-eval/bad-indirect-call2.wast.out
index 16f2b33a5..61ef71afb 100644
--- a/test/ctor-eval/bad-indirect-call2.wast.out
+++ b/test/ctor-eval/bad-indirect-call2.wast.out
@@ -1,13 +1,13 @@
(module
- (type $FUNCSIG$v (func))
+ (type $v (func))
(import "env" "_abort" (func $_abort))
(memory $0 256 256)
(data (i32.const 10) "waka waka waka waka waka")
(table $0 2 2 funcref)
(elem (i32.const 0) $_abort $call-indirect)
(export "test1" (func $test1))
- (func $test1 (; 1 ;) (type $FUNCSIG$v)
- (call_indirect (type $FUNCSIG$v)
+ (func $test1 (; 1 ;) (type $v)
+ (call_indirect (type $v)
(i32.const 0)
)
(i32.store8
@@ -15,7 +15,7 @@
(i32.const 120)
)
)
- (func $call-indirect (; 2 ;) (type $FUNCSIG$v)
+ (func $call-indirect (; 2 ;) (type $v)
(i32.store8
(i32.const 40)
(i32.const 67)
diff --git a/test/ctor-eval/imported2.wast.out b/test/ctor-eval/imported2.wast.out
index 8d9148920..b0788065e 100644
--- a/test/ctor-eval/imported2.wast.out
+++ b/test/ctor-eval/imported2.wast.out
@@ -1,11 +1,11 @@
(module
- (type $0 (func))
+ (type $FUNCSIG$v (func))
(memory $0 256 256)
(data (i32.const 10) "wasa waka waka waka waka")
(global $mine (mut i32) (i32.const 1))
(export "test2" (func $test2))
(export "test3" (func $test3))
- (func $test2 (; 0 ;) (type $0)
+ (func $test2 (; 0 ;) (type $FUNCSIG$v)
(global.set $mine
(i32.const 2)
)
@@ -14,7 +14,7 @@
(i32.const 115)
)
)
- (func $test3 (; 1 ;) (type $0)
+ (func $test3 (; 1 ;) (type $FUNCSIG$v)
(i32.store8
(i32.const 14)
(i32.const 115)
diff --git a/test/ctor-eval/imported3.wast.out b/test/ctor-eval/imported3.wast.out
index 101c1adaa..47ab523c1 100644
--- a/test/ctor-eval/imported3.wast.out
+++ b/test/ctor-eval/imported3.wast.out
@@ -1,9 +1,9 @@
(module
- (type $0 (func))
+ (type $FUNCSIG$v (func))
(memory $0 256 256)
(data (i32.const 10) "waka waka waka waka waka")
(export "test1" (func $test1))
- (func $test1 (; 0 ;) (type $0)
+ (func $test1 (; 0 ;) (type $FUNCSIG$v)
(i32.store8
(i32.const 13)
(i32.const 115)
diff --git a/test/ctor-eval/indirect-call3.wast.out b/test/ctor-eval/indirect-call3.wast.out
index 27351bcce..370e73b42 100644
--- a/test/ctor-eval/indirect-call3.wast.out
+++ b/test/ctor-eval/indirect-call3.wast.out
@@ -1,10 +1,10 @@
(module
- (type $FUNCSIG$v (func))
+ (type $v (func))
(import "env" "tableBase" (global $tableBase i32))
(import "env" "_abort" (func $_abort))
(memory $0 256 256)
(data (i32.const 10) "waka waka xaka waka waka\00\00\00\00\00\00C")
- (func $call-indirect (; 1 ;) (type $FUNCSIG$v)
+ (func $call-indirect (; 1 ;) (type $v)
(i32.store8
(i32.const 40)
(i32.const 67)
diff --git a/test/ctor-eval/just_some.wast.out b/test/ctor-eval/just_some.wast.out
index b7a1aa2be..d61eb9548 100644
--- a/test/ctor-eval/just_some.wast.out
+++ b/test/ctor-eval/just_some.wast.out
@@ -1,13 +1,13 @@
(module
- (type $0 (func))
+ (type $FUNCSIG$v (func))
(memory $0 256 256)
(data (i32.const 10) "wasa waka waka waka waka")
(export "test2" (func $test2))
(export "test3" (func $test3))
- (func $test2 (; 0 ;) (type $0)
+ (func $test2 (; 0 ;) (type $FUNCSIG$v)
(unreachable)
)
- (func $test3 (; 1 ;) (type $0)
+ (func $test3 (; 1 ;) (type $FUNCSIG$v)
(i32.store8
(i32.const 13)
(i32.const 113)
diff --git a/test/ctor-eval/no_partial.wast.out b/test/ctor-eval/no_partial.wast.out
index ac943d57c..ad8006a7c 100644
--- a/test/ctor-eval/no_partial.wast.out
+++ b/test/ctor-eval/no_partial.wast.out
@@ -1,9 +1,9 @@
(module
- (type $0 (func))
+ (type $FUNCSIG$v (func))
(memory $0 256 256)
(data (i32.const 10) "waka waka waka waka waka")
(export "test1" (func $test1))
- (func $test1 (; 0 ;) (type $0)
+ (func $test1 (; 0 ;) (type $FUNCSIG$v)
(i32.store8
(i32.const 12)
(i32.const 115)
diff --git a/test/ctor-eval/unsafe_call.wast.out b/test/ctor-eval/unsafe_call.wast.out
index d92a4cd2f..eec593fb9 100644
--- a/test/ctor-eval/unsafe_call.wast.out
+++ b/test/ctor-eval/unsafe_call.wast.out
@@ -1,9 +1,9 @@
(module
- (type $0 (func))
+ (type $FUNCSIG$v (func))
(memory $0 256 256)
(data (i32.const 10) "waka waka waka waka waka")
(export "test1" (func $test1))
- (func $test1 (; 0 ;) (type $0)
+ (func $test1 (; 0 ;) (type $FUNCSIG$v)
(call $unsafe-to-call)
(i32.store
(i32.const 12)
@@ -18,7 +18,7 @@
(i32.const 120)
)
)
- (func $unsafe-to-call (; 1 ;) (type $0)
+ (func $unsafe-to-call (; 1 ;) (type $FUNCSIG$v)
(unreachable)
)
)