Remove castToNat

This commit is contained in:
Joshua Hoeflich 2021-08-19 16:04:20 -05:00
parent 0bebb64bae
commit b57ebb6229
8 changed files with 2 additions and 22 deletions

View file

@ -81,7 +81,6 @@ comptime {
exportNumFn(num.asin, "asin");
exportNumFn(num.bytesToU16C, "bytes_to_u16");
exportNumFn(num.bytesToU32C, "bytes_to_u32");
exportNumFn(num.castToNat, "cast_to_nat");
exportNumFn(num.round, "round");
}

View file

@ -41,10 +41,6 @@ fn bytesToU32(arg: RocList, position: usize) u32 {
return @bitCast(u32, [_]u8{ bytes[position], bytes[position + 1], bytes[position + 2], bytes[position + 3] });
}
pub fn castToNat(num: i64) callconv(.C) usize {
return @intCast(usize, num);
}
pub fn round(num: f64) callconv(.C) i64 {
return @floatToInt(i32, (@round(num)));
}

View file

@ -10,7 +10,6 @@ pub const NUM_IS_FINITE: &str = "roc_builtins.num.is_finite";
pub const NUM_POW_INT: &str = "roc_builtins.num.pow_int";
pub const NUM_BYTES_TO_U16: &str = "roc_builtins.num.bytes_to_u16";
pub const NUM_BYTES_TO_U32: &str = "roc_builtins.num.bytes_to_u32";
pub const NUM_CAST_TO_NAT: &str = "roc_builtins.num.cast_to_nat";
pub const NUM_ROUND: &str = "roc_builtins.num.round";
pub const STR_INIT: &str = "roc_builtins.str.init";

View file

@ -501,13 +501,6 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
Box::new(float_type(flex(TVAR1))),
);
// castToNat : Num a -> Nat
add_top_level_function_type!(
Symbol::NUM_CAST_TO_NAT,
vec![int_type(flex(TVAR1))],
Box::new(nat_type()),
);
// bytesToU16 : List U8, Nat -> Result U16 [ OutOfBounds ]
{
let position_out_of_bounds = SolvedType::TagUnion(

View file

@ -3404,7 +3404,7 @@ fn num_bytes_to(symbol: Symbol, var_store: &mut VarStore, offset: i64, low_level
RunLowLevel {
ret_var: cast_var,
args: vec![(cast_var, Num(var_store.fresh(), offset))],
op: LowLevel::NumCastToNat,
op: LowLevel::NumIntCast,
},
),
],

View file

@ -4740,11 +4740,6 @@ fn run_low_level<'a, 'ctx, 'env>(
}
}
}
NumCastToNat => {
debug_assert_eq!(args.len(), 1);
let num = load_symbol(scope, &args[0]).into_int_value();
call_bitcode_fn(env, &[num.into()], bitcode::NUM_CAST_TO_NAT)
}
NumBytesToU16 => {
debug_assert_eq!(args.len(), 2);
let list = load_symbol(scope, &args[0]).into_struct_value();

View file

@ -89,7 +89,6 @@ pub enum LowLevel {
NumAsin,
NumBytesToU16,
NumBytesToU32,
NumCastToNat,
NumBitwiseAnd,
NumBitwiseXor,
NumBitwiseOr,
@ -126,7 +125,7 @@ impl LowLevel {
| NumSqrtUnchecked | NumLogUnchecked | NumRound | NumToFloat | NumPow | NumCeiling
| NumPowInt | NumFloor | NumIsFinite | NumAtan | NumAcos | NumAsin | NumBitwiseAnd
| NumBitwiseXor | NumBitwiseOr | NumShiftLeftBy | NumShiftRightBy | NumBytesToU16
| NumBytesToU32 | NumCastToNat | NumShiftRightZfBy | NumIntCast | Eq | NotEq | And
| NumBytesToU32 | NumShiftRightZfBy | NumIntCast | Eq | NotEq | And
| Or | Not | Hash | ExpectTrue => false,
ListMap | ListMap2 | ListMap3 | ListMapWithIndex | ListKeepIf | ListWalk

View file

@ -1011,7 +1011,6 @@ pub fn lowlevel_borrow_signature(arena: &Bump, op: LowLevel) -> &[bool] {
| NumIntCast => arena.alloc_slice_copy(&[irrelevant]),
NumBytesToU16 => arena.alloc_slice_copy(&[borrowed, irrelevant]),
NumBytesToU32 => arena.alloc_slice_copy(&[borrowed, irrelevant]),
NumCastToNat => arena.alloc_slice_copy(&[irrelevant]),
StrStartsWith | StrEndsWith => arena.alloc_slice_copy(&[owned, borrowed]),
StrStartsWithCodePt => arena.alloc_slice_copy(&[borrowed, irrelevant]),
StrFromUtf8 => arena.alloc_slice_copy(&[owned]),