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

Function dispatch_len

compiler/src/main/abi_bridge.rs:155–167  ·  view source on GitHub ↗
(recv_h: u32)

Source from the content-addressed store, hash-verified

153}
154
155fn dispatch_len(recv_h: u32) -> Result<Val, VmErr> {
156 with_recv("edge_op len: invalid receiver handle", recv_h, |vm, recv| {
157 let n: i64 = match vm.heap.get(recv) {
158 HeapObj::Str(s) => s.chars().count() as i64,
159 HeapObj::List(rc) => rc.borrow().len() as i64,
160 HeapObj::Dict(rc) => rc.borrow().entries.len() as i64,
161 HeapObj::Set(rc) => rc.borrow().len() as i64,
162 HeapObj::Tuple(t) => t.len() as i64,
163 _ => return Err(VmErr::TypeMsg(s!("object of type '", str vm.type_name(recv), "' has no len()"))),
164 };
165 Ok(Val::int(n))
166 })
167}
168
169/* Iter: flatten any iterable into a List for guest GetItem/Len access. */
170fn dispatch_iter(recv_h: u32) -> Result<Val, VmErr> {

Callers 1

host_edge_opFunction · 0.85

Calls 5

with_recvFunction · 0.85
countMethod · 0.80
borrowMethod · 0.80
getMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected