(op: u32, recv: u32, name_ptr: *const u8, name_len: u32,argv_ptr: *const u32, argc: u32, out_handle: *mut u32)
| 12 | // Universal dispatch. Returns 0 + handle in `*out_handle`, or 1 + stashed error. |
| 13 | #[unsafe(no_mangle)] |
| 14 | pub 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 | |
| 42 | fn 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| { |
nothing calls this directly
no test coverage detected