mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 22:09:09 +00:00
remove tag_id in favor of index
This commit is contained in:
parent
347431d1df
commit
90223022af
8 changed files with 32 additions and 33 deletions
|
@ -2004,13 +2004,14 @@ pub(crate) fn build_exp_expr<'a, 'ctx>(
|
|||
}
|
||||
|
||||
UnionFieldPtrAtIndex {
|
||||
tag_id,
|
||||
structure,
|
||||
index,
|
||||
union_layout,
|
||||
..
|
||||
} => {
|
||||
debug_assert_ne!(index.len(), 0);
|
||||
let index = index[0] as usize;
|
||||
debug_assert!(index.len() >= 2);
|
||||
let tag_id = index[0];
|
||||
let index = index[1] as usize;
|
||||
// cast the argument bytes into the desired shape for this tag
|
||||
let argument = scope.load_symbol(structure);
|
||||
let ret_repr = layout_interner.get_repr(layout);
|
||||
|
@ -2020,7 +2021,7 @@ pub(crate) fn build_exp_expr<'a, 'ctx>(
|
|||
UnionLayout::Recursive(tag_layouts) => {
|
||||
debug_assert!(argument.is_pointer_value());
|
||||
|
||||
let field_layouts = tag_layouts[*tag_id as usize];
|
||||
let field_layouts = tag_layouts[tag_id as usize];
|
||||
|
||||
let ptr = tag_pointer_clear_tag_id(env, argument.into_pointer_value());
|
||||
let target_loaded_type = basic_type_from_layout(env, layout_interner, ret_repr);
|
||||
|
@ -2056,10 +2057,11 @@ pub(crate) fn build_exp_expr<'a, 'ctx>(
|
|||
other_tags,
|
||||
} => {
|
||||
debug_assert!(argument.is_pointer_value());
|
||||
debug_assert_ne!(*tag_id, *nullable_id);
|
||||
debug_assert_ne!(tag_id as u16, *nullable_id);
|
||||
|
||||
let tag_index = if *tag_id < *nullable_id {
|
||||
*tag_id
|
||||
let tag_id = tag_id as u16;
|
||||
let tag_index = if tag_id < *nullable_id {
|
||||
tag_id
|
||||
} else {
|
||||
tag_id - 1
|
||||
};
|
||||
|
@ -2084,7 +2086,7 @@ pub(crate) fn build_exp_expr<'a, 'ctx>(
|
|||
other_fields,
|
||||
} => {
|
||||
debug_assert!(argument.is_pointer_value());
|
||||
debug_assert_ne!(*tag_id != 0, *nullable_id);
|
||||
debug_assert_ne!(tag_id != 0, *nullable_id);
|
||||
|
||||
let field_layouts = other_fields;
|
||||
let struct_layout = LayoutRepr::struct_(field_layouts);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue