mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 23:04:49 +00:00
remove Boxed
This commit is contained in:
parent
56d4ac190e
commit
0171fd0959
10 changed files with 41 additions and 67 deletions
|
@ -2495,32 +2495,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
|
|||
Dec(symbol) => {
|
||||
let (value, layout) = load_symbol_and_layout(scope, symbol);
|
||||
|
||||
if let Layout::Boxed(_) = layout {
|
||||
if value.is_pointer_value() {
|
||||
let value_ptr = value.into_pointer_value();
|
||||
|
||||
let then_block = env.context.append_basic_block(parent, "then");
|
||||
let done_block = env.context.append_basic_block(parent, "done");
|
||||
|
||||
let condition =
|
||||
env.builder.build_is_not_null(value_ptr, "box_is_not_null");
|
||||
env.builder
|
||||
.build_conditional_branch(condition, then_block, done_block);
|
||||
|
||||
{
|
||||
env.builder.position_at_end(then_block);
|
||||
let refcount_ptr =
|
||||
PointerToRefcount::from_ptr_to_data(env, value_ptr);
|
||||
refcount_ptr.decrement(env, layout);
|
||||
|
||||
env.builder.build_unconditional_branch(done_block);
|
||||
}
|
||||
|
||||
env.builder.position_at_end(done_block);
|
||||
} else {
|
||||
eprint!("we're likely leaking memory; see issue #985 for details");
|
||||
}
|
||||
} else if layout.contains_refcounted() {
|
||||
if layout.contains_refcounted() {
|
||||
decrement_refcount_layout(env, parent, layout_ids, value, layout);
|
||||
}
|
||||
|
||||
|
@ -2562,11 +2537,26 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
|
|||
|
||||
_ if layout.is_refcounted() => {
|
||||
if value.is_pointer_value() {
|
||||
// BasicValueEnum::PointerValue(value_ptr) => {
|
||||
let value_ptr = value.into_pointer_value();
|
||||
let refcount_ptr =
|
||||
PointerToRefcount::from_ptr_to_data(env, value_ptr);
|
||||
refcount_ptr.decrement(env, layout);
|
||||
|
||||
let then_block = env.context.append_basic_block(parent, "then");
|
||||
let done_block = env.context.append_basic_block(parent, "done");
|
||||
|
||||
let condition =
|
||||
env.builder.build_is_not_null(value_ptr, "box_is_not_null");
|
||||
env.builder
|
||||
.build_conditional_branch(condition, then_block, done_block);
|
||||
|
||||
{
|
||||
env.builder.position_at_end(then_block);
|
||||
let refcount_ptr =
|
||||
PointerToRefcount::from_ptr_to_data(env, value_ptr);
|
||||
refcount_ptr.decrement(env, layout);
|
||||
|
||||
env.builder.build_unconditional_branch(done_block);
|
||||
}
|
||||
|
||||
env.builder.position_at_end(done_block);
|
||||
} else {
|
||||
eprint!("we're likely leaking memory; see issue #985 for details");
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@ fn build_hash_layout<'a, 'ctx, 'env>(
|
|||
when_recursive: WhenRecursive<'a>,
|
||||
) -> IntValue<'ctx> {
|
||||
match layout {
|
||||
Layout::Boxed(_) => todo!(),
|
||||
Layout::Builtin(builtin) => {
|
||||
hash_builtin(env, layout_ids, seed, val, layout, builtin, when_recursive)
|
||||
}
|
||||
|
|
|
@ -139,7 +139,6 @@ fn build_eq<'a, 'ctx, 'env>(
|
|||
}
|
||||
|
||||
match lhs_layout {
|
||||
Layout::Boxed(_) => todo!(),
|
||||
Layout::Builtin(builtin) => {
|
||||
build_eq_builtin(env, layout_ids, lhs_val, rhs_val, builtin, when_recursive)
|
||||
}
|
||||
|
@ -297,7 +296,6 @@ fn build_neq<'a, 'ctx, 'env>(
|
|||
}
|
||||
|
||||
match lhs_layout {
|
||||
Layout::Boxed(_) => todo!(),
|
||||
Layout::Builtin(builtin) => {
|
||||
build_neq_builtin(env, layout_ids, lhs_val, rhs_val, builtin, when_recursive)
|
||||
}
|
||||
|
|
|
@ -79,14 +79,6 @@ pub fn basic_type_from_layout<'a, 'ctx, 'env>(
|
|||
.as_basic_type_enum()
|
||||
}
|
||||
|
||||
Boxed(_) => {
|
||||
// TODO make this dynamic
|
||||
env.context
|
||||
.i64_type()
|
||||
.ptr_type(AddressSpace::Generic)
|
||||
.as_basic_type_enum()
|
||||
}
|
||||
|
||||
Builtin(builtin) => basic_type_from_builtin(env, builtin),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -752,10 +752,6 @@ fn modify_refcount_layout_build_function<'a, 'ctx, 'env>(
|
|||
Some(function)
|
||||
}
|
||||
},
|
||||
Layout::Boxed(_) => {
|
||||
// TODO
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue