mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
allow byte/bool closure sizes
This commit is contained in:
parent
5282eba556
commit
15600a8f2b
1 changed files with 26 additions and 5 deletions
|
@ -40,6 +40,22 @@ pub struct ClosureLayout<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ClosureLayout<'a> {
|
impl<'a> ClosureLayout<'a> {
|
||||||
|
fn from_bool(arena: &'a Bump) -> Self {
|
||||||
|
let layout = Layout::Builtin(Builtin::Int1);
|
||||||
|
let layouts = arena.alloc([layout]);
|
||||||
|
ClosureLayout {
|
||||||
|
captured: layouts,
|
||||||
|
max_size: layouts,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn from_byte(arena: &'a Bump) -> Self {
|
||||||
|
let layout = Layout::Builtin(Builtin::Int8);
|
||||||
|
let layouts = arena.alloc([layout]);
|
||||||
|
ClosureLayout {
|
||||||
|
captured: layouts,
|
||||||
|
max_size: layouts,
|
||||||
|
}
|
||||||
|
}
|
||||||
fn from_unwrapped(layouts: &'a [Layout<'a>]) -> Self {
|
fn from_unwrapped(layouts: &'a [Layout<'a>]) -> Self {
|
||||||
debug_assert!(layouts.len() > 0);
|
debug_assert!(layouts.len() > 0);
|
||||||
ClosureLayout {
|
ClosureLayout {
|
||||||
|
@ -566,11 +582,16 @@ fn layout_from_flat_type<'a>(
|
||||||
// a max closure size of 0 means this is a standart top-level function
|
// a max closure size of 0 means this is a standart top-level function
|
||||||
Ok(Layout::FunctionPointer(fn_args, ret))
|
Ok(Layout::FunctionPointer(fn_args, ret))
|
||||||
}
|
}
|
||||||
BoolUnion {
|
BoolUnion { .. } => {
|
||||||
ttrue: _,
|
let closure_layout = ClosureLayout::from_bool(env.arena);
|
||||||
ffalse: _,
|
|
||||||
} => todo!(),
|
Ok(Layout::Closure(fn_args, closure_layout, ret))
|
||||||
ByteUnion(_tagnames) => todo!(),
|
}
|
||||||
|
ByteUnion(_) => {
|
||||||
|
let closure_layout = ClosureLayout::from_byte(env.arena);
|
||||||
|
|
||||||
|
Ok(Layout::Closure(fn_args, closure_layout, ret))
|
||||||
|
}
|
||||||
Unwrapped(layouts) => {
|
Unwrapped(layouts) => {
|
||||||
let closure_layout =
|
let closure_layout =
|
||||||
ClosureLayout::from_unwrapped(layouts.into_bump_slice());
|
ClosureLayout::from_unwrapped(layouts.into_bump_slice());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue