Merge branch 'trunk' of github.com:rtfeldman/roc into pure-roc-list-walk

This commit is contained in:
Brian Carroll 2022-07-02 21:40:51 +01:00
commit 94181111be
No known key found for this signature in database
GPG key ID: 9CF4E3BF9C4722C7
37 changed files with 259 additions and 1321 deletions

View file

@ -552,10 +552,7 @@ impl<'a> BorrowInfState<'a> {
};
match op {
ListMap { xs }
| ListKeepIf { xs }
| ListKeepOks { xs }
| ListKeepErrs { xs } => {
ListMap { xs } => {
// own the list if the function wants to own the element
if !function_ps[0].borrow {
self.own_var(*xs);
@ -907,9 +904,6 @@ pub fn lowlevel_borrow_signature(arena: &Bump, op: LowLevel) -> &[bool] {
ListMap2 => arena.alloc_slice_copy(&[owned, owned, function, closure_data]),
ListMap3 => arena.alloc_slice_copy(&[owned, owned, owned, function, closure_data]),
ListMap4 => arena.alloc_slice_copy(&[owned, owned, owned, owned, function, closure_data]),
ListKeepIf | ListKeepOks | ListKeepErrs => {
arena.alloc_slice_copy(&[owned, function, closure_data])
}
ListSortWith => arena.alloc_slice_copy(&[owned, function, closure_data]),
// TODO when we have lists with capacity (if ever)

View file

@ -693,7 +693,7 @@ impl<'a> Context<'a> {
let after_arguments = &arguments[op.function_index()..];
match *op {
ListMap { xs } | ListKeepIf { xs } | ListKeepOks { xs } | ListKeepErrs { xs } => {
ListMap { xs } => {
let ownerships = [(xs, function_ps[0])];
let b = self.add_dec_after_lowlevel(after_arguments, &borrows, b, b_live_vars);

View file

@ -5043,34 +5043,6 @@ pub fn with_hole<'a>(
let xs = arg_symbols[0];
match_on_closure_argument!(ListMapWithIndex, [xs])
}
ListKeepIf => {
debug_assert_eq!(arg_symbols.len(), 2);
let xs = arg_symbols[0];
let stmt = match_on_closure_argument!(ListKeepIf, [xs]);
// See the comment in `walk!`. We use List.keepIf to implement
// other builtins, where the closure can be an actual closure rather
// than a symbol.
assign_to_symbol(
env,
procs,
layout_cache,
args[1].0, // the closure
Loc::at_zero(args[1].1.clone()),
arg_symbols[1],
stmt,
)
}
ListKeepOks => {
debug_assert_eq!(arg_symbols.len(), 2);
let xs = arg_symbols[0];
match_on_closure_argument!(ListKeepOks, [xs])
}
ListKeepErrs => {
debug_assert_eq!(arg_symbols.len(), 2);
let xs = arg_symbols[0];
match_on_closure_argument!(ListKeepErrs, [xs])
}
ListSortWith => {
debug_assert_eq!(arg_symbols.len(), 2);
let xs = arg_symbols[0];

View file

@ -23,15 +23,6 @@ pub enum HigherOrder {
ListMapWithIndex {
xs: Symbol,
},
ListKeepIf {
xs: Symbol,
},
ListKeepOks {
xs: Symbol,
},
ListKeepErrs {
xs: Symbol,
},
ListSortWith {
xs: Symbol,
},
@ -49,9 +40,6 @@ impl HigherOrder {
HigherOrder::ListMap3 { .. } => 3,
HigherOrder::ListMap4 { .. } => 4,
HigherOrder::ListMapWithIndex { .. } => 2,
HigherOrder::ListKeepIf { .. } => 1,
HigherOrder::ListKeepOks { .. } => 1,
HigherOrder::ListKeepErrs { .. } => 1,
HigherOrder::ListSortWith { .. } => 2,
HigherOrder::DictWalk { .. } => 2,
}
@ -63,12 +51,7 @@ impl HigherOrder {
use HigherOrder::*;
match self {
ListMap { .. }
| ListMapWithIndex { .. }
| ListSortWith { .. }
| ListKeepIf { .. }
| ListKeepOks { .. }
| ListKeepErrs { .. } => 2,
ListMap { .. } | ListMapWithIndex { .. } | ListSortWith { .. } => 2,
ListMap2 { .. } => 3,
ListMap3 { .. } => 4,
ListMap4 { .. } => 5,