a working prototype

This commit is contained in:
Folkert 2021-08-15 23:20:05 +02:00
parent d8e38ef2ac
commit a0a0896622
11 changed files with 443 additions and 144 deletions

View file

@ -101,6 +101,14 @@ comptime {
exportStrFn(str.fromUtf8RangeC, "from_utf8_range");
}
// Utils
const utils = @import("utils.zig");
comptime {
exportUtilsFn(utils.test_panic, "test_panic");
@export(utils.panic, .{ .name = "roc_builtins.utils." ++ "panic", .linkage = .Weak });
}
// Export helpers - Must be run inside a comptime
fn exportBuiltinFn(comptime func: anytype, comptime func_name: []const u8) void {
@export(func, .{ .name = "roc_builtins." ++ func_name, .linkage = .Strong });
@ -121,6 +129,10 @@ fn exportDecFn(comptime func: anytype, comptime func_name: []const u8) void {
exportBuiltinFn(func, "dec." ++ func_name);
}
fn exportUtilsFn(comptime func: anytype, comptime func_name: []const u8) void {
exportBuiltinFn(func, "utils." ++ func_name);
}
// Custom panic function, as builtin Zig version errors during LLVM verification
pub fn panic(message: []const u8, stacktrace: ?*std.builtin.StackTrace) noreturn {
std.debug.print("{s}: {?}", .{ message, stacktrace });