Proposed strategy to support WASM in D

Paulo Pinto pjmlp at progtools.org
Fri Nov 18 08:00:00 UTC 2022


On Friday, 18 November 2022 at 07:28:33 UTC, AnimusPEXUS wrote:
> On Friday, 18 November 2022 at 07:06:08 UTC, Johan wrote:
>> On Friday, 18 November 2022 at 00:55:57 UTC, AnimusPEXUS wrote:
>>> 
>>
>> Can you give an example of what goes wrong? `i32` is 
>> LDC/LLVM's type of signed _and_ unsigned integers, there is no 
>> distinction on LLVM IR level.
>>
>> -Johan
>
> for example, if I export function uint fname(uint p1, uint p2), 
> the resulting wasm code treats values as signed. but actually I 
> don't know if it possible for wasm to really know I wast to 
> pass unsigned value.

It looks like that if you look at the number, but in reality WASM 
makes no distiction, it is up for the application themselves to 
use the appropriate set of opcodes.

> The class  defines uninterpreted integers, whose signedness 
> interpretation can vary depending on context. In the abstract 
> syntax, they are represented as unsigned values. However, some 
> operations convert them to signed based on a two’s complement 
> interpretation.

https://webassembly.github.io/spec/core/syntax/values.html#integers

https://webassembly.github.io/spec/core/syntax/instructions.html#syntax-sx




More information about the Digitalmars-d mailing list