mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
Add FunctionPointer layout
This commit is contained in:
parent
a9e3f967a8
commit
6312d75ee0
18 changed files with 111 additions and 14 deletions
|
@ -25,7 +25,7 @@ pub fn eq_generic<'a>(
|
|||
use crate::layout::Builtin::*;
|
||||
use LayoutRepr::*;
|
||||
let main_body = match layout_interner.get_repr(layout) {
|
||||
Builtin(Int(_) | Float(_) | Bool | Decimal) => {
|
||||
Builtin(Int(_) | Float(_) | Bool | Decimal) | FunctionPointer(_) => {
|
||||
unreachable!(
|
||||
"No generated proc for `==`. Use direct code gen for {:?}",
|
||||
layout
|
||||
|
|
|
@ -582,6 +582,8 @@ impl<'a> CodeGenHelp<'a> {
|
|||
|
||||
// This line is the whole point of the function
|
||||
LayoutRepr::RecursivePointer(_) => LayoutRepr::Union(ctx.recursive_union.unwrap()),
|
||||
|
||||
LayoutRepr::FunctionPointer(_) => return layout,
|
||||
};
|
||||
|
||||
layout_interner.insert(Layout::new(LayoutWrapper::Direct(repr), semantic))
|
||||
|
@ -838,5 +840,6 @@ fn layout_needs_helper_proc<'a>(
|
|||
LayoutRepr::LambdaSet(_) => true,
|
||||
LayoutRepr::RecursivePointer(_) => false,
|
||||
LayoutRepr::Ptr(_) => false,
|
||||
LayoutRepr::FunctionPointer(_) => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,7 +188,8 @@ pub fn refcount_generic<'a>(
|
|||
match layout_interner.get_repr(layout) {
|
||||
LayoutRepr::Builtin(
|
||||
Builtin::Int(_) | Builtin::Float(_) | Builtin::Bool | Builtin::Decimal,
|
||||
) => {
|
||||
)
|
||||
| LayoutRepr::FunctionPointer(_) => {
|
||||
// Generate a dummy function that immediately returns Unit
|
||||
// Some higher-order Zig builtins *always* call an RC function on List elements.
|
||||
rc_return_stmt(root, ident_ids, ctx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue