diff --git a/compiler/builtins/README.md b/compiler/builtins/README.md index dd0a754476..5767daf76e 100644 --- a/compiler/builtins/README.md +++ b/compiler/builtins/README.md @@ -58,6 +58,10 @@ This is where bottom-level functions that need to be written as LLVM are created ### builtins/src/std.rs Its one thing to actually write these functions, its _another_ thing to let the Roc compiler know they exist as part of the standard library. You have to tell the compiler "Hey, this function exists, and it has this type signature". That happens in `std.rs`. +## Specifying how we pass args to the function +### builtins/mono/src/borrow.rs +After we have all of this, we need to specify if the arguements we're passing are owned, borrowed or irrelvant. Towards the bottom of this file, add a new case for you builtin and specify each arg. Be sure to read the comment, as it explains this in more detail. + ## Specifying the uniqueness of a function ### builtins/src/unique.rs One of the cool things about Roc is that it evaluates if a value in memory is shared between scopes or if it is used in just one place. If the value is used in one place then it is 'unique', and it therefore can be mutated in place. For a value created by a function, the uniqueness of the output is determined in part by the uniqueness of the input arguments. For example `List.single : elem -> List elem` can return a unique list if the `elem` is also unique. diff --git a/compiler/mono/src/borrow.rs b/compiler/mono/src/borrow.rs index 08bbd2f321..fa6a7da8ee 100644 --- a/compiler/mono/src/borrow.rs +++ b/compiler/mono/src/borrow.rs @@ -510,7 +510,8 @@ pub fn lowlevel_borrow_signature(arena: &Bump, op: LowLevel) -> &[bool] { ListSet => arena.alloc_slice_copy(&[owned, irrelevant, irrelevant]), ListSetInPlace => arena.alloc_slice_copy(&[owned, irrelevant, irrelevant]), ListGetUnsafe => arena.alloc_slice_copy(&[borrowed, irrelevant]), - ListConcat | StrConcat | StrCountGraphemes => arena.alloc_slice_copy(&[owned, borrowed]), + ListConcat | StrConcat => arena.alloc_slice_copy(&[owned, borrowed]), + StrCountGraphemes => arena.alloc_slice_copy(&[borrowed]), ListSingle => arena.alloc_slice_copy(&[irrelevant]), ListRepeat => arena.alloc_slice_copy(&[irrelevant, irrelevant]),