remove box and unbox expressions

This commit is contained in:
Folkert 2023-07-05 18:01:00 +02:00
parent a9813aeae7
commit d64930c17f
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
12 changed files with 9 additions and 196 deletions

View file

@ -882,17 +882,11 @@ fn insert_refcount_operations_binding<'a>(
inc_owned!(arguments.iter().copied(), new_let)
}
Expr::ExprBox { symbol } => {
let new_let = new_let!(stmt);
inc_owned!([*symbol], new_let)
}
Expr::GetTagId { structure, .. }
| Expr::StructAtIndex { structure, .. }
| Expr::UnionAtIndex { structure, .. }
| Expr::UnionFieldPtrAtIndex { structure, .. }
| Expr::ExprUnbox { symbol: structure } => {
| Expr::UnionFieldPtrAtIndex { structure, .. } => {
// All structures are alive at this point and don't have to be copied in order to take an index out/get tag id/copy values to the stack.
// But we do want to make sure to decrement this item if it is the last reference.
let new_stmt = dec_borrowed!([*structure], stmt);
@ -905,8 +899,9 @@ fn insert_refcount_operations_binding<'a>(
match expr {
Expr::StructAtIndex { .. }
| Expr::UnionAtIndex { .. }
| Expr::UnionFieldPtrAtIndex { .. }
| Expr::ExprUnbox { .. } => insert_inc_stmt(arena, *binding, 1, new_stmt),
| Expr::UnionFieldPtrAtIndex { .. } => {
insert_inc_stmt(arena, *binding, 1, new_stmt)
}
// No usage of an element of a reference counted symbol. No need to increment.
Expr::GetTagId { .. } => new_stmt,
_ => unreachable!("Unexpected expression type"),