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

Function host_edge_op

compiler/src/main/abi_bridge.rs:14–40  ·  view source on GitHub ↗
(op: u32, recv: u32, name_ptr: *const u8, name_len: u32,argv_ptr: *const u32, argc: u32, out_handle: *mut u32)

Source from the content-addressed store, hash-verified

12// Universal dispatch. Returns 0 + handle in `*out_handle`, or 1 + stashed error.
13#[unsafe(no_mangle)]
14pub unsafe extern "C" fn host_edge_op(op: u32, recv: u32, name_ptr: *const u8, name_len: u32,argv_ptr: *const u32, argc: u32, out_handle: *mut u32) -> i32 {
15 let name = unsafe { safe_str_owned(name_ptr, name_len) };
16 let args: Vec<Val> = unsafe { safe_handles(argv_ptr, argc) }.iter().filter_map(|&h| get_val(h)).collect();
17
18 let result: Result<Val, VmErr> = match Op::from_u32(op) {
19 Some(Op::Call) => dispatch_call(recv, &name, &args),
20 Some(Op::GetAttr) => dispatch_get_attr(recv, &name),
21 Some(Op::SetAttr) => dispatch_set_attr(recv, &name, &args),
22 Some(Op::GetItem) => dispatch_get_item(recv, &args),
23 Some(Op::SetItem) => dispatch_set_item(recv, &args),
24 Some(Op::Len) => dispatch_len(recv),
25 Some(Op::Iter) => dispatch_iter(recv),
26 Some(Op::IterNext) => dispatch_iter_next(recv),
27 Some(Op::NewDict) => dispatch_new_dict(),
28 Some(Op::NewList) => dispatch_new_list(),
29 Some(Op::TypeOf) => dispatch_type_of(recv),
30 Some(Op::NewTuple) => dispatch_new_tuple(&args),
31 Some(Op::NewSet) => dispatch_new_set(&args),
32 Some(Op::NewFrozenSet) => dispatch_new_frozenset(&args),
33 None => Err(VmErr::Raised(s!("edge_op: unsupported op ", int op as i64))),
34 };
35
36 match result {
37 Ok(v) => { unsafe { *out_handle = put_val(v); } 0 }
38 Err(e) => { stash_error(e); 1 }
39 }
40}
41
42fn dispatch_call(recv_h: u32, name: &str, args: &[Val]) -> Result<Val, VmErr> {
43 with_recv("edge_op call: invalid receiver handle", recv_h, |vm, recv| {

Callers

nothing calls this directly

Calls 15

safe_str_ownedFunction · 0.85
safe_handlesFunction · 0.85
get_valFunction · 0.85
dispatch_callFunction · 0.85
dispatch_get_attrFunction · 0.85
dispatch_set_attrFunction · 0.85
dispatch_get_itemFunction · 0.85
dispatch_set_itemFunction · 0.85
dispatch_lenFunction · 0.85
dispatch_iterFunction · 0.85
dispatch_iter_nextFunction · 0.85
dispatch_new_dictFunction · 0.85

Tested by

no test coverage detected