summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorWouter van Oortmerssen <aardappel@gmail.com>2020-01-30 14:22:22 -0800
committerGitHub <noreply@github.com>2020-01-30 14:22:22 -0800
commite21bb7e3370da868aa36e3000a756824df4078d1 (patch)
tree692be44bb9467a7aa057da9b9f2e5c3cabf8022d /test
parent4966aa99dceb8851c1135393f520b879096c16fc (diff)
downloadwabt-e21bb7e3370da868aa36e3000a756824df4078d1.tar.gz
wabt-e21bb7e3370da868aa36e3000a756824df4078d1.tar.bz2
wabt-e21bb7e3370da868aa36e3000a756824df4078d1.zip
wasm-decompile: escape hatch for variables used outside scope. (#1322)
The decompiler assumes it can define a variable where it is first assigned to, which works for almost all cases, but occasionally there is a use of a variable outside of the scope where it was defined. This detects that case, and makes sure that variable is pre-declared.
Diffstat (limited to 'test')
-rw-r--r--test/decompile/basic.txt22
1 files changed, 21 insertions, 1 deletions
diff --git a/test/decompile/basic.txt b/test/decompile/basic.txt
index 66c05323..31be88b9 100644
--- a/test/decompile/basic.txt
+++ b/test/decompile/basic.txt
@@ -102,6 +102,17 @@
call_indirect
i32.const 0
)
+ (func $g (param) (result) (local i32)
+ ;; This is rare, but requires special handling: uses of local outside scope
+ ;; of first definition.
+ loop
+ i32.const 1
+ tee_local 0
+ br_if 0
+ end
+ get_local 0
+ drop
+ )
;; LLD outputs a name section with de-mangled C++ function signatures as names,
;; so have to make sure special chars get removed.
(func (export "void signature-&<>(int a)") (param) (result))
@@ -169,13 +180,22 @@ export function f(a:int, b:int):int {
return 0;
}
+function f_c() {
+ var a:int;
+ loop L_a {
+ a = 1;
+ if (a) continue L_a;
+ }
+ a;
+}
+
function signature() {
}
function signature_1() {
}
-function f_e() {
+function f_f() {
}
;;; STDOUT ;;)