From c6e9bcae2595740bd6c5fbfaf4c343297616842c Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Tue, 31 Oct 2023 14:22:15 -0700 Subject: [PATCH] chore: remove last BS references --- jscomp/common/dune | 6 +- jscomp/common/external_arg_spec.mli | 12 +- jscomp/common/external_ffi_types.cppo.ml | 352 ------------------ jscomp/common/external_ffi_types.ml | 262 +++++++++++++ jscomp/common/external_ffi_types.mli | 6 +- jscomp/common/external_ffi_types0.ml | 33 ++ .../common/oprint_mel_primitive_name.dev.ml | 25 ++ .../oprint_mel_primitive_name.release.ml | 26 ++ jscomp/core/initialization.ml | 2 +- jscomp/core/js_name_of_module_id.ml | 2 +- jscomp/core/lam.ml | 4 +- jscomp/core/lam.mli | 2 +- jscomp/core/lam_compile.ml | 4 +- jscomp/core/lam_compile_primitive.ml | 2 +- jscomp/core/lam_convert.ml | 6 +- jscomp/core/lam_dispatch_primitive.ml | 2 +- jscomp/core/lam_eta_conversion.ml | 2 +- jscomp/core/mel_ast_invariant.ml | 2 - jscomp/core/melc_warnings.ml | 2 +- jscomp/core/record_attributes_check.ml | 2 +- jscomp/ext/ext_path.ml | 2 +- jscomp/ext/gen/build_reserved.ml | 6 +- jscomp/others/belt.ml | 2 +- jscomp/others/belt_HashMap.mli | 8 +- jscomp/runtime/caml_format.ml | 1 - jscomp/runtime/js_global.ml | 4 +- jscomp/runtime/js_promise.ml | 2 +- jscomp/test/406_primitive_test.ml | 5 +- jscomp/test/class_repr.ml | 2 +- .../dist/jscomp/test/406_primitive_test.js | 8 +- jscomp/test/dist/jscomp/test/class_repr.js | 2 +- ppx/ast_derive/ast_derive_abstract.ml | 2 +- ppx/ast_external_process.ml | 2 +- 33 files changed, 394 insertions(+), 406 deletions(-) delete mode 100644 jscomp/common/external_ffi_types.cppo.ml create mode 100644 jscomp/common/external_ffi_types.ml create mode 100644 jscomp/common/external_ffi_types0.ml create mode 100644 jscomp/common/oprint_mel_primitive_name.dev.ml create mode 100644 jscomp/common/oprint_mel_primitive_name.release.ml diff --git a/jscomp/common/dune b/jscomp/common/dune index fd5261e0a2..370eba969f 100644 --- a/jscomp/common/dune +++ b/jscomp/common/dune @@ -6,7 +6,7 @@ (libraries ext melange_compiler_libs js_parser)) (rule - (target external_ffi_types.ml) - (deps external_ffi_types.cppo.ml) + (target oprint_mel_primitive_name.ml) + (deps oprint_mel_primitive_name.dev.ml oprint_mel_primitive_name.release.ml) (action - (run cppo %{env:CPPO_FLAGS=} %{deps} -o %{target}))) + (copy# oprint_mel_primitive_name.%{profile}.ml %{target}))) diff --git a/jscomp/common/external_arg_spec.mli b/jscomp/common/external_arg_spec.mli index 15fda5608b..58b043dc55 100644 --- a/jscomp/common/external_arg_spec.mli +++ b/jscomp/common/external_arg_spec.mli @@ -1,5 +1,5 @@ (* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -17,7 +17,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) @@ -31,15 +31,15 @@ type label = private | Obj_label of { name : string } | Obj_empty | Obj_optional of { name : string; for_sure_no_nested_option : bool } -(* it will be ignored , side effect will be recorded *) + (** it will be ignored , side effect will be recorded *) type attr = | Poly_var_string of { descr : (string * string) list } | Poly_var of { descr : (string * string) list option } - | Int of (string * int) list (* ([`a | `b ] [@bs.int])*) + | Int of (string * int) list (* ([`a | `b ] [@mel.int])*) | Arg_cst of cst - | Fn_uncurry_arity of - int (* annotated with [@bs.uncurry ] or [@bs.uncurry 2]*) + | Fn_uncurry_arity of int + (** annotated with [@mel.uncurry ] or [@mel.uncurry 2]*) (* maybe we can improve it as a combination of {!Asttypes.constant} and tuple *) | Extern_unit | Nothing diff --git a/jscomp/common/external_ffi_types.cppo.ml b/jscomp/common/external_ffi_types.cppo.ml deleted file mode 100644 index 335b1d56ab..0000000000 --- a/jscomp/common/external_ffi_types.cppo.ml +++ /dev/null @@ -1,352 +0,0 @@ -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) - -module Literals = struct - let setter_suffix = "#=" - (* let gentype_import = "genType.import" *) -end - -type module_bind_name = - | Phint_name of string - (* explicit hint name *) - - | Phint_nothing - - -type external_module_name = - { bundle : string ; - module_bind_name : module_bind_name - } - -type pipe = bool - -(** TODO: information between [arg_type] and [arg_label] are duplicated, - design a more compact representation so that it is also easy to seralize by hand -*) -type arg_type = External_arg_spec.attr - -type arg_label = External_arg_spec.label - - - -type external_spec = - | Js_var of { - name : string ; - external_module_name : external_module_name option; - scopes : string list - } - | Js_module_as_var of external_module_name - | Js_module_as_fn of { external_module_name : external_module_name; - splice : bool - } - | Js_module_as_class of external_module_name - | Js_call of { - name : string; - external_module_name : external_module_name option; - splice : bool ; - scopes : string list - } - - | Js_send of { - name : string ; - splice : bool ; - pipe : pipe ; - js_send_scopes : string list; - } (* we know it is a js send, but what will happen if you pass an ocaml objct *) - - | Js_new of { - name : string ; - external_module_name : external_module_name option; - splice : bool; - scopes : string list; - } - | Js_set of - { js_set_name : string ; - js_set_scopes : string list - } - | Js_get of { js_get_name : string ; - js_get_scopes : string list; - } - | Js_get_index of { - js_get_index_scopes : string list - } - | Js_set_index of { - js_set_index_scopes : string list - } - -(* let not_inlineable (x : external_spec) = *) - - -(* let name_of_ffi ffi = - match ffi with - | Js_get_index _scope -> "@get_index .." - | Js_set_index _scope -> "@set_index .." - | Js_get { js_get_name = s} -> Printf.sprintf "[@@get %S]" s - | Js_set { js_set_name = s} -> Printf.sprintf "[@@set %S]" s - | Js_call v -> Printf.sprintf "[@@val %S]" v.name - | Js_send v -> Printf.sprintf "[@@send %S]" v.name - | Js_module_as_fn v -> Printf.sprintf "[@@val %S]" v.external_module_name.bundle - | Js_new v -> Printf.sprintf "[@@new %S]" v.name - | Js_module_as_class v - -> Printf.sprintf "[@@module] %S " v.bundle - | Js_module_as_var v - -> - Printf.sprintf "[@@module] %S " v.bundle - | Js_var v (* FIXME: could be [@@module "xx"] as well *) - -> - Printf.sprintf "[@@val] %S " v.name *) - -type return_wrapper = - | Return_unset - | Return_identity - | Return_undefined_to_opt - | Return_null_to_opt - | Return_null_undefined_to_opt - | Return_replaced_with_unit - -type params = - | Params of External_arg_spec.params - | Param_number of int - -type t = - | Ffi_bs of params * - return_wrapper * external_spec - (** [Ffi_bs(args,return,attr) ] - [return] means return value is unit or not, - [true] means is [unit] - *) - | Ffi_obj_create of External_arg_spec.obj_params - | Ffi_inline_const of Lam_constant.t - | Ffi_normal - (* When it's normal, it is handled as normal c functional ffi call *) - - - -let valid_js_char = - let a = Array.init 256 (fun i -> - let c = Char.chr i in - (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c = '_' || c = '$' - ) in - (fun c -> Array.unsafe_get a (Char.code c)) - -let valid_first_js_char = - let a = Array.init 256 (fun i -> - let c = Char.chr i in - (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c = '_' || c = '$' - ) in - (fun c -> Array.unsafe_get a (Char.code c)) - -(** Approximation could be improved *) -let valid_ident (s : string) = - let len = String.length s in - len > 0 && valid_js_char s.[0] && valid_first_js_char s.[0] && - (let module E = struct exception E end in - try - for i = 1 to len - 1 do - if not (valid_js_char (String.unsafe_get s i)) then - raise E.E - done ; - true - with E.E -> false ) - -let is_package_relative_path (x : string) = - String.starts_with x ~prefix:"./" || - String.starts_with x ~prefix:"../" - -let valid_global_name ?loc txt = - if not (valid_ident txt) then - let v = Ext_string.split_by ~keep_empty:true (fun x -> x = '.') txt in - List.iter - (fun s -> - if not (valid_ident s) then - Location.raise_errorf ?loc "Not a valid global name %s" txt - ) v - -(* - We loose such check (see #2583), - it also helps with the implementation deriving abstract [@as] -*) - -let valid_method_name ?loc:_ _txt = - () - (* if not (valid_ident txt) then - Location.raise_errorf ?loc "Not a valid method name %s" txt *) - - - -let check_external_module_name ?loc x = - match x with - | {bundle = ""; _ } - | { module_bind_name = Phint_name ""; _ } -> - Location.raise_errorf ?loc "empty name encountered" - | _ -> () - - - -let check_ffi ?loc ffi : bool = - let xrelative = ref false in - let upgrade bool = - if not (!xrelative) then xrelative := bool in - begin match ffi with - | Js_var {name; external_module_name; _} -> - upgrade (is_package_relative_path name); - Option.iter (fun name -> upgrade (is_package_relative_path name.bundle)) - external_module_name; - valid_global_name ?loc name - | Js_send {name; _ } - | Js_set {js_set_name = name; _} - | Js_get { js_get_name = name; _} - -> valid_method_name ?loc name - | Js_get_index _ (* TODO: check scopes *) - | Js_set_index _ - -> () - - | Js_module_as_var external_module_name - | Js_module_as_fn {external_module_name; splice = _} - | Js_module_as_class external_module_name - -> - upgrade (is_package_relative_path external_module_name.bundle); - check_external_module_name external_module_name - | Js_new {external_module_name ; name; _} - | Js_call {external_module_name ; name ; splice = _; scopes = _ } - -> - Option.iter (fun external_module_name -> - upgrade (is_package_relative_path external_module_name.bundle)) - external_module_name; - Option.iter (fun name -> check_external_module_name ?loc name) - external_module_name; - - valid_global_name ?loc name - end; - !xrelative - -(* let bs_prefix = "MEL:" -let bs_prefix_length = String.length bs_prefix - *) - -(** TODO: Make sure each version is not prefix of each other - Solution: - 1. fixed length - 2. non-prefix approach -*) -(* let bs_external = bs_prefix *) - - -(* let bs_external_length = String.length bs_external *) - - -let to_string (t : t) = - Marshal.to_string t [] - -(* \132\149\166\190 - 0x84 95 A6 BE Intext_magic_small intext.h - https://github.com/ocaml/merlin/commit/b094c937c3a360eb61054f7652081b88e4f3612f -*) -let is_bs_primitive s = - (* TODO(anmonteiro): check this, header_size changed to 16 in 5.1 *) - String.length s >= 20 (* Marshal.header_size*) && - String.unsafe_get s 0 = '\132' && - String.unsafe_get s 1 = '\149' - -let () = Oprint.map_primitive_name := -#ifdef BS_RELEASE_BUILD - (fun s -> - if is_bs_primitive s then "MEL:external" - else s) -#else - (fun s -> String.escaped s) (* For debugging*) -#endif - -external from_bytes_unsafe : bytes -> int -> 'a = "caml_input_value_from_bytes" - -(* TODO: better error message when version mismatch *) -let from_string s : t = - if is_bs_primitive s then - from_bytes_unsafe (Bytes.unsafe_of_string s) 0 - else Ffi_normal - - -let inline_string_primitive (s : string) (op : string option) : string list = - let lam : Lam_constant.t = - let unicode = match op with - | Some op -> Utf8_string.is_unicode_string op - | None -> false in - (Const_string { s; unicode }) in - [""; to_string (Ffi_inline_const lam )] - -(* Let's only do it for string ATM - for boolean, and ints, a good optimizer should - do it by default? - But it may not work after layers of indirection - e.g, submodule -*) -let inline_bool_primitive b : string list = - let lam : Lam_constant.t = - if b then Lam_constant.Const_js_true - else Lam_constant.Const_js_false - in - [""; to_string (Ffi_inline_const lam )] - -(* FIXME: check overflow ?*) -let inline_int_primitive (i : int32) : string list = - [""; - to_string - (Ffi_inline_const - (Const_int {i; comment = None})) - ] - -let inline_int64_primitive (i : int64) : string list = - [""; - to_string - (Ffi_inline_const - (Const_int64 i)) - ] - -let inline_float_primitive (i : string) : string list = - [""; - to_string - (Ffi_inline_const (Const_float i)) - ] -let rec ffi_bs_aux acc (params : External_arg_spec.params) = - match params with - | {arg_type = Nothing; arg_label = Arg_empty} - (* same as External_arg_spec.dummy*) - :: rest -> - ffi_bs_aux (acc + 1) rest - | _ :: _ -> -1 - | [] -> acc - -let ffi_bs (params : External_arg_spec.params) return attr = - let n = ffi_bs_aux 0 params in - if n < 0 then Ffi_bs (Params params,return,attr) - else Ffi_bs (Param_number n, return, attr) - -let ffi_bs_as_prims params return attr = - [""; to_string (ffi_bs params return attr)] - -let ffi_obj_create obj_params = - Ffi_obj_create obj_params - -let ffi_obj_as_prims obj_params = - ["";to_string (Ffi_obj_create obj_params)] diff --git a/jscomp/common/external_ffi_types.ml b/jscomp/common/external_ffi_types.ml new file mode 100644 index 0000000000..6d7819778e --- /dev/null +++ b/jscomp/common/external_ffi_types.ml @@ -0,0 +1,262 @@ +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + +open External_ffi_types0 + +module Literals = struct + let setter_suffix = "#=" + (* let gentype_import = "genType.import" *) +end + +type module_bind_name = + | Phint_name of string (* explicit hint name *) + | Phint_nothing + +type external_module_name = { + bundle : string; + module_bind_name : module_bind_name; +} + +type pipe = bool +type arg_type = External_arg_spec.attr +(* TODO: information between [arg_type] and [arg_label] are duplicated, + design a more compact representation so that it is also easy to seralize by + hand *) + +type arg_label = External_arg_spec.label + +type external_spec = + | Js_var of { + name : string; + external_module_name : external_module_name option; + scopes : string list; + } + | Js_module_as_var of external_module_name + | Js_module_as_fn of { + external_module_name : external_module_name; + splice : bool; + } + | Js_module_as_class of external_module_name + | Js_call of { + name : string; + external_module_name : external_module_name option; + splice : bool; + scopes : string list; + } + | Js_send of { + name : string; + splice : bool; + pipe : pipe; + js_send_scopes : string list; + } + (* we know it is a js send, but what will happen if you pass an ocaml objct *) + | Js_new of { + name : string; + external_module_name : external_module_name option; + splice : bool; + scopes : string list; + } + | Js_set of { js_set_name : string; js_set_scopes : string list } + | Js_get of { js_get_name : string; js_get_scopes : string list } + | Js_get_index of { js_get_index_scopes : string list } + | Js_set_index of { js_set_index_scopes : string list } + +type return_wrapper = + | Return_unset + | Return_identity + | Return_undefined_to_opt + | Return_null_to_opt + | Return_null_undefined_to_opt + | Return_replaced_with_unit + +type params = Params of External_arg_spec.params | Param_number of int + +type t = + | Ffi_mel of params * return_wrapper * external_spec + (** [Ffi_mel(args,return,attr) ] + [return] means return value is unit or not, + [true] means is [unit] *) + | Ffi_obj_create of External_arg_spec.obj_params + | Ffi_inline_const of Lam_constant.t + | Ffi_normal +(* When it's normal, it is handled as normal c functional ffi call *) + +let valid_js_char = + let a = + Array.init 256 (fun i -> + let c = Char.chr i in + (c >= 'a' && c <= 'z') + || (c >= 'A' && c <= 'Z') + || (c >= '0' && c <= '9') + || c = '_' || c = '$') + in + fun c -> Array.unsafe_get a (Char.code c) + +let valid_first_js_char = + let a = + Array.init 256 (fun i -> + let c = Char.chr i in + (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c = '_' || c = '$') + in + fun c -> Array.unsafe_get a (Char.code c) + +(** Approximation could be improved *) +let valid_ident (s : string) = + let len = String.length s in + len > 0 + && valid_js_char s.[0] + && valid_first_js_char s.[0] + && + let module E = struct + exception E + end in + try + for i = 1 to len - 1 do + if not (valid_js_char (String.unsafe_get s i)) then raise E.E + done; + true + with E.E -> false + +let is_package_relative_path (x : string) = + String.starts_with x ~prefix:"./" || String.starts_with x ~prefix:"../" + +let valid_global_name ?loc txt = + if not (valid_ident txt) then + let v = Ext_string.split_by ~keep_empty:true (fun x -> x = '.') txt in + List.iter + (fun s -> + if not (valid_ident s) then + Location.raise_errorf ?loc "Not a valid global name %s" txt) + v + +(* We lose such check (see #2583), + it also helps with the implementation deriving abstract [@as] *) +let valid_method_name ?loc:_ _txt = () +(* if not (valid_ident txt) then + Location.raise_errorf ?loc "Not a valid method name %s" txt *) + +let check_external_module_name ?loc x = + match x with + | { bundle = ""; _ } | { module_bind_name = Phint_name ""; _ } -> + Location.raise_errorf ?loc "empty name encountered" + | _ -> () + +let check_ffi ?loc ffi : bool = + let xrelative = ref false in + let upgrade bool = if not !xrelative then xrelative := bool in + (match ffi with + | Js_var { name; external_module_name; _ } -> + upgrade (is_package_relative_path name); + Option.iter + (fun name -> upgrade (is_package_relative_path name.bundle)) + external_module_name; + valid_global_name ?loc name + | Js_send { name; _ } + | Js_set { js_set_name = name; _ } + | Js_get { js_get_name = name; _ } -> + valid_method_name ?loc name + | Js_get_index _ (* TODO: check scopes *) | Js_set_index _ -> () + | Js_module_as_var external_module_name + | Js_module_as_fn { external_module_name; splice = _ } + | Js_module_as_class external_module_name -> + upgrade (is_package_relative_path external_module_name.bundle); + check_external_module_name external_module_name + | Js_new { external_module_name; name; _ } + | Js_call { external_module_name; name; splice = _; scopes = _ } -> + Option.iter + (fun external_module_name -> + upgrade (is_package_relative_path external_module_name.bundle)) + external_module_name; + Option.iter + (fun name -> check_external_module_name ?loc name) + external_module_name; + + valid_global_name ?loc name); + !xrelative + +let to_string (t : t) = Marshal.to_string t [] + +let () = + Oprint.map_primitive_name := Oprint_mel_primitive_name.map_primitive_name + +external from_bytes_unsafe : bytes -> int -> 'a = "caml_input_value_from_bytes" + +(* TODO: better error message when version mismatch *) +let from_string s : t = + if is_mel_primitive s then from_bytes_unsafe (Bytes.unsafe_of_string s) 0 + else Ffi_normal + +let inline_string_primitive (s : string) (op : string option) : string list = + let lam : Lam_constant.t = + let unicode = + match op with + | Some op -> Utf8_string.is_unicode_string op + | None -> false + in + Const_string { s; unicode } + in + [ ""; to_string (Ffi_inline_const lam) ] + +(* Let's only do it for string ATM + for boolean, and ints, a good optimizer should + do it by default? + But it may not work after layers of indirection + e.g, submodule +*) +let inline_bool_primitive b : string list = + let lam : Lam_constant.t = + if b then Lam_constant.Const_js_true else Lam_constant.Const_js_false + in + [ ""; to_string (Ffi_inline_const lam) ] + +(* FIXME: check overflow ?*) +let inline_int_primitive (i : int32) : string list = + [ ""; to_string (Ffi_inline_const (Const_int { i; comment = None })) ] + +let inline_int64_primitive (i : int64) : string list = + [ ""; to_string (Ffi_inline_const (Const_int64 i)) ] + +let inline_float_primitive (i : string) : string list = + [ ""; to_string (Ffi_inline_const (Const_float i)) ] + +let ffi_mel = + let rec ffi_mel_aux acc (params : External_arg_spec.params) = + match params with + | { arg_type = Nothing; arg_label = Arg_empty } + (* same as External_arg_spec.dummy*) + :: rest -> + ffi_mel_aux (acc + 1) rest + | _ :: _ -> -1 + | [] -> acc + in + fun (params : External_arg_spec.params) return attr -> + let n = ffi_mel_aux 0 params in + if n < 0 then Ffi_mel (Params params, return, attr) + else Ffi_mel (Param_number n, return, attr) + +let ffi_mel_as_prims params return attr = + [ ""; to_string (ffi_mel params return attr) ] + +let ffi_obj_create obj_params = Ffi_obj_create obj_params +let ffi_obj_as_prims obj_params = [ ""; to_string (Ffi_obj_create obj_params) ] diff --git a/jscomp/common/external_ffi_types.mli b/jscomp/common/external_ffi_types.mli index 43f9aa4bf4..50edaac648 100644 --- a/jscomp/common/external_ffi_types.mli +++ b/jscomp/common/external_ffi_types.mli @@ -87,7 +87,7 @@ type return_wrapper = type params = Params of External_arg_spec.params | Param_number of int type t = private - | Ffi_bs of params * return_wrapper * external_spec + | Ffi_mel of params * return_wrapper * external_spec | Ffi_obj_create of External_arg_spec.obj_params | Ffi_inline_const of Lam_constant.t | Ffi_normal @@ -106,9 +106,9 @@ val inline_bool_primitive : bool -> string list val inline_int_primitive : int32 -> string list val inline_int64_primitive : int64 -> string list val inline_float_primitive : string -> string list -val ffi_bs : External_arg_spec.params -> return_wrapper -> external_spec -> t +val ffi_mel : External_arg_spec.params -> return_wrapper -> external_spec -> t -val ffi_bs_as_prims : +val ffi_mel_as_prims : External_arg_spec.params -> return_wrapper -> external_spec -> string list val ffi_obj_create : External_arg_spec.obj_params -> t diff --git a/jscomp/common/external_ffi_types0.ml b/jscomp/common/external_ffi_types0.ml new file mode 100644 index 0000000000..7f9a7cceda --- /dev/null +++ b/jscomp/common/external_ffi_types0.ml @@ -0,0 +1,33 @@ +(* Copyright (C) 2023- Authors of Melange + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + +(* \132\149\166\190 + 0x84 95 A6 BE Intext_magic_small intext.h + https://github.com/ocaml/merlin/commit/b094c937c3a360eb61054f7652081b88e4f3612f +*) +let is_mel_primitive s = + (* TODO(anmonteiro): check this, header_size changed to 16 in 5.1 *) + String.length s >= 20 + (* Marshal.header_size*) && String.unsafe_get s 0 = '\132' + && String.unsafe_get s 1 = '\149' diff --git a/jscomp/common/oprint_mel_primitive_name.dev.ml b/jscomp/common/oprint_mel_primitive_name.dev.ml new file mode 100644 index 0000000000..d8bbc017c2 --- /dev/null +++ b/jscomp/common/oprint_mel_primitive_name.dev.ml @@ -0,0 +1,25 @@ +(* Copyright (C) 2023- Authors of Melange + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + +let map_primitive_name s = String.escaped s (* For debugging*) diff --git a/jscomp/common/oprint_mel_primitive_name.release.ml b/jscomp/common/oprint_mel_primitive_name.release.ml new file mode 100644 index 0000000000..7471fa357e --- /dev/null +++ b/jscomp/common/oprint_mel_primitive_name.release.ml @@ -0,0 +1,26 @@ +(* Copyright (C) 2023- Authors of Melange + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + +let map_primitive_name s = + if External_ffi_types0.is_mel_primitive s then "MEL:external" else s diff --git a/jscomp/core/initialization.ml b/jscomp/core/initialization.ml index 6efb797f7b..04bde338db 100644 --- a/jscomp/core/initialization.ml +++ b/jscomp/core/initialization.ml @@ -53,7 +53,7 @@ module Global = struct (* Turn on [-no-alias-deps] by default -- double check *) Oprint.out_ident := Outcome_printer_ns.out_ident; Builtin_attributes.check_bs_attributes_inclusion := - Record_attributes_check.check_bs_attributes_inclusion; + Record_attributes_check.check_mel_attributes_inclusion; Builtin_attributes.check_duplicated_labels := Record_attributes_check.check_duplicated_labels; Lambda.fld_record := Record_attributes_check.fld_record; diff --git a/jscomp/core/js_name_of_module_id.ml b/jscomp/core/js_name_of_module_id.ml index 15aa02b97f..ccc9e134f6 100644 --- a/jscomp/core/js_name_of_module_id.ml +++ b/jscomp/core/js_name_of_module_id.ml @@ -77,7 +77,7 @@ let get_runtime_module_path ~package_info ~output_info package_info (* ~package_dir:(Lazy.force Ext_path.package_dir) *) ~package_dir:(Sys.getcwd ()) module_system) - (* Invariant: the package path to bs-platform, it is used to + (* Invariant: the package path to `node_modules/melange`, it is used to calculate relative js path *) (Filename.dirname (Filename.dirname Sys.executable_name) // dep_path // js_file)) diff --git a/jscomp/core/lam.ml b/jscomp/core/lam.ml index 4bbc6683c5..6ab819d3b4 100644 --- a/jscomp/core/lam.ml +++ b/jscomp/core/lam.ml @@ -795,7 +795,7 @@ let sequor l r = if_ l true_ r let sequand l r = if_ l r false_ (*********************************) -(* only [handle_bs_non_obj_ffi] will be used outside *) +(* only [handle_mel_non_obj_ffi] will be used outside *) (* [no_auto_uncurried_arg_types xs] check if the FFI have @uncurry attribute. @@ -837,7 +837,7 @@ let rec transform_uncurried_arg_type loc (x :: o_arg_types, y :: o_args)) | ([], [] | _ :: _, [] | [], _ :: _) as ok -> ok -let handle_bs_non_obj_ffi (arg_types : Melange_ffi.External_arg_spec.params) +let handle_mel_non_obj_ffi (arg_types : Melange_ffi.External_arg_spec.params) (result_type : Melange_ffi.External_ffi_types.return_wrapper) ffi args loc prim_name = if no_auto_uncurried_arg_types arg_types then diff --git a/jscomp/core/lam.mli b/jscomp/core/lam.mli index a2015f108a..9781567b09 100644 --- a/jscomp/core/lam.mli +++ b/jscomp/core/lam.mli @@ -90,7 +90,7 @@ and t = private val inner_map : t -> (t -> t) -> t -val handle_bs_non_obj_ffi : +val handle_mel_non_obj_ffi : Melange_ffi.External_arg_spec.params -> Melange_ffi.External_ffi_types.return_wrapper -> Melange_ffi.External_ffi_types.external_spec -> diff --git a/jscomp/core/lam_compile.ml b/jscomp/core/lam_compile.ml index b300f3e4c0..5c05cce72f 100644 --- a/jscomp/core/lam_compile.ml +++ b/jscomp/core/lam_compile.ml @@ -1477,7 +1477,7 @@ and compile_prim (prim_info : Lam.prim_info) compile_sequand l r lambda_cxt | { primitive = Psequor; args = [ l; r ]; _ } -> compile_sequor l r lambda_cxt | { primitive = Pdebugger; _ } -> - (* [%bs.debugger] guarantees that the expression does not matter + (* [%mel.debugger] guarantees that the expression does not matter TODO: make it even safer *) Js_output.output_of_block_and_expression lambda_cxt.continuation S.debugger_block E.unit @@ -1569,7 +1569,7 @@ and compile_prim (prim_info : Lam.prim_info) ap_inlined = Default_inline; ap_status = App_uncurry; }) - (*FIXME: should pass info down: `f a [@bs][@inlined]`*) + (*FIXME: should pass info down: `f a [@u][@inlined]`*) | [] -> assert false) | { primitive = Pjs_fn_method; args = args_lambda; _ } -> ( match args_lambda with diff --git a/jscomp/core/lam_compile_primitive.ml b/jscomp/core/lam_compile_primitive.ml index 701d7f3b87..086e556616 100644 --- a/jscomp/core/lam_compile_primitive.ml +++ b/jscomp/core/lam_compile_primitive.ml @@ -329,7 +329,7 @@ let translate loc (cxt : Lam_compile_context.t) (prim : Lam_primitive.t) | Backend_type -> E.make_block E.zero_int_literal (Blk_constructor { name = "Other"; num_nonconst = 1 }) - [ E.str "BS" ] + [ E.str "Melange" ] Immutable) | Pbswap16 -> E.runtime_call Js_runtime_modules.bytes "bswap16" args | Pbbswap Pnativeint -> assert false diff --git a/jscomp/core/lam_convert.ml b/jscomp/core/lam_convert.ml index 6f0565733f..43c7595edf 100644 --- a/jscomp/core/lam_convert.ml +++ b/jscomp/core/lam_convert.ml @@ -536,7 +536,7 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : | Ffi_obj_create labels -> let args = List.map convert_aux args in prim ~primitive:(Pjs_object_create labels) ~args loc - | Ffi_bs (arg_types, result_type, ffi) -> + | Ffi_mel (arg_types, result_type, ffi) -> let arg_types = match arg_types with | Params ls -> ls @@ -544,7 +544,7 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : List.init i (fun _ -> Melange_ffi.External_arg_spec.dummy) in let args = List.map convert_aux args in - Lam.handle_bs_non_obj_ffi arg_types result_type ffi args loc prim_name + Lam.handle_mel_non_obj_ffi arg_types result_type ffi args loc prim_name | Ffi_inline_const i -> Lam.const i and convert_js_primitive (p : Primitive.description) (args : Lambda.lambda list) loc = @@ -642,7 +642,7 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : | [ Lapply { ap_func; ap_args; _ } ] -> prim ~primitive ~args:(ap_func :: ap_args) loc (* There may be some optimization opportunities here - for cases like `(fun [@bs] a b -> a + b ) 1 2 [@bs]` *) + for cases like `(fun [@u] a b -> a + b ) 1 2 [@u]` *) | _ -> assert false else prim ~primitive ~args loc and convert_aux (lam : Lambda.lambda) : Lam.t = diff --git a/jscomp/core/lam_dispatch_primitive.ml b/jscomp/core/lam_dispatch_primitive.ml index 37961135da..3746e16e4d 100644 --- a/jscomp/core/lam_dispatch_primitive.ml +++ b/jscomp/core/lam_dispatch_primitive.ml @@ -339,5 +339,5 @@ let translate loc (prim_name : string) (args : J.expression list) : J.expression (*we dont use [throw] here, since [throw] is an statement so we wrap in IIFE TODO: we might provoide a hook for user to provide polyfill. - For example `Bs_global.xxx` + For example `Mel_global.xxx` *) diff --git a/jscomp/core/lam_eta_conversion.ml b/jscomp/core/lam_eta_conversion.ml index 3731b0f358..16a93c7142 100644 --- a/jscomp/core/lam_eta_conversion.ml +++ b/jscomp/core/lam_eta_conversion.ml @@ -130,7 +130,7 @@ let unsafe_adjust_to_arity loc ~(to_ : int) ?(from : int option) (fn : Lam.t) : ~body:(Lam.let_ Alias param Lam.unit body) (* could be only introduced by {[ Pjs_fn_make 0 ]} <- - {[ fun [@bs] () -> .. ]} + {[ fun [@u] () -> .. ]} *) | _ -> ( let wrapper, new_fn = diff --git a/jscomp/core/mel_ast_invariant.ml b/jscomp/core/mel_ast_invariant.ml index 15e15cf60f..b3203e21e2 100644 --- a/jscomp/core/mel_ast_invariant.ml +++ b/jscomp/core/mel_ast_invariant.ml @@ -80,8 +80,6 @@ module Core_type = struct let is_arity_one ty = get_curry_arity ty = 1 end -(* Note we only used Bs_ast_iterator here, we can reuse compiler-libs instead of - rolling our own *) let emit_external_warnings : iterator = { super with diff --git a/jscomp/core/melc_warnings.ml b/jscomp/core/melc_warnings.ml index afa8d5fc70..a4126dd8d9 100644 --- a/jscomp/core/melc_warnings.ml +++ b/jscomp/core/melc_warnings.ml @@ -67,7 +67,7 @@ - 50 Unexpected documentation comment. - - 102 Bs_polymorphic_comparison + - 102 Mel_polymorphic_comparison *) let defaults_w = "+a-4-20-29-40-41-42-44-45-48-58-59-60-61-63..70-102" let defaults_warn_error = "-a+5+6+101+109" diff --git a/jscomp/core/record_attributes_check.ml b/jscomp/core/record_attributes_check.ml index 7bdd269d63..5fa2aa3bb5 100644 --- a/jscomp/core/record_attributes_check.ml +++ b/jscomp/core/record_attributes_check.ml @@ -133,7 +133,7 @@ let blk_record_inlined fields name num_nonconst = in Lambda.Blk_record_inlined { fields; name; num_nonconst } -let check_bs_attributes_inclusion (attrs1 : Parsetree.attributes) +let check_mel_attributes_inclusion (attrs1 : Parsetree.attributes) (attrs2 : Parsetree.attributes) lbl_name = let a = find_with_default attrs1 ~f:find_name ~default:lbl_name in let b = find_with_default attrs2 ~f:find_name ~default:lbl_name in diff --git a/jscomp/ext/ext_path.ml b/jscomp/ext/ext_path.ml index 0402ebadf7..52662f10e4 100644 --- a/jscomp/ext/ext_path.ml +++ b/jscomp/ext/ext_path.ml @@ -51,7 +51,7 @@ let node_sep = "/" let node_relative_path = let split_by_sep_per_os : string -> string list = if Sys.win32 || Sys.cygwin then fun x -> - (* on Windows, we can still accept -bs-package-output lib/js *) + (* on Windows, we can still accept -mel-package-output lib/js *) Ext_string.split_by (function '/' | '\\' -> true | _ -> false) x else fun x -> Ext_string.split x '/' in diff --git a/jscomp/ext/gen/build_reserved.ml b/jscomp/ext/gen/build_reserved.ml index 944dd0612b..4bb05f30b8 100644 --- a/jscomp/ext/gen/build_reserved.ml +++ b/jscomp/ext/gen/build_reserved.ml @@ -196,7 +196,7 @@ let binary_search = bool = let mid = (lo + hi) / 2 in let midVal = Array.unsafe_get arr mid in - (* let c = cmp key midVal [@bs] in *) + (* let c = cmp key midVal [@u] in *) if key = midVal then true else if key < midVal then (* a[lo] =< key < a[mid] <= a[hi] *) @@ -211,11 +211,11 @@ let binary_search = if len = 0 then false else let lo = Array.unsafe_get sorted 0 in - (* let c = cmp key lo [@bs] in *) + (* let c = cmp key lo [@u] in *) if key < lo then false else let hi = Array.unsafe_get sorted (len - 1) in - (* let c2 = cmp key hi [@bs]in *) + (* let c2 = cmp key hi [@u]in *) if key > hi then false else binarySearchAux sorted 0 (len - 1) key let is_reserved s = binarySearch sorted_keywords s] diff --git a/jscomp/others/belt.ml b/jscomp/others/belt.ml index 27203bed51..ab99aa5e91 100644 --- a/jscomp/others/belt.ml +++ b/jscomp/others/belt.ml @@ -46,7 +46,7 @@ {[ val forEach : 'a t -> ('a -> unit) -> unit - val forEachU : 'a t -> ('a -> unit [\@bs]) -> unit + val forEachU : 'a t -> ('a -> unit [\@u]) -> unit ]} In general, uncurried version will be faster, but it may be less familiar to diff --git a/jscomp/others/belt_HashMap.mli b/jscomp/others/belt_HashMap.mli index 2db5c0c9cb..6e01652fa9 100644 --- a/jscomp/others/belt_HashMap.mli +++ b/jscomp/others/belt_HashMap.mli @@ -33,14 +33,14 @@ type t = int module I0 = (val Belt.Id.hashableU - ~hash:(fun[\@bs] (a : t) -> a & 0xff_ff) - ~eq:(fun[\@bs] a b -> a = b) + ~hash:(fun[\@u] (a : t) -> a & 0xff_ff) + ~eq:(fun[\@u] a b -> a = b) ) let s0 : (_, string,_) t = make ~hintSize:40 ~id:(module I0) module I1 = (val Belt.Id.hashableU - ~hash:(fun[\@bs] (a : t) -> a & 0xff) - ~eq:(fun[\@bs] a b -> a = b) + ~hash:(fun[\@u] (a : t) -> a & 0xff) + ~eq:(fun[\@u] a b -> a = b) ) let s1 : (_, string,_) t = make ~hintSize:40 ~id:(module I1) ]} diff --git a/jscomp/runtime/caml_format.ml b/jscomp/runtime/caml_format.ml index d4800813bd..6d902535b9 100644 --- a/jscomp/runtime/caml_format.ml +++ b/jscomp/runtime/caml_format.ml @@ -85,7 +85,6 @@ let caml_int_of_string (s : string) : int = let c = if i < len then s.!(i) else '\000' in let d = parse_digit c in let () = if d < 0 || d >= base then failwith "int_of_string" in - (* let () = [%bs.debugger] in *) let rec aux acc k = if k = len then acc else diff --git a/jscomp/runtime/js_global.ml b/jscomp/runtime/js_global.ml index 8c69aec834..dcabcadf9d 100644 --- a/jscomp/runtime/js_global.ml +++ b/jscomp/runtime/js_global.ml @@ -48,7 +48,7 @@ let snooze mins = interval := Js.Nullable.return (Js.Global.setInterval remind (mins * 60 * 1000)) let cancel () = - Js.Nullable.iter !interval (fun[\@bs] intervalId -> Js.Global.clearInterval intervalId) + Js.Nullable.iter !interval (fun[\@u] intervalId -> Js.Global.clearInterval intervalId) ]} @see MDN @@ -66,7 +66,7 @@ let work () = IO.closeHackerNewsTab () let procrastinate mins = - Js.Nullable.iter !timer (fun[\@bs] timer -> Js.Global.clearTimeout timer); + Js.Nullable.iter !timer (fun[\@u] timer -> Js.Global.clearTimeout timer); timer := Js.Nullable.return (Js.Global.setTimeout work (mins * 60 * 1000)) ]} diff --git a/jscomp/runtime/js_promise.ml b/jscomp/runtime/js_promise.ml index 2d59ab674f..715ebd32bb 100644 --- a/jscomp/runtime/js_promise.ml +++ b/jscomp/runtime/js_promise.ml @@ -84,5 +84,5 @@ let errorAsExn (x : error) (e : (exn ->'a option))= if Caml_exceptions.isCamlExceptionOrOpenVariant (Obj.magic x ) then e (Obj.magic x) else None -[%bs.error? ] +[%mel.error? ] *) diff --git a/jscomp/test/406_primitive_test.ml b/jscomp/test/406_primitive_test.ml index 6558c50713..4b0d4fa738 100644 --- a/jscomp/test/406_primitive_test.ml +++ b/jscomp/test/406_primitive_test.ml @@ -1,6 +1,3 @@ - - - let suites : Mt.pair_suites ref = ref [] let test_id = ref 0 @@ -24,7 +21,7 @@ external get_backend_type : unit -> backend_type = let backend_type = get_backend_type () let max_array_length = max_wosize () -;; eq __LOC__ backend_type (Other "BS") +;; eq __LOC__ backend_type (Other "Melange") let f () = let exception A of int in diff --git a/jscomp/test/class_repr.ml b/jscomp/test/class_repr.ml index a2c979b533..9987487b40 100644 --- a/jscomp/test/class_repr.ml +++ b/jscomp/test/class_repr.ml @@ -45,7 +45,7 @@ let () = assert (v1#get_money = 3.) let () = match Sys.backend_type with - | Other "BS" -> + | Other "Melange" -> Js.log (v1#get_money, v2#get_money) | _ -> () (* another code path diff --git a/jscomp/test/dist/jscomp/test/406_primitive_test.js b/jscomp/test/dist/jscomp/test/406_primitive_test.js index d9196b635d..6a78c9e7c5 100644 --- a/jscomp/test/dist/jscomp/test/406_primitive_test.js +++ b/jscomp/test/dist/jscomp/test/406_primitive_test.js @@ -17,14 +17,14 @@ function eq(loc, x, y) { Mt.eq_suites(test_id, suites, loc, x, y); } -eq("File \"jscomp/test/406_primitive_test.ml\", line 16, characters 6-13", 32, 32); +eq("File \"jscomp/test/406_primitive_test.ml\", line 13, characters 6-13", 32, 32); var backend_type = /* Other */{ - _0: "BS" + _0: "Melange" }; -eq("File \"jscomp/test/406_primitive_test.ml\", line 27, characters 6-13", backend_type, /* Other */{ - _0: "BS" +eq("File \"jscomp/test/406_primitive_test.ml\", line 24, characters 6-13", backend_type, /* Other */{ + _0: "Melange" }); function f(param) { diff --git a/jscomp/test/dist/jscomp/test/class_repr.js b/jscomp/test/dist/jscomp/test/class_repr.js index d98df3c14e..7e81b215d6 100644 --- a/jscomp/test/dist/jscomp/test/class_repr.js +++ b/jscomp/test/dist/jscomp/test/class_repr.js @@ -116,7 +116,7 @@ if (Caml_oo_curry.js1(-804710761, 4, v1) !== 3) { }; } -if (typeof Stdlib__Sys.backend_type !== "number" && Stdlib__Sys.backend_type._0 === "BS") { +if (typeof Stdlib__Sys.backend_type !== "number" && Stdlib__Sys.backend_type._0 === "Melange") { console.log([ Caml_oo_curry.js1(-804710761, 7, v1), Caml_oo_curry.js1(-804710761, 8, v2) diff --git a/ppx/ast_derive/ast_derive_abstract.ml b/ppx/ast_derive/ast_derive_abstract.ml index bd247b9693..47610bea3e 100644 --- a/ppx/ast_derive/ast_derive_abstract.ml +++ b/ppx/ast_derive/ast_derive_abstract.ml @@ -107,7 +107,7 @@ let handleTdcl light (tdcl : Parsetree.type_declaration) : ~attrs:get_attrs ~prim: ((* Not needed actually*) - Melange_ffi.External_ffi_types.ffi_bs_as_prims + Melange_ffi.External_ffi_types.ffi_mel_as_prims [ Melange_ffi.External_arg_spec.dummy ] Return_identity (Js_get diff --git a/ppx/ast_external_process.ml b/ppx/ast_external_process.ml index b7c583c596..9066d6b3c6 100644 --- a/ppx/ast_external_process.ml +++ b/ppx/ast_external_process.ml @@ -1072,7 +1072,7 @@ let handle_attributes (loc : Location.t) (type_annotation : Parsetree.core_type) check_return_wrapper loc external_desc.return_wrapper result_type in ( mk_fn_type new_arg_types_ty result_type, - External_ffi_types.ffi_bs arg_type_specs return_wrapper ffi, + External_ffi_types.ffi_mel arg_type_specs return_wrapper ffi, unused_attrs, relative )