diff options
author | Son Ho | 2024-04-12 08:48:13 +0200 |
---|---|---|
committer | Son Ho | 2024-04-12 08:48:13 +0200 |
commit | 502f25a653a0afe7787b92a3004374e7670ea69b (patch) | |
tree | c85831d9d4bae5116cda6261befafdc229303205 /compiler | |
parent | 604b450a1a6d9aa364b5acbad460ec3d4d7822e4 (diff) |
Update the bindings for the extraction
Diffstat (limited to '')
-rw-r--r-- | compiler/ExtractBuiltin.ml | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/compiler/ExtractBuiltin.ml b/compiler/ExtractBuiltin.ml index a2983573..3ba8d11d 100644 --- a/compiler/ExtractBuiltin.ml +++ b/compiler/ExtractBuiltin.ml @@ -240,12 +240,11 @@ let builtin_funs () : (pattern * bool list option * builtin_fun_info) list = let f = { extract_name = basename } in (rust_name, filter, f) in - let mk_scalar_fun (rust_name_prefix : string) (rust_name_suffix : string) - (extract_name : string option) (filter : bool list option) : + let mk_scalar_fun (rust_name : string -> string) + (extract_name : string -> string) : (pattern * bool list option * builtin_fun_info) list = List.map - (fun ty -> - mk_fun (rust_name_prefix ^ ty ^ rust_name_suffix) extract_name filter) + (fun ty -> mk_fun (rust_name ty) (Some (extract_name ty)) None) [ "usize"; "u8"; @@ -346,16 +345,14 @@ let builtin_funs () : (pattern * bool list option * builtin_fun_info) list = [@T]>}::index_mut" (Some "core_slice_index_Slice_index_mut") None; ] - @ mk_scalar_fun "core::num::{" "}::checked_add" (Some "core.num.checked_add") - None - @ mk_scalar_fun "core::num::{" "}::checked_sub" (Some "core.num.checked_sub") - None - @ mk_scalar_fun "core::num::{" "}::checked_mul" (Some "core.num.checked_mul") - None - @ mk_scalar_fun "core::num::{" "}::checked_div" (Some "core.num.checked_div") - None - @ mk_scalar_fun "core::num::{" "}::checked_rem" (Some "core.num.checked_rem") - None + @ List.flatten + (List.map + (fun op -> + mk_scalar_fun + (fun ty -> "core::num::{" ^ ty ^ "}::checked_" ^ op) + (fun ty -> + StringUtils.capitalize_first_letter ty ^ ".checked_" ^ op)) + [ "add"; "sub"; "mul"; "div"; "rem" ]) let mk_builtin_funs_map () = let m = |