mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
set up GetTagId
This commit is contained in:
parent
f08c764cad
commit
342d1f34c2
6 changed files with 136 additions and 5 deletions
|
@ -129,6 +129,12 @@ pub fn occurring_variables_expr(expr: &Expr<'_>, result: &mut MutSet<Symbol>) {
|
|||
}
|
||||
|
||||
EmptyArray | RuntimeErrorFunction(_) | Literal(_) => {}
|
||||
|
||||
GetTagId {
|
||||
structure: symbol, ..
|
||||
} => {
|
||||
result.insert(*symbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -753,6 +759,19 @@ impl<'a> Context<'a> {
|
|||
// function pointers are persistent
|
||||
self.arena.alloc(Stmt::Let(z, v, l, b))
|
||||
}
|
||||
|
||||
GetTagId { structure: x, .. } => {
|
||||
let b = self.add_dec_if_needed(x, b, b_live_vars);
|
||||
let info_x = self.get_var_info(x);
|
||||
let b = if info_x.consume {
|
||||
self.add_inc(z, 1, b)
|
||||
} else {
|
||||
b
|
||||
};
|
||||
|
||||
self.arena.alloc(Stmt::Let(z, v, l, b))
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
(new_b, live_vars)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue