mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
Bringing in Trunk and resolving conflict
This commit is contained in:
commit
ec7d8e0dc9
28 changed files with 964 additions and 1130 deletions
|
@ -1266,24 +1266,12 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
|
|||
index,
|
||||
structure,
|
||||
wrapped: Wrapped::SingleElementRecord,
|
||||
field_layouts,
|
||||
..
|
||||
} => {
|
||||
match load_symbol_and_layout(env, scope, structure) {
|
||||
(StructValue(argument), Layout::Struct(fields)) if fields.len() > 1 =>
|
||||
// TODO so sometimes a value gets Wrapped::SingleElementRecord
|
||||
// but still has multiple fields...
|
||||
{
|
||||
env.builder
|
||||
.build_extract_value(
|
||||
argument,
|
||||
*index as u32,
|
||||
env.arena
|
||||
.alloc(format!("struct_field_access_single_element{}", index)),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
(other, _) => other,
|
||||
}
|
||||
debug_assert_eq!(field_layouts.len(), 1);
|
||||
debug_assert_eq!(*index, 0);
|
||||
load_symbol(env, scope, structure)
|
||||
}
|
||||
|
||||
AccessAtIndex {
|
||||
|
@ -2054,12 +2042,12 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
|
|||
// This doesn't currently do anything
|
||||
context.i64_type().const_zero().into()
|
||||
}
|
||||
Inc(symbol, cont) => {
|
||||
Inc(symbol, inc_amount, cont) => {
|
||||
let (value, layout) = load_symbol_and_layout(env, scope, symbol);
|
||||
let layout = layout.clone();
|
||||
|
||||
if layout.contains_refcounted() {
|
||||
increment_refcount_layout(env, parent, layout_ids, value, &layout);
|
||||
increment_refcount_layout(env, parent, layout_ids, *inc_amount, value, &layout);
|
||||
}
|
||||
|
||||
build_exp_stmt(env, layout_ids, scope, parent, cont)
|
||||
|
@ -2192,24 +2180,34 @@ pub fn complex_bitcast<'ctx>(
|
|||
) -> BasicValueEnum<'ctx> {
|
||||
use inkwell::types::BasicType;
|
||||
|
||||
// we can't use the more simple
|
||||
// builder.build_bitcast(from_value, to_type, "cast_basic_basic")
|
||||
// because this does not allow some (valid) bitcasts
|
||||
|
||||
// store the value in memory
|
||||
let argument_pointer = builder.build_alloca(from_value.get_type(), "cast_alloca");
|
||||
builder.build_store(argument_pointer, from_value);
|
||||
use BasicTypeEnum::*;
|
||||
match (from_value.get_type(), to_type) {
|
||||
(PointerType(_), PointerType(_)) => {
|
||||
// we can't use the more straightforward bitcast in all cases
|
||||
// it seems like a bitcast only works on integers and pointers
|
||||
// and crucially does not work not on arrays
|
||||
builder.build_bitcast(from_value, to_type, name)
|
||||
}
|
||||
_ => {
|
||||
// store the value in memory
|
||||
let argument_pointer = builder.build_alloca(from_value.get_type(), "cast_alloca");
|
||||
builder.build_store(argument_pointer, from_value);
|
||||
|
||||
// then read it back as a different type
|
||||
let to_type_pointer = builder
|
||||
.build_bitcast(
|
||||
argument_pointer,
|
||||
to_type.ptr_type(inkwell::AddressSpace::Generic),
|
||||
name,
|
||||
)
|
||||
.into_pointer_value();
|
||||
// then read it back as a different type
|
||||
let to_type_pointer = builder
|
||||
.build_bitcast(
|
||||
argument_pointer,
|
||||
to_type.ptr_type(inkwell::AddressSpace::Generic),
|
||||
name,
|
||||
)
|
||||
.into_pointer_value();
|
||||
|
||||
builder.build_load(to_type_pointer, "cast_value")
|
||||
builder.build_load(to_type_pointer, "cast_value")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn extract_tag_discriminant_struct<'a, 'ctx, 'env>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue