Closed ejrgilbert closed 2 months ago
Actually, I found the source for that cast_signed
function and it just does a u32 as i32
cast (seen in the macro invocation).
Given the test in the docs they use to demonstrate the functionality, we should be okay to just cast using the as
keyword.
Add in a notion of macro opcodes that emulate some desired behavior, making the API usage more expressive.
The first example of this is a
u32_const
to help users ensure theiru32
's are emitted correctly when using thei32.const
opcode. This protects users from doingfunc.i32_const(u32_val as i32)
, which will emit signed-ness incorrectly due to sign extension rules for i32s vs u32s. We will need to use thecast_signed
function foru32
primitives to do this.The code will look like the following:
NOTE: When considering IDs represented as
u32
value (global IDs, function IDs, etc.), we don't have to worry about theu32
fitting into ani32
since the number of IDs allowed in a module is capped. It will never surpassI32::MAX
anyway since the cap is somewhere in the millions.