inline dbg

This commit is contained in:
Folkert 2022-11-23 21:23:28 +01:00
parent dcb530d3af
commit e7f3c6f281
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
18 changed files with 192 additions and 21 deletions

View file

@ -4403,6 +4403,7 @@ pub fn with_hole<'a>(
Expect { .. } => unreachable!("I think this is unreachable"),
ExpectFx { .. } => unreachable!("I think this is unreachable"),
Dbg { .. } => unreachable!("I think this is unreachable"),
If {
cond_var,
@ -6546,6 +6547,42 @@ pub fn from_can<'a>(
stmt
}
Dbg {
loc_condition,
loc_continuation,
variable,
} => {
let rest = from_can(env, variable, loc_continuation.value, procs, layout_cache);
let dbg_symbol = env.unique_symbol();
let call = crate::ir::Call {
call_type: CallType::LowLevel {
op: LowLevel::Dbg,
update_mode: env.next_update_mode_id(),
},
arguments: env.arena.alloc([dbg_symbol]),
};
let dbg_layout = layout_cache
.from_var(env.arena, variable, env.subs)
.expect("invalid dbg_layout");
let expr = Expr::Call(call);
let mut stmt = Stmt::Let(dbg_symbol, expr, dbg_layout, env.arena.alloc(rest));
stmt = with_hole(
env,
loc_condition.value,
variable,
procs,
layout_cache,
dbg_symbol,
env.arena.alloc(stmt),
);
stmt
}
LetRec(defs, cont, _cycle_mark) => {
// because Roc is strict, only functions can be recursive!
for def in defs.into_iter() {