Stream: wit-bindgen

Topic: ✔ Unigned integers


view this post on Zulip Scott Waye (Aug 26 2023 at 02:28):

In wit-bindgen, a lot of the generators have a wasm_type function which converts WasmType to the destination language type, but it doesnt differentiate singed/unsigned. Why is that, many languages differentiate between signed and unsigned integers ? THe C example for the numbers test produces

int32_t __wasm_import_test_numbers_test_roundtrip_u32(int32_t);

When I would have expected to see uint32_t as this is the test for an unsigned 32bit int.

view this post on Zulip Alex Crichton (Aug 26 2023 at 02:37):

That's the raw untyped import, the typed import will have uint32_t

view this post on Zulip Scott Waye (Aug 26 2023 at 08:31):

I see. The raw imports must have native wasm types because of something that means you can't rely on the target language wasm compiler to do that conversion?

view this post on Zulip Alex Crichton (Aug 26 2023 at 14:07):

Sort of, certainly for aggregates but we could use unsigned types there in that example. Because a wrapper is always generated it's easier to always use i32 and then convert for the real function. At runtime it shouldn't matter since it all goes away anyway

view this post on Zulip Scott Waye (Aug 26 2023 at 16:09):

Thanks, Not tackled aggregrates yet but I see that might be more complicated depending on how the target language tackles the interop. And yes agree it would probably get inlined away during optimisation.

view this post on Zulip Notification Bot (Aug 26 2023 at 16:10):

Scott Waye has marked this topic as resolved.


Last updated: Oct 23 2024 at 20:03 UTC