fix most dev backend tests

This commit is contained in:
Folkert 2023-09-11 23:08:46 +02:00
parent 5ca3d3bcf1
commit 89472bf495
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
7 changed files with 120 additions and 53 deletions

View file

@ -1125,6 +1125,23 @@ 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 exportFromInt(comptime T: type, comptime name: []const u8) void {
comptime var f = struct {
fn func(self: T) callconv(.C) i128 {
const this = @intCast(i128, self);
var result: i128 = undefined;
if (@mulWithOverflow(i128, this, RocDec.one_point_zero_i128, &result)) {
@panic("TODO runtime exception failing convert integer to RocDec");
} else {
return result;
}
}
}.func;
@export(f, .{ .name = name ++ @typeName(T), .linkage = .Strong });
}
pub fn fromU64C(arg: u64) callconv(.C) i128 {
return @call(.{ .modifier = always_inline }, RocDec.fromU64, .{arg}).toI128();
}