set up GetTagId

This commit is contained in:
Eric Correia 2021-06-20 10:54:53 -04:00
parent f08c764cad
commit 342d1f34c2
6 changed files with 136 additions and 5 deletions

View file

@ -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)