mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 06:44:46 +00:00
add JoinPointId tracking for parameters
This commit is contained in:
parent
fb589f7dc5
commit
b00ef5ea4f
1 changed files with 10 additions and 0 deletions
|
@ -741,6 +741,8 @@ trait Backend<'a> {
|
|||
/// scan_ast runs through the ast and fill the last seen map.
|
||||
/// This must iterate through the ast in the same way that build_stmt does. i.e. then before else.
|
||||
fn scan_ast(&mut self, stmt: &Stmt<'a>) {
|
||||
// Join map keeps track of join point paramaters so that we can keep them around while they still might be jumped to.
|
||||
let mut join_map: MutMap<JoinPointId, &'a [Param<'a>]> = MutMap::default();
|
||||
match stmt {
|
||||
Stmt::Let(sym, expr, _, following) => {
|
||||
self.set_last_seen(*sym, stmt);
|
||||
|
@ -829,8 +831,10 @@ trait Backend<'a> {
|
|||
parameters,
|
||||
body: continuation,
|
||||
remainder,
|
||||
id,
|
||||
..
|
||||
} => {
|
||||
join_map.insert(*id, parameters);
|
||||
for param in *parameters {
|
||||
self.set_last_seen(param.symbol, stmt);
|
||||
}
|
||||
|
@ -838,6 +842,12 @@ trait Backend<'a> {
|
|||
self.scan_ast(remainder);
|
||||
}
|
||||
Stmt::Jump(JoinPointId(sym), symbols) => {
|
||||
if let Some(parameters) = join_map.get(&JoinPointId(*sym)) {
|
||||
// Keep the parameters around. They will be overwritten when jumping.
|
||||
for param in *parameters {
|
||||
self.set_last_seen(param.symbol, stmt);
|
||||
}
|
||||
}
|
||||
self.set_last_seen(*sym, stmt);
|
||||
for sym in *symbols {
|
||||
self.set_last_seen(*sym, stmt);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue