mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
add dbg impl for use with roc test
This commit is contained in:
parent
546e0778c4
commit
6c60da2832
4 changed files with 47 additions and 2 deletions
11
crates/compiler/builtins/bitcode/src/dbg.zig
Normal file
11
crates/compiler/builtins/bitcode/src/dbg.zig
Normal file
|
@ -0,0 +1,11 @@
|
|||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const RocStr = @import("str.zig").RocStr;
|
||||
|
||||
// An optional debug impl to be called during `roc test`
|
||||
pub fn dbg_impl(loc: *const RocStr, src: *const RocStr, msg: *const RocStr) callconv(.C) void {
|
||||
if (builtin.target.cpu.arch != .wasm32) {
|
||||
const stderr = std.io.getStdErr().writer();
|
||||
stderr.print("[{s}] {s} = {s}\n", .{ loc.asSlice(), src.asSlice(), msg.asSlice() }) catch unreachable;
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ const math = std.math;
|
|||
const utils = @import("utils.zig");
|
||||
const expect = @import("expect.zig");
|
||||
const panic_utils = @import("panic.zig");
|
||||
const dbg_utils = @import("dbg.zig");
|
||||
|
||||
comptime {
|
||||
_ = @import("compiler_rt.zig");
|
||||
|
@ -245,6 +246,7 @@ comptime {
|
|||
exportUtilsFn(utils.dictPseudoSeed, "dict_pseudo_seed");
|
||||
|
||||
@export(panic_utils.panic, .{ .name = "roc_builtins.utils." ++ "panic", .linkage = .Weak });
|
||||
@export(dbg_utils.dbg_impl, .{ .name = "roc_builtins.utils." ++ "dbg_impl", .linkage = .Weak });
|
||||
|
||||
if (builtin.target.cpu.arch != .wasm32) {
|
||||
exportUtilsFn(expect.expectFailedStartSharedBuffer, "expect_failed_start_shared_buffer");
|
||||
|
|
|
@ -422,6 +422,7 @@ pub const DEC_TAN: &str = "roc_builtins.dec.tan";
|
|||
pub const DEC_TO_I128: &str = "roc_builtins.dec.to_i128";
|
||||
pub const DEC_TO_STR: &str = "roc_builtins.dec.to_str";
|
||||
|
||||
pub const UTILS_DBG_IMPL: &str = "roc_builtins.utils.dbg_impl";
|
||||
pub const UTILS_TEST_PANIC: &str = "roc_builtins.utils.test_panic";
|
||||
pub const UTILS_ALLOCATE_WITH_REFCOUNT: &str = "roc_builtins.utils.allocate_with_refcount";
|
||||
pub const UTILS_INCREF_RC_PTR: &str = "roc_builtins.utils.incref_rc_ptr";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue