mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
remove box and unbox expressions
This commit is contained in:
parent
a9813aeae7
commit
d64930c17f
12 changed files with 9 additions and 196 deletions
|
@ -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"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue