This commit is contained in:
Folkert 2021-06-21 23:02:49 +02:00
parent 368d45fb01
commit 205b168f16
8 changed files with 20 additions and 20 deletions

View File

@ -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, .. } => {

View File

@ -1423,7 +1423,7 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
Reset(_) => todo!(),
Reuse { .. } => todo!(),
AccessAtIndex {
StructAtIndex {
index,
structure,
wrapped: Wrapped::RecordOrSingleTagUnion,

View File

@ -874,7 +874,7 @@ fn expr_spec(
builder.add_unknown_with(block, &[value_id], result_type)
}
},
AccessAtIndex {
StructAtIndex {
index,
field_layouts: _,
structure,

View File

@ -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);

View File

@ -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,

View File

@ -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,

View File

@ -103,7 +103,7 @@ pub fn occurring_variables_expr(expr: &Expr<'_>, result: &mut MutSet<Symbol>) {
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 {

View File

@ -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,