switch dbg arg ordering to make it backwards compatible

This commit is contained in:
Brendan Hansknecht 2023-12-02 16:52:32 -08:00
parent 6c60da2832
commit 787d7f85ac
No known key found for this signature in database
GPG key ID: 0EA784685083E75B
50 changed files with 54 additions and 53 deletions

View file

@ -3,7 +3,7 @@ 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 {
pub fn dbg_impl(loc: *const RocStr, msg: *const RocStr, src: *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;

View file

@ -20,11 +20,11 @@ extern fn roc_realloc(c_ptr: *anyopaque, new_size: usize, old_size: usize, align
// This should never be passed a null pointer.
extern fn roc_dealloc(c_ptr: *anyopaque, alignment: u32) callconv(.C) void;
extern fn roc_dbg(loc: *anyopaque, src: *anyopaque, message: *anyopaque) callconv(.C) void;
extern fn roc_dbg(loc: *anyopaque, message: *anyopaque, src: *anyopaque) callconv(.C) void;
// Since roc_dbg is never used by the builtins, we need at export a function that uses it to stop DCE.
pub fn test_dbg(loc: *anyopaque, src: *anyopaque, message: *anyopaque) callconv(.C) void {
roc_dbg(loc, src, message);
roc_dbg(loc, message, src);
}
extern fn kill(pid: c_int, sig: c_int) c_int;
@ -47,7 +47,7 @@ fn testing_roc_mmap(addr: ?*anyopaque, length: c_uint, prot: c_int, flags: c_int
return mmap(addr, length, prot, flags, fd, offset);
}
fn testing_roc_dbg(loc: *anyopaque, src: *anyopaque, message: *anyopaque) callconv(.C) void {
fn testing_roc_dbg(loc: *anyopaque, message: *anyopaque, src: *anyopaque) callconv(.C) void {
_ = message;
_ = src;
_ = loc;

View file

@ -919,9 +919,10 @@ impl<'a, 'ctx, 'env> Env<'a, 'ctx, 'env> {
let src = self.string_to_arg(env, source);
let msg = self.string_to_arg(env, message);
// TODO: at some point it will be a breaking change, but flip order to (loc, src, msg)
let call =
self.builder
.new_build_call(function, &[loc.into(), src.into(), msg.into()], "roc_dbg");
.new_build_call(function, &[loc.into(), msg.into(), src.into()], "roc_dbg");
call.set_call_convention(C_CALL_CONV);
}

View file

@ -167,8 +167,8 @@ pub fn add_default_roc_externs(env: &Env<'_, '_, '_>) {
let fn_val = module.get_function("roc_dbg").unwrap();
let mut params = fn_val.get_param_iter();
let loc_arg = params.next().unwrap();
let src_arg = params.next().unwrap();
let msg_arg = params.next().unwrap();
let src_arg = params.next().unwrap();
debug_assert!(params.next().is_none());
@ -181,7 +181,7 @@ pub fn add_default_roc_externs(env: &Env<'_, '_, '_>) {
let dbg_impl = module.get_function(bitcode::UTILS_DBG_IMPL).unwrap();
let call = builder.new_build_call(
dbg_impl,
&[loc_arg.into(), src_arg.into(), msg_arg.into()],
&[loc_arg.into(), msg_arg.into(), src_arg.into()],
"call_utils_dbg_impl",
);

View file

@ -290,7 +290,7 @@ mod dummy_platform_functions {
}
#[no_mangle]
pub unsafe extern "C" fn roc_dbg(_loc: *mut c_void, _src: *mut c_void, _msg: *mut c_void) {
pub unsafe extern "C" fn roc_dbg(_loc: *mut c_void, _msg: *mut c_void, _src: *mut c_void) {
unimplemented!("It is not valid to call roc dbg from within the compiler. Please use the \"platform\" feature if this is a platform.")
}