| 266 | type NativeFn = fn(&mut HeapPool, &[Val], Option<Val>) -> Result<Val, VmErr>; |
| 267 | |
| 268 | pub fn test_native(name: &str) -> Option<NativeBinding> { |
| 269 | let (func, pure): (NativeFn, bool) = match name { |
| 270 | "add" => (add, true), |
| 271 | "square" => (square, true), |
| 272 | "make_str" => (make_str, true), |
| 273 | "counter" => (counter, false), |
| 274 | "const_42" => (const_42, true), |
| 275 | "boom" => (boom, true), |
| 276 | "double_f" => (double_f, true), |
| 277 | "negate" => (negate, true), |
| 278 | "pick" => (pick, true), |
| 279 | "host_defer" => (host_defer, false), |
| 280 | "__const_pi" => (const_pi, true), |
| 281 | // Registered under a builtin name to assert imported natives shadow builtins. |
| 282 | "abs" => (const_42, true), |
| 283 | _ => return None, |
| 284 | }; |
| 285 | Some(NativeBinding::from_fn(name, func, pure)) |
| 286 | } |