MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / exec_sort

Method exec_sort

compiler/src/modules/vm/handlers/function.rs:308–322  ·  view source on GitHub ↗

list.sort(): parse key/reverse kwargs and sort in place. Intercepted from both call paths since it needs chunk/slots for __lt__. */

(&mut self, recv: Val, positional: &[Val], kw_flat: &[Val], chunk: &SSAChunk, slots: &mut [Val])

Source from the content-addressed store, hash-verified

306
307 /* list.sort(): parse key/reverse kwargs and sort in place. Intercepted from both call paths since it needs chunk/slots for __lt__. */
308 pub(crate) fn exec_sort(&mut self, recv: Val, positional: &[Val], kw_flat: &[Val], chunk: &SSAChunk, slots: &mut [Val]) -> Result<(), VmErr> {
309 if !positional.is_empty() {
310 return Err(cold_type("list.sort() takes no positional arguments"));
311 }
312 let mut sort_key: Option<Val> = None;
313 let mut sort_reverse = false;
314 for pair in kw_flat.chunks(2) {
315 match self.kw_name(pair[0]) {
316 Some("key") => sort_key = Some(pair[1]),
317 Some("reverse") => sort_reverse = self.truthy(pair[1]),
318 _ => return Err(cold_type("list.sort() got unexpected keyword argument")),
319 }
320 }
321 self.call_list_sort_keyed(recv, sort_key, sort_reverse, chunk, slots)
322 }
323
324 /* Dispatch non-Func callees. Returns Ok(true) when handled here; Ok(false) means the caller falls through to the Func path. */
325 fn try_dispatch_non_func_callable(&mut self, callee: Val, positional: &[Val], kw_flat: &[Val], num_kw: usize, chunk: &SSAChunk, slots: &mut [Val]) -> Result<bool, VmErr> {

Callers 2

exec_call_methodMethod · 0.80

Calls 5

cold_typeFunction · 0.85
kw_nameMethod · 0.80
truthyMethod · 0.80
call_list_sort_keyedMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected