mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
Get rid of passing target_info a bunch
This commit is contained in:
parent
8495f3b085
commit
bc41db2a34
18 changed files with 154 additions and 287 deletions
|
@ -16,7 +16,7 @@ use super::struct_::RocStruct;
|
|||
|
||||
pub fn basic_type_from_layout<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &'env STLayoutInterner<'a>,
|
||||
layout_interner: &STLayoutInterner<'a>,
|
||||
layout: LayoutRepr<'_>,
|
||||
) -> BasicTypeEnum<'ctx> {
|
||||
use LayoutRepr::*;
|
||||
|
@ -81,32 +81,25 @@ pub fn struct_type_from_union_layout<'a, 'ctx>(
|
|||
match union_layout {
|
||||
NonRecursive([]) => env.context.struct_type(&[], false),
|
||||
NonRecursive(tags) => {
|
||||
RocUnion::tagged_from_slices(layout_interner, env.context, tags, env.target_info)
|
||||
.struct_type()
|
||||
RocUnion::tagged_from_slices(layout_interner, env.context, tags).struct_type()
|
||||
}
|
||||
Recursive(tags)
|
||||
| NullableWrapped {
|
||||
other_tags: tags, ..
|
||||
} => {
|
||||
if union_layout.stores_tag_id_as_data(env.target_info) {
|
||||
RocUnion::tagged_from_slices(layout_interner, env.context, tags, env.target_info)
|
||||
.struct_type()
|
||||
RocUnion::tagged_from_slices(layout_interner, env.context, tags).struct_type()
|
||||
} else {
|
||||
RocUnion::untagged_from_slices(layout_interner, env.context, tags, env.target_info)
|
||||
.struct_type()
|
||||
RocUnion::untagged_from_slices(layout_interner, env.context, tags).struct_type()
|
||||
}
|
||||
}
|
||||
NullableUnwrapped { other_fields, .. } => RocUnion::untagged_from_slices(
|
||||
layout_interner,
|
||||
env.context,
|
||||
&[other_fields],
|
||||
env.target_info,
|
||||
)
|
||||
.struct_type(),
|
||||
NonNullableUnwrapped(fields) => {
|
||||
RocUnion::untagged_from_slices(layout_interner, env.context, &[fields], env.target_info)
|
||||
NullableUnwrapped { other_fields, .. } => {
|
||||
RocUnion::untagged_from_slices(layout_interner, env.context, &[other_fields])
|
||||
.struct_type()
|
||||
}
|
||||
NonNullableUnwrapped(fields) => {
|
||||
RocUnion::untagged_from_slices(layout_interner, env.context, &[fields]).struct_type()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -289,7 +282,6 @@ impl<'ctx> RocUnion<'ctx> {
|
|||
|
||||
fn new(
|
||||
context: &'ctx Context,
|
||||
_target_info: TargetInfo,
|
||||
data_align: u32,
|
||||
data_width: u32,
|
||||
tag_type: Option<TagType>,
|
||||
|
@ -353,7 +345,6 @@ impl<'ctx> RocUnion<'ctx> {
|
|||
interner: &STLayoutInterner,
|
||||
context: &'ctx Context,
|
||||
layouts: &[&[InLayout<'_>]],
|
||||
target_info: TargetInfo,
|
||||
) -> Self {
|
||||
let tag_type = match layouts.len() {
|
||||
0 => unreachable!("zero-element tag union is not represented as a RocUnion"),
|
||||
|
@ -361,22 +352,19 @@ impl<'ctx> RocUnion<'ctx> {
|
|||
_ => TagType::I16,
|
||||
};
|
||||
|
||||
let (data_width, data_align) =
|
||||
Layout::stack_size_and_alignment_slices(interner, layouts, target_info);
|
||||
let (data_width, data_align) = Layout::stack_size_and_alignment_slices(interner, layouts);
|
||||
|
||||
Self::new(context, target_info, data_align, data_width, Some(tag_type))
|
||||
Self::new(context, data_align, data_width, Some(tag_type))
|
||||
}
|
||||
|
||||
pub fn untagged_from_slices(
|
||||
interner: &STLayoutInterner,
|
||||
context: &'ctx Context,
|
||||
layouts: &[&[InLayout<'_>]],
|
||||
target_info: TargetInfo,
|
||||
) -> Self {
|
||||
let (data_width, data_align) =
|
||||
Layout::stack_size_and_alignment_slices(interner, layouts, target_info);
|
||||
let (data_width, data_align) = Layout::stack_size_and_alignment_slices(interner, layouts);
|
||||
|
||||
Self::new(context, target_info, data_align, data_width, None)
|
||||
Self::new(context, data_align, data_width, None)
|
||||
}
|
||||
|
||||
pub fn data_width(&self) -> u32 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue