Skip to content

Commit 0deaf4f

Browse files
committed
Simplify the unboxing functions.
We can rely on the `ToNumber(v)` conversions performed by `ToWebAssemblyValue` instead of doing `null` handling ourselves.
1 parent 0c1fd3c commit 0deaf4f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

linker/shared/src/main/scala/org/scalajs/linker/backend/wasmemitter/LoaderContent.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ const scalaJSHelpers = {
102102
bF: (x) => x,
103103
bD: (x) => x,
104104

105-
// Unboxes (downcast, null is converted to the zero of the type)
106-
uZ: (x) => x | 0,
107-
uB: (x) => (x << 24) >> 24,
108-
uS: (x) => (x << 16) >> 16,
109-
uI: (x) => x | 0,
110-
uF: (x) => Math.fround(x),
111-
uD: (x) => +x,
105+
// Unboxes (downcast, null is converted to the zero of the type as part of ToWebAssemblyValue)
106+
uZ: (x) => x, // ToInt32 turns false into 0 and true into 1, so this is also an identity
107+
uB: (x) => x,
108+
uS: (x) => x,
109+
uI: (x) => x,
110+
uF: (x) => x,
111+
uD: (x) => x,
112112

113113
// Type tests
114114
tZ: (x) => typeof x === 'boolean',

0 commit comments

Comments
 (0)