mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
cleanup build_reset usage
This commit is contained in:
parent
1beed7f759
commit
771599165b
3 changed files with 40 additions and 60 deletions
|
@ -1021,20 +1021,14 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
|
|||
// referenced value, and returns the location of the now-invalid cell
|
||||
env.builder.position_at_end(then_block);
|
||||
|
||||
match build_reset(env, layout_ids, union_layout) {
|
||||
Some(reset_function) => {
|
||||
let call =
|
||||
env.builder
|
||||
.build_call(reset_function, &[tag_ptr.into()], "call_reuse");
|
||||
let reset_function = build_reset(env, layout_ids, union_layout);
|
||||
let call = env
|
||||
.builder
|
||||
.build_call(reset_function, &[tag_ptr.into()], "call_reuse");
|
||||
|
||||
call.set_call_convention(FAST_CALL_CONV);
|
||||
call.set_call_convention(FAST_CALL_CONV);
|
||||
|
||||
let _ = call.try_as_basic_value();
|
||||
}
|
||||
None => {
|
||||
panic!("")
|
||||
}
|
||||
}
|
||||
let _ = call.try_as_basic_value();
|
||||
|
||||
env.builder.build_unconditional_branch(cont_block);
|
||||
}
|
||||
|
|
|
@ -1564,61 +1564,47 @@ pub fn build_reset<'a, 'ctx, 'env>(
|
|||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
union_layout: &UnionLayout<'a>,
|
||||
) -> Option<FunctionValue<'ctx>> {
|
||||
) -> FunctionValue<'ctx> {
|
||||
use UnionLayout::*;
|
||||
|
||||
match union_layout {
|
||||
NullableWrapped {
|
||||
other_tags: tags, ..
|
||||
} => {
|
||||
let function = build_reuse_rec_union(
|
||||
env,
|
||||
layout_ids,
|
||||
&WhenRecursive::Loop(*union_layout),
|
||||
*union_layout,
|
||||
tags,
|
||||
true,
|
||||
);
|
||||
} => build_reuse_rec_union(
|
||||
env,
|
||||
layout_ids,
|
||||
&WhenRecursive::Loop(*union_layout),
|
||||
*union_layout,
|
||||
tags,
|
||||
true,
|
||||
),
|
||||
|
||||
Some(function)
|
||||
}
|
||||
NullableUnwrapped { other_fields, .. } => build_reuse_rec_union(
|
||||
env,
|
||||
layout_ids,
|
||||
&WhenRecursive::Loop(*union_layout),
|
||||
*union_layout,
|
||||
env.arena.alloc([*other_fields]),
|
||||
true,
|
||||
),
|
||||
|
||||
NullableUnwrapped { other_fields, .. } => {
|
||||
let function = build_reuse_rec_union(
|
||||
env,
|
||||
layout_ids,
|
||||
&WhenRecursive::Loop(*union_layout),
|
||||
*union_layout,
|
||||
env.arena.alloc([*other_fields]),
|
||||
true,
|
||||
);
|
||||
NonNullableUnwrapped(fields) => build_reuse_rec_union(
|
||||
env,
|
||||
layout_ids,
|
||||
&WhenRecursive::Loop(*union_layout),
|
||||
*union_layout,
|
||||
&*env.arena.alloc([*fields]),
|
||||
true,
|
||||
),
|
||||
|
||||
Some(function)
|
||||
}
|
||||
|
||||
NonNullableUnwrapped(fields) => {
|
||||
let function = build_reuse_rec_union(
|
||||
env,
|
||||
layout_ids,
|
||||
&WhenRecursive::Loop(*union_layout),
|
||||
*union_layout,
|
||||
&*env.arena.alloc([*fields]),
|
||||
true,
|
||||
);
|
||||
Some(function)
|
||||
}
|
||||
|
||||
Recursive(tags) => {
|
||||
let function = build_reuse_rec_union(
|
||||
env,
|
||||
layout_ids,
|
||||
&WhenRecursive::Loop(*union_layout),
|
||||
*union_layout,
|
||||
tags,
|
||||
false,
|
||||
);
|
||||
Some(function)
|
||||
}
|
||||
Recursive(tags) => build_reuse_rec_union(
|
||||
env,
|
||||
layout_ids,
|
||||
&WhenRecursive::Loop(*union_layout),
|
||||
*union_layout,
|
||||
tags,
|
||||
false,
|
||||
),
|
||||
|
||||
NonRecursive(_) => {
|
||||
unreachable!("non-recursive tags cannot be reused")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue