Skip to content

Commit 13d090d

Browse files
author
jonas.ong
committed
make bool 0 or 1
1 parent a13224e commit 13d090d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/wasm-compiler/constants.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,14 @@ export const MAKE_BOOL_FX = wasm
6666
.func("$_make_bool")
6767
.params({ $value: i32 })
6868
.results(i32, i64)
69-
.body(i32.const(TYPE_TAG.BOOL), i64.extend_i32_u(local.get("$value")));
69+
.body(
70+
i32.const(TYPE_TAG.BOOL),
71+
wasm
72+
.if(i32.eqz(local.get("$value")))
73+
.results(i64)
74+
.then(i64.const(0))
75+
.else(i64.const(1))
76+
);
7077

7178
// upper 32: pointer; lower 32: length
7279
export const MAKE_STRING_FX = wasm

0 commit comments

Comments
 (0)