Cast a signed integer node to a usize, for use in pointer arithmetic. Negative numbers will become very large positive numbers but that is ok since we only use this in pointer arithmetic expressions, where wraparound will ensure we get the correct value. node -> @as(usize, @bitCast(@as(isize, @intCast(node))))
fn usizeCastForWrappingPtrArithmetic(t: *Translator, node: ZigNode) TransError!ZigNode
fn usizeCastForWrappingPtrArithmetic(t: *Translator, node: ZigNode) TransError!ZigNode {
const intcast_node = try ZigTag.as.create(t.arena, .{
.lhs = try ZigTag.type.create(t.arena, "isize"),
.rhs = try ZigTag.int_cast.create(t.arena, node),
});
return ZigTag.as.create(t.arena, .{
.lhs = try ZigTag.type.create(t.arena, "usize"),
.rhs = try ZigTag.bit_cast.create(t.arena, intcast_node),
});
}