mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
Remove insert_direct_no_semantic in compare eq
This commit is contained in:
parent
7ab044d79f
commit
6139918e3b
7 changed files with 89 additions and 118 deletions
|
@ -1291,7 +1291,12 @@ pub(crate) fn build_exp_expr<'a, 'ctx>(
|
|||
let (value, layout) = scope.load_symbol_and_layout(structure);
|
||||
let struct_val = RocStruct::from(value);
|
||||
|
||||
struct_val.load_at_index(env, layout_interner, layout, *index)
|
||||
struct_val.load_at_index(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_interner.get_repr(layout),
|
||||
*index,
|
||||
)
|
||||
}
|
||||
|
||||
EmptyArray => empty_polymorphic_list(env),
|
||||
|
|
|
@ -384,14 +384,9 @@ pub(crate) fn list_replace_unsafe<'a, 'ctx>(
|
|||
[Layout::LIST_U8 /* any list works */, element_layout]
|
||||
};
|
||||
// TODO: have use_roc_value take LayoutRepr
|
||||
let result_layout =
|
||||
layout_interner.insert_direct_no_semantic(LayoutRepr::Struct(env.arena.alloc(fields)));
|
||||
let result_struct_type = basic_type_from_layout(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_interner.get_repr(result_layout),
|
||||
)
|
||||
.into_struct_type();
|
||||
let result_layout = LayoutRepr::Struct(env.arena.alloc(fields));
|
||||
let result_struct_type =
|
||||
basic_type_from_layout(env, layout_interner, result_layout).into_struct_type();
|
||||
|
||||
let result = result_struct_type.const_zero();
|
||||
|
||||
|
@ -410,7 +405,7 @@ pub(crate) fn list_replace_unsafe<'a, 'ctx>(
|
|||
use_roc_value(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_interner.get_repr(result_layout),
|
||||
result_layout,
|
||||
result.into_struct_value().into(),
|
||||
"use_replace_result_record",
|
||||
)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::llvm::build::Env;
|
||||
use inkwell::values::{BasicValueEnum, PointerValue};
|
||||
use roc_builtins::bitcode;
|
||||
use roc_mono::layout::{InLayout, Layout, LayoutInterner, LayoutRepr, STLayoutInterner};
|
||||
use roc_mono::layout::{InLayout, Layout, LayoutRepr, STLayoutInterner};
|
||||
|
||||
use super::bitcode::{call_str_bitcode_fn, BitcodeReturns};
|
||||
use super::build::load_roc_value;
|
||||
|
@ -10,7 +10,7 @@ pub static CHAR_LAYOUT: InLayout = Layout::U8;
|
|||
|
||||
pub(crate) fn decode_from_utf8_result<'a, 'ctx>(
|
||||
env: &Env<'a, 'ctx, '_>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_interner: &STLayoutInterner<'a>,
|
||||
pointer: PointerValue<'ctx>,
|
||||
) -> BasicValueEnum<'ctx> {
|
||||
let layout = LayoutRepr::Struct(env.arena.alloc([
|
||||
|
@ -19,13 +19,11 @@ pub(crate) fn decode_from_utf8_result<'a, 'ctx>(
|
|||
Layout::BOOL,
|
||||
Layout::U8,
|
||||
]));
|
||||
// TODO: have load_roc_value use LayoutRepr
|
||||
let layout = layout_interner.insert_direct_no_semantic(layout);
|
||||
|
||||
load_roc_value(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_interner.get_repr(layout),
|
||||
layout,
|
||||
pointer,
|
||||
"load_decode_from_utf8_result",
|
||||
)
|
||||
|
|
|
@ -34,8 +34,8 @@ pub fn generic_eq<'a, 'ctx>(
|
|||
layout_ids,
|
||||
lhs_val,
|
||||
rhs_val,
|
||||
lhs_layout,
|
||||
rhs_layout,
|
||||
layout_interner.get_repr(lhs_layout),
|
||||
layout_interner.get_repr(rhs_layout),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ fn build_eq_builtin<'a, 'ctx>(
|
|||
layout_ids: &mut LayoutIds<'a>,
|
||||
lhs_val: BasicValueEnum<'ctx>,
|
||||
rhs_val: BasicValueEnum<'ctx>,
|
||||
builtin_layout: InLayout<'a>,
|
||||
builtin_layout: LayoutRepr<'a>,
|
||||
builtin: &Builtin<'a>,
|
||||
) -> BasicValueEnum<'ctx> {
|
||||
let int_cmp = |pred, label| {
|
||||
|
@ -130,7 +130,7 @@ fn build_eq_builtin<'a, 'ctx>(
|
|||
layout_interner,
|
||||
layout_ids,
|
||||
builtin_layout,
|
||||
*elem,
|
||||
layout_interner.get_repr(*elem),
|
||||
lhs_val.into_struct_value(),
|
||||
rhs_val.into_struct_value(),
|
||||
),
|
||||
|
@ -143,26 +143,23 @@ fn build_eq<'a, 'ctx>(
|
|||
layout_ids: &mut LayoutIds<'a>,
|
||||
lhs_val: BasicValueEnum<'ctx>,
|
||||
rhs_val: BasicValueEnum<'ctx>,
|
||||
lhs_layout: InLayout<'a>,
|
||||
rhs_layout: InLayout<'a>,
|
||||
lhs_layout: LayoutRepr<'a>,
|
||||
rhs_layout: LayoutRepr<'a>,
|
||||
) -> BasicValueEnum<'ctx> {
|
||||
let lhs_layout = &layout_interner.runtime_representation_in(lhs_layout);
|
||||
let rhs_layout = &layout_interner.runtime_representation_in(rhs_layout);
|
||||
debug_assert!(
|
||||
layout_interner.eq_repr(*lhs_layout, *rhs_layout),
|
||||
debug_assert_eq!(
|
||||
lhs_layout, rhs_layout,
|
||||
"Equality of different layouts; did you have a type mismatch?\n{:?} == {:?}",
|
||||
lhs_layout,
|
||||
rhs_layout
|
||||
lhs_layout, rhs_layout
|
||||
);
|
||||
|
||||
match layout_interner.get_repr(*lhs_layout) {
|
||||
match lhs_layout {
|
||||
LayoutRepr::Builtin(builtin) => build_eq_builtin(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
lhs_val,
|
||||
rhs_val,
|
||||
*lhs_layout,
|
||||
lhs_layout,
|
||||
&builtin,
|
||||
),
|
||||
|
||||
|
@ -170,7 +167,7 @@ fn build_eq<'a, 'ctx>(
|
|||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
*lhs_layout,
|
||||
lhs_layout,
|
||||
field_layouts,
|
||||
lhs_val,
|
||||
rhs_val,
|
||||
|
@ -182,7 +179,7 @@ fn build_eq<'a, 'ctx>(
|
|||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
*lhs_layout,
|
||||
lhs_layout,
|
||||
&union_layout,
|
||||
lhs_val,
|
||||
rhs_val,
|
||||
|
@ -192,7 +189,7 @@ fn build_eq<'a, 'ctx>(
|
|||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
*lhs_layout,
|
||||
lhs_layout,
|
||||
inner_layout,
|
||||
lhs_val,
|
||||
rhs_val,
|
||||
|
@ -228,7 +225,7 @@ fn build_eq<'a, 'ctx>(
|
|||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
rec_layout,
|
||||
layout_interner.get_repr(rec_layout),
|
||||
&union_layout,
|
||||
field1_cast.into(),
|
||||
field2_cast.into(),
|
||||
|
@ -313,8 +310,8 @@ fn build_neq_builtin<'a, 'ctx>(
|
|||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
builtin_layout,
|
||||
*elem,
|
||||
layout_interner.get_repr(builtin_layout),
|
||||
layout_interner.get_repr(*elem),
|
||||
lhs_val.into_struct_value(),
|
||||
rhs_val.into_struct_value(),
|
||||
)
|
||||
|
@ -359,7 +356,7 @@ fn build_neq<'a, 'ctx>(
|
|||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
lhs_layout,
|
||||
layout_interner.get_repr(lhs_layout),
|
||||
field_layouts,
|
||||
lhs_val,
|
||||
rhs_val,
|
||||
|
@ -376,7 +373,7 @@ fn build_neq<'a, 'ctx>(
|
|||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
lhs_layout,
|
||||
layout_interner.get_repr(lhs_layout),
|
||||
&union_layout,
|
||||
lhs_val,
|
||||
rhs_val,
|
||||
|
@ -393,7 +390,7 @@ fn build_neq<'a, 'ctx>(
|
|||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
lhs_layout,
|
||||
layout_interner.get_repr(lhs_layout),
|
||||
inner_layout,
|
||||
lhs_val,
|
||||
rhs_val,
|
||||
|
@ -416,8 +413,8 @@ fn build_list_eq<'a, 'ctx>(
|
|||
env: &Env<'a, 'ctx, '_>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
list_layout: InLayout<'a>,
|
||||
element_layout: InLayout<'a>,
|
||||
list_layout: LayoutRepr<'a>,
|
||||
element_layout: LayoutRepr<'a>,
|
||||
list1: StructValue<'ctx>,
|
||||
list2: StructValue<'ctx>,
|
||||
) -> BasicValueEnum<'ctx> {
|
||||
|
@ -425,21 +422,19 @@ fn build_list_eq<'a, 'ctx>(
|
|||
let di_location = env.builder.get_current_debug_location().unwrap();
|
||||
|
||||
let symbol = Symbol::LIST_EQ;
|
||||
let element_layout =
|
||||
if let LayoutRepr::RecursivePointer(rec) = layout_interner.get_repr(element_layout) {
|
||||
rec
|
||||
} else {
|
||||
element_layout
|
||||
};
|
||||
let element_layout = if let LayoutRepr::RecursivePointer(rec) = element_layout {
|
||||
layout_interner.get_repr(rec)
|
||||
} else {
|
||||
element_layout
|
||||
};
|
||||
let fn_name = layout_ids
|
||||
.get(symbol, &layout_interner.get_repr(element_layout))
|
||||
.get(symbol, &element_layout)
|
||||
.to_symbol_string(symbol, &env.interns);
|
||||
|
||||
let function = match env.module.get_function(fn_name.as_str()) {
|
||||
Some(function_value) => function_value,
|
||||
None => {
|
||||
let arg_type =
|
||||
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(list_layout));
|
||||
let arg_type = basic_type_from_layout(env, layout_interner, list_layout);
|
||||
|
||||
let function_value = crate::llvm::refcounting::build_header_help(
|
||||
env,
|
||||
|
@ -476,7 +471,7 @@ fn build_list_eq_help<'a, 'ctx>(
|
|||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
parent: FunctionValue<'ctx>,
|
||||
element_layout: InLayout<'a>,
|
||||
element_layout: LayoutRepr<'a>,
|
||||
) {
|
||||
let ctx = env.context;
|
||||
let builder = env.builder;
|
||||
|
@ -535,11 +530,7 @@ fn build_list_eq_help<'a, 'ctx>(
|
|||
env.builder.position_at_end(then_block);
|
||||
|
||||
let builder = env.builder;
|
||||
let element_type = basic_type_from_layout(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_interner.get_repr(element_layout),
|
||||
);
|
||||
let element_type = basic_type_from_layout(env, layout_interner, element_layout);
|
||||
let ptr_type = element_type.ptr_type(AddressSpace::default());
|
||||
let ptr1 = load_list_ptr(env.builder, list1, ptr_type);
|
||||
let ptr2 = load_list_ptr(env.builder, list2, ptr_type);
|
||||
|
@ -579,26 +570,14 @@ fn build_list_eq_help<'a, 'ctx>(
|
|||
let elem_ptr = unsafe {
|
||||
builder.new_build_in_bounds_gep(element_type, ptr1, &[curr_index], "load_index")
|
||||
};
|
||||
load_roc_value(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_interner.get_repr(element_layout),
|
||||
elem_ptr,
|
||||
"get_elem",
|
||||
)
|
||||
load_roc_value(env, layout_interner, element_layout, elem_ptr, "get_elem")
|
||||
};
|
||||
|
||||
let elem2 = {
|
||||
let elem_ptr = unsafe {
|
||||
builder.new_build_in_bounds_gep(element_type, ptr2, &[curr_index], "load_index")
|
||||
};
|
||||
load_roc_value(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_interner.get_repr(element_layout),
|
||||
elem_ptr,
|
||||
"get_elem",
|
||||
)
|
||||
load_roc_value(env, layout_interner, element_layout, elem_ptr, "get_elem")
|
||||
};
|
||||
|
||||
let are_equal = build_eq(
|
||||
|
@ -649,7 +628,7 @@ fn build_struct_eq<'a, 'ctx>(
|
|||
env: &Env<'a, 'ctx, '_>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
struct_layout: InLayout<'a>,
|
||||
struct_layout: LayoutRepr<'a>,
|
||||
field_layouts: &'a [InLayout<'a>],
|
||||
struct1: BasicValueEnum<'ctx>,
|
||||
struct2: BasicValueEnum<'ctx>,
|
||||
|
@ -659,17 +638,13 @@ fn build_struct_eq<'a, 'ctx>(
|
|||
|
||||
let symbol = Symbol::GENERIC_EQ;
|
||||
let fn_name = layout_ids
|
||||
.get(symbol, &layout_interner.get_repr(struct_layout))
|
||||
.get(symbol, &struct_layout)
|
||||
.to_symbol_string(symbol, &env.interns);
|
||||
|
||||
let function = match env.module.get_function(fn_name.as_str()) {
|
||||
Some(function_value) => function_value,
|
||||
None => {
|
||||
let arg_type = argument_type_from_layout(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_interner.get_repr(struct_layout),
|
||||
);
|
||||
let arg_type = argument_type_from_layout(env, layout_interner, struct_layout);
|
||||
|
||||
let function_value = crate::llvm::refcounting::build_header_help(
|
||||
env,
|
||||
|
@ -707,7 +682,7 @@ fn build_struct_eq_help<'a, 'ctx>(
|
|||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
parent: FunctionValue<'ctx>,
|
||||
struct_layout: InLayout<'a>,
|
||||
struct_layout: LayoutRepr<'a>,
|
||||
field_layouts: &[InLayout<'a>],
|
||||
) {
|
||||
let ctx = env.context;
|
||||
|
@ -803,8 +778,8 @@ fn build_struct_eq_help<'a, 'ctx>(
|
|||
layout_ids,
|
||||
field1_cast.into(),
|
||||
field2_cast.into(),
|
||||
field_layout,
|
||||
field_layout,
|
||||
layout_interner.get_repr(field_layout),
|
||||
layout_interner.get_repr(field_layout),
|
||||
)
|
||||
.into_int_value()
|
||||
} else {
|
||||
|
@ -814,8 +789,8 @@ fn build_struct_eq_help<'a, 'ctx>(
|
|||
layout_ids,
|
||||
field1,
|
||||
field2,
|
||||
*field_layout,
|
||||
*field_layout,
|
||||
layout_interner.get_repr(*field_layout),
|
||||
layout_interner.get_repr(*field_layout),
|
||||
)
|
||||
.into_int_value()
|
||||
};
|
||||
|
@ -846,7 +821,7 @@ fn build_tag_eq<'a, 'ctx>(
|
|||
env: &Env<'a, 'ctx, '_>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
tag_layout: InLayout<'a>,
|
||||
tag_layout: LayoutRepr<'a>,
|
||||
union_layout: &UnionLayout<'a>,
|
||||
tag1: BasicValueEnum<'ctx>,
|
||||
tag2: BasicValueEnum<'ctx>,
|
||||
|
@ -856,7 +831,7 @@ fn build_tag_eq<'a, 'ctx>(
|
|||
|
||||
let symbol = Symbol::GENERIC_EQ;
|
||||
let fn_name = layout_ids
|
||||
.get(symbol, &layout_interner.get_repr(tag_layout))
|
||||
.get(symbol, &tag_layout)
|
||||
.to_symbol_string(symbol, &env.interns);
|
||||
|
||||
let function = match env.module.get_function(fn_name.as_str()) {
|
||||
|
@ -1002,8 +977,7 @@ fn build_tag_eq_help<'a, 'ctx>(
|
|||
let block = env.context.append_basic_block(parent, "tag_id_modify");
|
||||
env.builder.position_at_end(block);
|
||||
|
||||
let struct_layout =
|
||||
layout_interner.insert_direct_no_semantic(LayoutRepr::struct_(field_layouts));
|
||||
let struct_layout = LayoutRepr::struct_(field_layouts);
|
||||
|
||||
let answer = eq_ptr_to_struct(
|
||||
env,
|
||||
|
@ -1075,8 +1049,7 @@ fn build_tag_eq_help<'a, 'ctx>(
|
|||
let block = env.context.append_basic_block(parent, "tag_id_modify");
|
||||
env.builder.position_at_end(block);
|
||||
|
||||
let struct_layout =
|
||||
layout_interner.insert_direct_no_semantic(LayoutRepr::struct_(field_layouts));
|
||||
let struct_layout = LayoutRepr::struct_(field_layouts);
|
||||
|
||||
let answer = eq_ptr_to_struct(
|
||||
env,
|
||||
|
@ -1138,8 +1111,7 @@ fn build_tag_eq_help<'a, 'ctx>(
|
|||
|
||||
env.builder.position_at_end(compare_other);
|
||||
|
||||
let struct_layout =
|
||||
layout_interner.insert_direct_no_semantic(LayoutRepr::struct_(other_fields));
|
||||
let struct_layout = LayoutRepr::struct_(other_fields);
|
||||
|
||||
let answer = eq_ptr_to_struct(
|
||||
env,
|
||||
|
@ -1243,8 +1215,7 @@ fn build_tag_eq_help<'a, 'ctx>(
|
|||
let block = env.context.append_basic_block(parent, "tag_id_modify");
|
||||
env.builder.position_at_end(block);
|
||||
|
||||
let struct_layout =
|
||||
layout_interner.insert_direct_no_semantic(LayoutRepr::struct_(field_layouts));
|
||||
let struct_layout = LayoutRepr::struct_(field_layouts);
|
||||
|
||||
let answer = eq_ptr_to_struct(
|
||||
env,
|
||||
|
@ -1284,8 +1255,7 @@ fn build_tag_eq_help<'a, 'ctx>(
|
|||
|
||||
env.builder.position_at_end(compare_fields);
|
||||
|
||||
let struct_layout =
|
||||
layout_interner.insert_direct_no_semantic(LayoutRepr::struct_(field_layouts));
|
||||
let struct_layout = LayoutRepr::struct_(field_layouts);
|
||||
|
||||
let answer = eq_ptr_to_struct(
|
||||
env,
|
||||
|
@ -1306,16 +1276,12 @@ fn eq_ptr_to_struct<'a, 'ctx>(
|
|||
env: &Env<'a, 'ctx, '_>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
struct_layout: InLayout<'a>,
|
||||
struct_layout: LayoutRepr<'a>,
|
||||
field_layouts: &'a [InLayout<'a>],
|
||||
tag1: PointerValue<'ctx>,
|
||||
tag2: PointerValue<'ctx>,
|
||||
) -> IntValue<'ctx> {
|
||||
let wrapper_type = basic_type_from_layout(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_interner.get_repr(struct_layout),
|
||||
);
|
||||
let wrapper_type = basic_type_from_layout(env, layout_interner, struct_layout);
|
||||
debug_assert!(wrapper_type.is_struct_type());
|
||||
|
||||
// cast the opaque pointer to a pointer of the correct shape
|
||||
|
@ -1334,14 +1300,14 @@ fn eq_ptr_to_struct<'a, 'ctx>(
|
|||
let struct1 = load_roc_value(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_interner.get_repr(struct_layout),
|
||||
struct_layout,
|
||||
struct1_ptr,
|
||||
"load_struct1",
|
||||
);
|
||||
let struct2 = load_roc_value(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_interner.get_repr(struct_layout),
|
||||
struct_layout,
|
||||
struct2_ptr,
|
||||
"load_struct2",
|
||||
);
|
||||
|
@ -1364,7 +1330,7 @@ fn build_box_eq<'a, 'ctx>(
|
|||
env: &Env<'a, 'ctx, '_>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
box_layout: InLayout<'a>,
|
||||
box_layout: LayoutRepr<'a>,
|
||||
inner_layout: InLayout<'a>,
|
||||
tag1: BasicValueEnum<'ctx>,
|
||||
tag2: BasicValueEnum<'ctx>,
|
||||
|
@ -1374,14 +1340,13 @@ fn build_box_eq<'a, 'ctx>(
|
|||
|
||||
let symbol = Symbol::GENERIC_EQ;
|
||||
let fn_name = layout_ids
|
||||
.get(symbol, &layout_interner.get_repr(box_layout))
|
||||
.get(symbol, &box_layout)
|
||||
.to_symbol_string(symbol, &env.interns);
|
||||
|
||||
let function = match env.module.get_function(fn_name.as_str()) {
|
||||
Some(function_value) => function_value,
|
||||
None => {
|
||||
let arg_type =
|
||||
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(box_layout));
|
||||
let arg_type = basic_type_from_layout(env, layout_interner, box_layout);
|
||||
|
||||
let function_value = crate::llvm::refcounting::build_header_help(
|
||||
env,
|
||||
|
@ -1503,8 +1468,8 @@ fn build_box_eq_help<'a, 'ctx>(
|
|||
layout_ids,
|
||||
value1,
|
||||
value2,
|
||||
inner_layout,
|
||||
inner_layout,
|
||||
layout_interner.get_repr(inner_layout),
|
||||
layout_interner.get_repr(inner_layout),
|
||||
);
|
||||
|
||||
env.builder.build_return(Some(&is_equal));
|
||||
|
|
|
@ -447,7 +447,12 @@ fn build_clone_struct<'a, 'ctx>(
|
|||
let structure = RocStruct::from(value);
|
||||
|
||||
for (i, field_layout) in field_layouts.iter().enumerate() {
|
||||
let field = structure.load_at_index(env, layout_interner, struct_layout, i as _);
|
||||
let field = structure.load_at_index(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_interner.get_repr(struct_layout),
|
||||
i as _,
|
||||
);
|
||||
|
||||
let new_extra = build_clone(
|
||||
env,
|
||||
|
|
|
@ -337,8 +337,12 @@ fn modify_refcount_struct_help<'a, 'ctx>(
|
|||
|
||||
for (i, field_layout) in field_layouts.iter().enumerate() {
|
||||
if layout_interner.contains_refcounted(*field_layout) {
|
||||
let field_value =
|
||||
wrapper_struct.load_at_index(env, layout_interner, struct_layout, i as _);
|
||||
let field_value = wrapper_struct.load_at_index(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_interner.get_repr(struct_layout),
|
||||
i as _,
|
||||
);
|
||||
|
||||
modify_refcount_layout_help(
|
||||
env,
|
||||
|
|
|
@ -78,17 +78,16 @@ impl<'ctx> RocStruct<'ctx> {
|
|||
&self,
|
||||
env: &Env<'a, 'ctx, '_>,
|
||||
layout_interner: &STLayoutInterner<'a>,
|
||||
struct_layout: InLayout<'a>,
|
||||
struct_layout: LayoutRepr<'a>,
|
||||
index: u64,
|
||||
) -> BasicValueEnum<'ctx> {
|
||||
let layout =
|
||||
if let LayoutRepr::LambdaSet(lambda_set) = layout_interner.get_repr(struct_layout) {
|
||||
lambda_set.runtime_representation()
|
||||
} else {
|
||||
struct_layout
|
||||
};
|
||||
let layout = if let LayoutRepr::LambdaSet(lambda_set) = struct_layout {
|
||||
layout_interner.get_repr(lambda_set.runtime_representation())
|
||||
} else {
|
||||
struct_layout
|
||||
};
|
||||
|
||||
match (self, layout_interner.get_repr(layout)) {
|
||||
match (self, layout) {
|
||||
(Self::ByValue(argument), LayoutRepr::Struct(field_layouts)) => {
|
||||
index_struct_value(env, layout_interner, field_layouts, *argument, index)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue