remove zig implementation of keepIf/keepErrs/keepOks

This commit is contained in:
Folkert 2022-07-02 13:55:48 +02:00
parent addb27164e
commit e29a89d33c
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
13 changed files with 21 additions and 721 deletions

View file

@ -552,13 +552,7 @@ impl<'a> BorrowInfState<'a> {
};
match op {
ListMap { xs }
| ListKeepIf { xs }
| ListKeepOks { xs }
| ListKeepErrs { xs }
| ListAny { xs }
| ListAll { xs }
| ListFindUnsafe { xs } => {
ListMap { xs } | ListAny { xs } | ListAll { xs } | ListFindUnsafe { xs } => {
// own the list if the function wants to own the element
if !function_ps[0].borrow {
self.own_var(*xs);
@ -913,9 +907,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])
}
ListWalk | ListWalkUntil | ListWalkBackwards => {
arena.alloc_slice_copy(&[owned, owned, function, closure_data])
}

View file

@ -693,13 +693,7 @@ impl<'a> Context<'a> {
let after_arguments = &arguments[op.function_index()..];
match *op {
ListMap { xs }
| ListKeepIf { xs }
| ListKeepOks { xs }
| ListKeepErrs { xs }
| ListAny { xs }
| ListAll { xs }
| ListFindUnsafe { xs } => {
ListMap { xs } | ListAny { xs } | ListAll { xs } | ListFindUnsafe { 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,9 +23,6 @@ pub enum HigherOrder {
ListMapWithIndex {
xs: Symbol,
},
ListKeepIf {
xs: Symbol,
},
ListWalk {
xs: Symbol,
state: Symbol,
@ -38,12 +35,6 @@ pub enum HigherOrder {
xs: Symbol,
state: Symbol,
},
ListKeepOks {
xs: Symbol,
},
ListKeepErrs {
xs: Symbol,
},
ListSortWith {
xs: Symbol,
},
@ -70,12 +61,9 @@ impl HigherOrder {
HigherOrder::ListMap3 { .. } => 3,
HigherOrder::ListMap4 { .. } => 4,
HigherOrder::ListMapWithIndex { .. } => 2,
HigherOrder::ListKeepIf { .. } => 1,
HigherOrder::ListWalk { .. } => 2,
HigherOrder::ListWalkUntil { .. } => 2,
HigherOrder::ListWalkBackwards { .. } => 2,
HigherOrder::ListKeepOks { .. } => 1,
HigherOrder::ListKeepErrs { .. } => 1,
HigherOrder::ListSortWith { .. } => 2,
HigherOrder::ListFindUnsafe { .. } => 1,
HigherOrder::DictWalk { .. } => 2,
@ -93,9 +81,6 @@ impl HigherOrder {
ListMap { .. }
| ListMapWithIndex { .. }
| ListSortWith { .. }
| ListKeepIf { .. }
| ListKeepOks { .. }
| ListKeepErrs { .. }
| ListAny { .. }
| ListAll { .. }
| ListFindUnsafe { .. } => 2,