mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Remove Num.bytesTo___ functions
These may be reintroduced in some form later, but they don't handle endianness and it's not clear builtins are the right place for them.
This commit is contained in:
parent
ef634ba8e4
commit
9518d76cd8
13 changed files with 15 additions and 530 deletions
|
@ -90,11 +90,6 @@ const FLOATS = [_]type{ f32, f64 };
|
|||
const NUMBERS = INTEGERS ++ FLOATS;
|
||||
|
||||
comptime {
|
||||
exportNumFn(num.bytesToU16C, "bytes_to_u16");
|
||||
exportNumFn(num.bytesToU32C, "bytes_to_u32");
|
||||
exportNumFn(num.bytesToU64C, "bytes_to_u64");
|
||||
exportNumFn(num.bytesToU128C, "bytes_to_u128");
|
||||
|
||||
exportNumFn(num.shiftRightZeroFillI128, "shift_right_zero_fill.i128");
|
||||
exportNumFn(num.shiftRightZeroFillU128, "shift_right_zero_fill.u128");
|
||||
|
||||
|
|
|
@ -274,42 +274,6 @@ pub fn exportToIntCheckingMaxAndMin(comptime From: type, comptime To: type, comp
|
|||
@export(f, .{ .name = name ++ @typeName(From), .linkage = .Strong });
|
||||
}
|
||||
|
||||
pub fn bytesToU16C(arg: RocList, position: usize) callconv(.C) u16 {
|
||||
return @call(.always_inline, bytesToU16, .{ arg, position });
|
||||
}
|
||||
|
||||
fn bytesToU16(arg: RocList, position: usize) u16 {
|
||||
const bytes = @as([*]const u8, @ptrCast(arg.bytes));
|
||||
return @as(u16, @bitCast([_]u8{ bytes[position], bytes[position + 1] }));
|
||||
}
|
||||
|
||||
pub fn bytesToU32C(arg: RocList, position: usize) callconv(.C) u32 {
|
||||
return @call(.always_inline, bytesToU32, .{ arg, position });
|
||||
}
|
||||
|
||||
fn bytesToU32(arg: RocList, position: usize) u32 {
|
||||
const bytes = @as([*]const u8, @ptrCast(arg.bytes));
|
||||
return @as(u32, @bitCast([_]u8{ bytes[position], bytes[position + 1], bytes[position + 2], bytes[position + 3] }));
|
||||
}
|
||||
|
||||
pub fn bytesToU64C(arg: RocList, position: usize) callconv(.C) u64 {
|
||||
return @call(.always_inline, bytesToU64, .{ arg, position });
|
||||
}
|
||||
|
||||
fn bytesToU64(arg: RocList, position: usize) u64 {
|
||||
const bytes = @as([*]const u8, @ptrCast(arg.bytes));
|
||||
return @as(u64, @bitCast([_]u8{ bytes[position], bytes[position + 1], bytes[position + 2], bytes[position + 3], bytes[position + 4], bytes[position + 5], bytes[position + 6], bytes[position + 7] }));
|
||||
}
|
||||
|
||||
pub fn bytesToU128C(arg: RocList, position: usize) callconv(.C) u128 {
|
||||
return @call(.always_inline, bytesToU128, .{ arg, position });
|
||||
}
|
||||
|
||||
fn bytesToU128(arg: RocList, position: usize) u128 {
|
||||
const bytes = @as([*]const u8, @ptrCast(arg.bytes));
|
||||
return @as(u128, @bitCast([_]u8{ bytes[position], bytes[position + 1], bytes[position + 2], bytes[position + 3], bytes[position + 4], bytes[position + 5], bytes[position + 6], bytes[position + 7], bytes[position + 8], bytes[position + 9], bytes[position + 10], bytes[position + 11], bytes[position + 12], bytes[position + 13], bytes[position + 14], bytes[position + 15] }));
|
||||
}
|
||||
|
||||
fn isMultipleOf(comptime T: type, lhs: T, rhs: T) bool {
|
||||
if (rhs == 0 or rhs == -1) {
|
||||
// lhs is a multiple of rhs iff
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue