How can I use WebAssembly Reference Types with LDC?
ErichMurazik
LucioStamm657 at hotmail.com
Fri Nov 22 02:05:13 UTC 2024
On Saturday, 14 September 2024 at 17:05:37 UTC, TM wrote:
> On Saturday, 14 September 2024 at 12:08:13 UTC, kinke wrote:
>> On Saturday, 14 September 2024 at 08:28:02 UTC, TM wrote:
>>> In C/C++, you can access wasm's externref and funcref using:
>>> ```C++
>>> char __attribute__((address_space(10)))* //externref
>>> char __attribute__((address_space(20)))* //funcref
>>> ```
>>> Does D provide similar functionality?
>>
>> Nope, there's currently no way to customize the address-space
>> of pointers. dcompute has 2-3 magic structs for expressing
>> such pointers.
>>
>> Maybe this could by solved via some magic
>> ```D
>> // magic struct requiring compiler support
>> struct __as_pointer(T, uint addressSpace) { T* ptr; alias this
>> = ptr; }
>>
>> alias ExternRef(T) = __as_pointer!(T, 10);
>> alias FuncRef(T) = __as_pointer!(T, 20);
>> ```
>
> Thank you for your response. Unfortunately, I was unable to
> generate wasm's externref using the method you suggested. It
> appears that dcompute [Undertale
> Yellow](https://undertaleyellow.io) cannot generate code
> targeting wasm.
>
> Sadly, it seems difficult to achieve this with the capabilities
> of the dlang.
Some programs on my computer crashed when accessing your link.
More information about the digitalmars-d-ldc
mailing list