Implement builtins for Num.isNan, Num.isInfinite, and Num.isFinite

Closes #5310 and closes #5309
This commit is contained in:
Basile Henry 2023-04-30 16:28:13 +01:00
parent d84a9fa8ba
commit b8aaaaabda
12 changed files with 202 additions and 1 deletions

View file

@ -95,6 +95,24 @@ pub fn exportPow(comptime T: type, comptime name: []const u8) void {
@export(f, .{ .name = name ++ @typeName(T), .linkage = .Strong });
}
pub fn exportIsNan(comptime T: type, comptime name: []const u8) void {
comptime var f = struct {
fn func(input: T) callconv(.C) bool {
return std.math.isNan(input);
}
}.func;
@export(f, .{ .name = name ++ @typeName(T), .linkage = .Strong });
}
pub fn exportIsInfinite(comptime T: type, comptime name: []const u8) void {
comptime var f = struct {
fn func(input: T) callconv(.C) bool {
return std.math.isInf(input);
}
}.func;
@export(f, .{ .name = name ++ @typeName(T), .linkage = .Strong });
}
pub fn exportIsFinite(comptime T: type, comptime name: []const u8) void {
comptime var f = struct {
fn func(input: T) callconv(.C) bool {