consider expect in inc/dec

This commit is contained in:
Folkert 2022-07-10 20:56:56 +02:00
parent 830dd03b30
commit a671b57f83
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
2 changed files with 28 additions and 3 deletions

View file

@ -1187,7 +1187,25 @@ impl<'a> Context<'a> {
(switch, case_live_vars)
}
Expect { remainder, .. } => self.visit_stmt(codegen, remainder),
Expect {
remainder,
condition,
region,
lookups,
layouts,
} => {
let (b, b_live_vars) = self.visit_stmt(codegen, remainder);
let expect = self.arena.alloc(Stmt::Expect {
condition: *condition,
region: *region,
lookups,
layouts,
remainder: b,
});
(expect, b_live_vars)
}
RuntimeError(_) | Refcounting(_, _) => (stmt, MutSet::default()),
}

View file

@ -1980,9 +1980,16 @@ impl<'a> Stmt<'a> {
.append(alloc.hardline())
.append(cont.to_doc(alloc)),
Expect { condition, .. } => alloc
Expect {
condition,
remainder,
..
} => alloc
.text("expect ")
.append(symbol_to_doc(alloc, *condition)),
.append(symbol_to_doc(alloc, *condition))
.append(";")
.append(alloc.hardline())
.append(remainder.to_doc(alloc)),
Ret(symbol) => alloc
.text("ret ")