remove MultiTagUnion

This commit is contained in:
Folkert 2021-06-21 21:03:37 +02:00
parent 8a36c20559
commit 65f4ff9663
4 changed files with 7 additions and 25 deletions

View file

@ -900,17 +900,6 @@ fn expr_spec(
let result_type = layout_spec(builder, layout)?; let result_type = layout_spec(builder, layout)?;
builder.add_unknown_with(block, &[value_id], result_type) builder.add_unknown_with(block, &[value_id], result_type)
} }
Wrapped::MultiTagUnion => {
// Clearly this is not generally correct, but it should be for our examples
// let hacky_is_recursive = field_layouts.iter().any(|l| l == &Layout::RecursivePointer);
// if hacky_is_recursive {
// we don't know what constructor we are at this point, so how can we get a
// field from an enum value?
let result_type = layout_spec(builder, layout)?;
builder.add_unknown_with(block, &[value_id], result_type)
}
} }
} }
Array { elem_layout, elems } => { Array { elem_layout, elems } => {

View file

@ -191,7 +191,7 @@ impl<'a, 'i> Env<'a, 'i> {
Symbol::new(self.home, ident_id) Symbol::new(self.home, ident_id)
} }
#[allow(dead_code)]
fn manual_unique_symbol(home: ModuleId, ident_ids: &mut IdentIds) -> Symbol { fn manual_unique_symbol(home: ModuleId, ident_ids: &mut IdentIds) -> Symbol {
let ident_id = ident_ids.gen_unique(); let ident_id = ident_ids.gen_unique();
@ -302,11 +302,13 @@ fn work_for_constructor<'a>(
// we have to extract it now, but we only extract it // we have to extract it now, but we only extract it
// if at least one field is aliased. // if at least one field is aliased.
todo!("get the tag id");
/*
let expr = Expr::AccessAtIndex { let expr = Expr::AccessAtIndex {
index: i as u64, index: i as u64,
field_layouts: constructor_layout, field_layouts: constructor_layout,
structure: *symbol, structure: *symbol,
wrapped: Wrapped::MultiTagUnion, wrapped: todo!("get the tag id"),
}; };
// create a fresh symbol for this field // create a fresh symbol for this field
@ -320,6 +322,7 @@ fn work_for_constructor<'a>(
env.deferred.assignments.push((alias_symbol, expr, layout)); env.deferred.assignments.push((alias_symbol, expr, layout));
result.push(alias_symbol); result.push(alias_symbol);
*/
} }
None => { None => {
// if all refcounted fields were unaliased, generate a normal decrement // if all refcounted fields were unaliased, generate a normal decrement

View file

@ -1021,7 +1021,6 @@ pub enum Wrapped {
RecordOrSingleTagUnion, RecordOrSingleTagUnion,
/// Like a rose tree; recursive, but only one tag /// Like a rose tree; recursive, but only one tag
LikeARoseTree, LikeARoseTree,
MultiTagUnion,
} }
impl Wrapped { impl Wrapped {
@ -1033,14 +1032,7 @@ impl Wrapped {
} }
pub fn is_indexable(layout: &Layout<'_>) -> bool { pub fn is_indexable(layout: &Layout<'_>) -> bool {
match layout { matches!(layout, Layout::Struct(_) | Layout::Union(_))
Layout::Struct(fields) => match fields.len() {
_ => true,
},
Layout::Union(variant) => true,
_ => false,
}
} }
pub fn opt_from_layout(layout: &Layout<'_>) -> Option<Self> { pub fn opt_from_layout(layout: &Layout<'_>) -> Option<Self> {
@ -2141,8 +2133,6 @@ fn specialize_external<'a>(
(Some(closure_layout), CapturedSymbols::Captured(captured)) => { (Some(closure_layout), CapturedSymbols::Captured(captured)) => {
// debug_assert!(!captured.is_empty()); // debug_assert!(!captured.is_empty());
let wrapped = closure_layout.get_wrapped();
match closure_layout.layout_for_member(proc_name) { match closure_layout.layout_for_member(proc_name) {
ClosureRepresentation::Union { ClosureRepresentation::Union {
tag_layout: field_layouts, tag_layout: field_layouts,

View file

@ -392,7 +392,7 @@ impl<'a> LambdaSet<'a> {
match self.representation { match self.representation {
Layout::Struct(fields) if fields.len() == 1 => Wrapped::SingleElementRecord, Layout::Struct(fields) if fields.len() == 1 => Wrapped::SingleElementRecord,
Layout::Struct(_) => Wrapped::RecordOrSingleTagUnion, Layout::Struct(_) => Wrapped::RecordOrSingleTagUnion,
Layout::Union(_) => Wrapped::MultiTagUnion, Layout::Union(_) => unreachable!(),
_ => Wrapped::SingleElementRecord, _ => Wrapped::SingleElementRecord,
} }
} }