Some questions with D and webassembly
TheZipCreator
thezipcreator at protonmail.com
Fri Mar 3 18:34:24 UTC 2023
On Friday, 3 March 2023 at 13:42:55 UTC, ryuukk_ wrote:
> On Friday, 3 March 2023 at 03:32:37 UTC, TheZipCreator wrote:
>> [...]
>
> https://discourse.llvm.org/t/rfc-webassembly-reference-types-in-clang/66939
>
> it says it is an opaque type, maybe just need to be ``void*``?
>
> Also there are new intrinsics, maybe you can define them like
> this:
>
> ```D
> alias externref_t = void*;
>
> pragma(LDC_intrinsic, "llvm.wasm.table.set.externref.i32")
> extern(C) void llvm_wasm_table_set_externref(void*, int,
> externref_t);
>
> pragma(LDC_intrinsic, "llvm.wasm.table.get.externref.i32")
> extern(C) externref_t llvm_wasm_table_get_externref(void*,
> int);
> ```
Using `void*` doesn't appear to work (and looking at the
generated wasm it seems to reduce it to `i32`, which is not the
right type unfortunately). I guess what I could do is have a
global array in js which stores all objects I'll need to access,
then just access them via the index into that array but that
feels like a hack especially when `externref` is a thing that
exists.
More information about the Digitalmars-d-learn
mailing list