mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
attempt at float switches
needs something more , will circle back later
This commit is contained in:
parent
f30655a103
commit
0075e3fb04
1 changed files with 8 additions and 1 deletions
|
@ -670,7 +670,13 @@ fn build_switch<'a, 'ctx, 'env>(
|
|||
|
||||
// Build the condition
|
||||
let cond = match cond_layout {
|
||||
Layout::Builtin(_) => build_expr(env, scope, parent, cond_expr, procs).into_int_value(),
|
||||
Layout::Builtin(Builtin::Float64) => {
|
||||
// float matches are done on the bit pattern
|
||||
cond_layout = Layout::Builtin(Builtin::Int64);
|
||||
let full_cond = build_expr(env, scope, parent, cond_expr, procs);
|
||||
|
||||
cast_basic_basic(builder, full_cond, env.context.i64_type().into()).into_int_value()
|
||||
}
|
||||
Layout::Union(_) => {
|
||||
// we match on the discriminant, not the whole Tag
|
||||
cond_layout = Layout::Builtin(Builtin::Int64);
|
||||
|
@ -678,6 +684,7 @@ fn build_switch<'a, 'ctx, 'env>(
|
|||
|
||||
extract_tag_discriminant(env, full_cond)
|
||||
}
|
||||
Layout::Builtin(_) => build_expr(env, scope, parent, cond_expr, procs).into_int_value(),
|
||||
other => todo!("Build switch value from layout: {:?}", other),
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue