mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 23:04:49 +00:00
inline dbg
This commit is contained in:
parent
dcb530d3af
commit
e7f3c6f281
18 changed files with 192 additions and 21 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue