Inline RocStructType back in

This commit is contained in:
Ayaz Hafiz 2023-06-13 13:51:46 -05:00
parent 7b1dc7eff0
commit c09a33f9f4
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 21 additions and 49 deletions

View file

@ -1,5 +1,5 @@
use crate::llvm::build::{BuilderExt, Env};
use crate::llvm::struct_::RocStructType;
use bumpalo::collections::Vec as AVec;
use inkwell::context::Context;
use inkwell::types::{BasicType, BasicTypeEnum, FloatType, IntType, StructType};
use inkwell::values::StructValue;
@ -22,7 +22,7 @@ pub fn basic_type_from_layout<'a, 'ctx, 'env>(
match layout_interner.get_repr(layout) {
Struct(sorted_fields, ..) => {
RocStructType::build(env, layout_interner, sorted_fields).into()
basic_type_from_record(env, layout_interner, sorted_fields).into()
}
LambdaSet(lambda_set) => {
basic_type_from_layout(env, layout_interner, lambda_set.runtime_representation())
@ -43,6 +43,23 @@ pub fn basic_type_from_layout<'a, 'ctx, 'env>(
}
}
fn basic_type_from_record<'a, 'ctx>(
env: &Env<'a, 'ctx, '_>,
layout_interner: &mut STLayoutInterner<'a>,
fields: &[InLayout<'_>],
) -> StructType<'ctx> {
let mut field_types = AVec::with_capacity_in(fields.len(), env.arena);
for field_layout in fields.iter() {
let typ = basic_type_from_layout(env, layout_interner, *field_layout);
field_types.push(typ);
}
env.context
.struct_type(field_types.into_bump_slice(), false)
}
pub fn struct_type_from_union_layout<'a, 'ctx>(
env: &Env<'a, 'ctx, '_>,
layout_interner: &mut STLayoutInterner<'a>,
@ -82,7 +99,7 @@ pub fn struct_type_from_union_layout<'a, 'ctx>(
}
}
pub fn basic_type_from_union_layout<'a, 'ctx>(
fn basic_type_from_union_layout<'a, 'ctx>(
env: &Env<'a, 'ctx, '_>,
layout_interner: &mut STLayoutInterner<'a>,
union_layout: &UnionLayout<'_>,