add src and location to dbg

This commit is contained in:
Brendan Hansknecht 2023-12-01 20:24:23 -08:00
parent 4587c4ebc5
commit 3966d63e2f
No known key found for this signature in database
GPG key ID: 0EA784685083E75B
21 changed files with 385 additions and 119 deletions

View file

@ -910,16 +910,18 @@ impl<'a, 'ctx, 'env> Env<'a, 'ctx, 'env> {
&self,
env: &Env<'a, 'ctx, 'env>,
location: BasicValueEnum<'ctx>,
source: BasicValueEnum<'ctx>,
message: BasicValueEnum<'ctx>,
) {
let function = self.module.get_function("roc_dbg").unwrap();
let loc = self.string_to_arg(env, location);
let src = self.string_to_arg(env, source);
let msg = self.string_to_arg(env, message);
let call = self
.builder
.new_build_call(function, &[loc.into(), msg.into()], "roc_dbg");
let call =
self.builder
.new_build_call(function, &[loc.into(), src.into(), msg.into()], "roc_dbg");
call.set_call_convention(C_CALL_CONV);
}
@ -3527,17 +3529,17 @@ pub(crate) fn build_exp_stmt<'a, 'ctx>(
}
Dbg {
source_location,
source,
symbol,
variable: _,
remainder,
} => {
if env.mode.runs_expects() {
// TODO: Change location to `filename:line_number`
// let region = unsafe { std::mem::transmute::<_, roc_region::all::Region>(*symbol) };
let location =
build_string_literal(env, parent, symbol.module_string(&env.interns));
let location = build_string_literal(env, parent, source_location);
let source = build_string_literal(env, parent, source);
let message = scope.load_symbol(symbol);
env.call_dbg(env, location, message);
env.call_dbg(env, location, source, message);
}
build_exp_stmt(