mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-15 21:23:57 +00:00
Implement hash for Dec
This commit is contained in:
parent
0b475ae979
commit
3585d5bb5b
12 changed files with 44 additions and 6 deletions
|
|
@ -209,6 +209,10 @@ pub const RocDec = extern struct {
|
|||
return RocStr.init(&str_bytes, position);
|
||||
}
|
||||
|
||||
pub fn toI128(self: RocDec) i128 {
|
||||
return self.num;
|
||||
}
|
||||
|
||||
pub fn eq(self: RocDec, other: RocDec) bool {
|
||||
return self.num == other.num;
|
||||
}
|
||||
|
|
@ -1108,6 +1112,10 @@ pub fn fromF64C(arg: f64) callconv(.C) i128 {
|
|||
return if (@call(.{ .modifier = always_inline }, RocDec.fromF64, .{arg})) |dec| dec.num else @panic("TODO runtime exception failing convert f64 to RocDec");
|
||||
}
|
||||
|
||||
pub fn toI128(arg: RocDec) callconv(.C) i128 {
|
||||
return @call(.{ .modifier = always_inline }, RocDec.toI128, .{arg});
|
||||
}
|
||||
|
||||
pub fn eqC(arg1: RocDec, arg2: RocDec) callconv(.C) bool {
|
||||
return @call(.{ .modifier = always_inline }, RocDec.eq, .{ arg1, arg2 });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ comptime {
|
|||
exportDecFn(dec.fromStr, "from_str");
|
||||
exportDecFn(dec.toStr, "to_str");
|
||||
exportDecFn(dec.fromF64C, "from_f64");
|
||||
exportDecFn(dec.toI128, "to_i128");
|
||||
exportDecFn(dec.eqC, "eq");
|
||||
exportDecFn(dec.neqC, "neq");
|
||||
exportDecFn(dec.negateC, "negate");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue