mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
WIP
This commit is contained in:
parent
8add147dcf
commit
99d0d9c732
8 changed files with 40 additions and 83 deletions
|
@ -109,8 +109,6 @@ impl<'a> UnionLayout<'a> {
|
|||
pub fn layout_at(self, tag_id: u8, index: usize) -> Layout<'a> {
|
||||
let result = match self {
|
||||
UnionLayout::NonRecursive(tag_layouts) => {
|
||||
let index = index - 1;
|
||||
|
||||
let field_layouts = tag_layouts[tag_id as usize];
|
||||
|
||||
// this cannot be recursive; return immediately
|
||||
|
@ -1193,15 +1191,12 @@ fn layout_from_flat_type<'a>(
|
|||
env.insert_seen(rec_var);
|
||||
for (index, (_name, variables)) in tags_vec.into_iter().enumerate() {
|
||||
if matches!(nullable, Some(i) if i == index as i64) {
|
||||
// don't add the
|
||||
// don't add the nullable case
|
||||
continue;
|
||||
}
|
||||
|
||||
let mut tag_layout = Vec::with_capacity_in(variables.len() + 1, arena);
|
||||
|
||||
// store the discriminant
|
||||
tag_layout.push(Layout::Builtin(TAG_SIZE));
|
||||
|
||||
for var in variables {
|
||||
// TODO does this cause problems with mutually recursive unions?
|
||||
if rec_var == subs.get_root_key_without_compacting(var) {
|
||||
|
@ -1242,7 +1237,7 @@ fn layout_from_flat_type<'a>(
|
|||
}
|
||||
} else if tag_layouts.len() == 1 {
|
||||
// drop the tag id
|
||||
UnionLayout::NonNullableUnwrapped(&tag_layouts.pop().unwrap()[1..])
|
||||
UnionLayout::NonNullableUnwrapped(&tag_layouts.pop().unwrap())
|
||||
} else {
|
||||
UnionLayout::Recursive(tag_layouts.into_bump_slice())
|
||||
};
|
||||
|
@ -1584,11 +1579,6 @@ pub fn union_sorted_tags_help<'a>(
|
|||
|
||||
let mut arg_layouts = Vec::with_capacity_in(arguments.len() + 1, arena);
|
||||
|
||||
// add the tag discriminant (size currently always hardcoded to i64)
|
||||
if is_recursive {
|
||||
arg_layouts.push(Layout::Builtin(TAG_SIZE));
|
||||
}
|
||||
|
||||
for var in arguments {
|
||||
match Layout::from_var(&mut env, var) {
|
||||
Ok(layout) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue