diff --git a/compiler/gen_dev/src/lib.rs b/compiler/gen_dev/src/lib.rs index cc33720764..8bb93c8ab2 100644 --- a/compiler/gen_dev/src/lib.rs +++ b/compiler/gen_dev/src/lib.rs @@ -444,7 +444,7 @@ where self.set_last_seen(*sym, stmt); } } - Expr::AccessAtIndex { structure, .. } => { + Expr::StructAtIndex { structure, .. } => { self.set_last_seen(*structure, stmt); } Expr::GetTagId { structure, .. } => { diff --git a/compiler/gen_llvm/src/llvm/build.rs b/compiler/gen_llvm/src/llvm/build.rs index 3c59dfbf98..d7d53f4b70 100644 --- a/compiler/gen_llvm/src/llvm/build.rs +++ b/compiler/gen_llvm/src/llvm/build.rs @@ -1423,7 +1423,7 @@ pub fn build_exp_expr<'a, 'ctx, 'env>( Reset(_) => todo!(), Reuse { .. } => todo!(), - AccessAtIndex { + StructAtIndex { index, structure, wrapped: Wrapped::RecordOrSingleTagUnion, diff --git a/compiler/mono/src/alias_analysis.rs b/compiler/mono/src/alias_analysis.rs index ccbcefb198..b4662c12da 100644 --- a/compiler/mono/src/alias_analysis.rs +++ b/compiler/mono/src/alias_analysis.rs @@ -874,7 +874,7 @@ fn expr_spec( builder.add_unknown_with(block, &[value_id], result_type) } }, - AccessAtIndex { + StructAtIndex { index, field_layouts: _, structure, diff --git a/compiler/mono/src/borrow.rs b/compiler/mono/src/borrow.rs index 137db5cf13..5bd40dc95a 100644 --- a/compiler/mono/src/borrow.rs +++ b/compiler/mono/src/borrow.rs @@ -570,7 +570,7 @@ impl<'a> BorrowInfState<'a> { Literal(_) | RuntimeErrorFunction(_) => {} - AccessAtIndex { structure: x, .. } => { + StructAtIndex { structure: x, .. } => { // if the structure (record/tag/array) is owned, the extracted value is if self.is_owned(*x) { self.own_var(z); diff --git a/compiler/mono/src/decision_tree.rs b/compiler/mono/src/decision_tree.rs index b000150714..ec8f2f4b55 100644 --- a/compiler/mono/src/decision_tree.rs +++ b/compiler/mono/src/decision_tree.rs @@ -1063,7 +1063,7 @@ fn path_to_expr_help<'a>( Layout::Struct(field_layouts) => { debug_assert!(field_layouts.len() > 1); - let expr = Expr::AccessAtIndex { + let expr = Expr::StructAtIndex { index, field_layouts, structure: symbol, diff --git a/compiler/mono/src/expand_rc.rs b/compiler/mono/src/expand_rc.rs index 21fbf29886..ea71562303 100644 --- a/compiler/mono/src/expand_rc.rs +++ b/compiler/mono/src/expand_rc.rs @@ -343,7 +343,7 @@ fn can_push_inc_through(stmt: &Stmt) -> bool { match stmt { Let(_, expr, _, _) => { // we can always delay an increment/decrement until after a field access - matches!(expr, Expr::AccessAtIndex { .. } | Expr::Literal(_)) + matches!(expr, Expr::StructAtIndex { .. } | Expr::Literal(_)) } Refcounting(ModifyRc::Inc(_, _), _) => true, @@ -421,7 +421,7 @@ fn expand_and_cancel<'a>(env: &mut Env<'a, '_>, stmt: &'a Stmt<'a>) -> &'a Stmt< while !matches!( &expr, - Expr::AccessAtIndex { .. } | Expr::Struct(_) | Expr::Call(_) + Expr::StructAtIndex { .. } | Expr::Struct(_) | Expr::Call(_) ) { if let Stmt::Let(symbol1, expr1, layout1, cont1) = cont { literal_stack.push((symbol, expr.clone(), *layout)); @@ -438,7 +438,7 @@ fn expand_and_cancel<'a>(env: &mut Env<'a, '_>, stmt: &'a Stmt<'a>) -> &'a Stmt< let new_cont; match &expr { - Expr::AccessAtIndex { + Expr::StructAtIndex { structure, index, field_layouts, diff --git a/compiler/mono/src/inc_dec.rs b/compiler/mono/src/inc_dec.rs index 55eb19fee1..ecc405bbde 100644 --- a/compiler/mono/src/inc_dec.rs +++ b/compiler/mono/src/inc_dec.rs @@ -103,7 +103,7 @@ pub fn occurring_variables_expr(expr: &Expr<'_>, result: &mut MutSet) { use Expr::*; match expr { - AccessAtIndex { + StructAtIndex { structure: symbol, .. } => { result.insert(*symbol); @@ -225,7 +225,7 @@ fn is_borrow_param(x: Symbol, ys: &[Symbol], ps: &[Param]) -> bool { // We do not need to consume the projection of a variable that is not consumed fn consume_expr(m: &VarMap, e: &Expr<'_>) -> bool { match e { - Expr::AccessAtIndex { structure: x, .. } => match m.get(x) { + Expr::StructAtIndex { structure: x, .. } => match m.get(x) { Some(info) => info.consume, None => true, }, @@ -759,7 +759,7 @@ impl<'a> Context<'a> { self.arena.alloc(Stmt::Let(z, v, l, b)) } - AccessAtIndex { structure: x, .. } => { + StructAtIndex { 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 { diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index c60d529a5d..21607a7fc9 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -1186,7 +1186,7 @@ pub enum Expr<'a> { }, Struct(&'a [Symbol]), - AccessAtIndex { + StructAtIndex { index: u64, field_layouts: &'a [Layout<'a>], structure: Symbol, @@ -1350,7 +1350,7 @@ impl<'a> Expr<'a> { } EmptyArray => alloc.text("Array []"), - AccessAtIndex { + StructAtIndex { index, structure, .. } => alloc .text(format!("Index {} ", index)) @@ -2173,7 +2173,7 @@ fn specialize_external<'a>( ); for (index, (symbol, _variable)) in captured.iter().enumerate() { - let expr = Expr::AccessAtIndex { + let expr = Expr::StructAtIndex { index: index as _, field_layouts, structure: Symbol::ARG_CLOSURE, @@ -3475,7 +3475,7 @@ pub fn with_hole<'a>( hole } _ => { - let expr = Expr::AccessAtIndex { + let expr = Expr::StructAtIndex { index: index.expect("field not in its own type") as u64, field_layouts: field_layouts.into_bump_slice(), structure: record_symbol, @@ -3679,7 +3679,7 @@ pub fn with_hole<'a>( ); } CopyExisting(index) => { - let access_expr = Expr::AccessAtIndex { + let access_expr = Expr::StructAtIndex { structure, index, field_layouts, @@ -5538,13 +5538,13 @@ fn substitute_in_expr<'a>( } } - AccessAtIndex { + StructAtIndex { index, structure, field_layouts, wrapped, } => match substitute(subs, *structure) { - Some(structure) => Some(AccessAtIndex { + Some(structure) => Some(StructAtIndex { index: *index, field_layouts: *field_layouts, wrapped: *wrapped, @@ -5831,7 +5831,7 @@ fn store_newtype_pattern<'a>( arg_layout = *layout; } - let load = Expr::AccessAtIndex { + let load = Expr::StructAtIndex { wrapped: Wrapped::RecordOrSingleTagUnion, index: index as u64, field_layouts: arg_layouts.clone().into_bump_slice(), @@ -5895,7 +5895,7 @@ fn store_record_destruct<'a>( use Pattern::*; // TODO wrapped could be SingleElementRecord - let load = Expr::AccessAtIndex { + let load = Expr::StructAtIndex { index, field_layouts: sorted_fields, structure: outer_symbol,