Commit a2d24141 authored by Kim Nguyễn's avatar Kim Nguyễn
Browse files

Add compatibility layer with OCaml 4.11

parent 59c08ff4
......@@ -30,7 +30,7 @@ build: [
dev-repo: "git+https://gitlab.math.univ-paris-diderot.fr/cduce/cduce/"
depends: [
"ocaml" {>= "4.07.0"}
"dune" {build & >= "2.8"}
"dune" {build & >= "2.4"}
"menhir" {build & >= "20181026"}
"cduce-types"
"odoc" {with-doc}
......
......@@ -7,7 +7,9 @@ let () =
) with
4 :: 7 :: _ -> "407"
| 4 :: (8|9) :: _ -> "408_9"
| _ -> "410"
| 4 :: 10 :: _ -> "410"
| 4 :: 11 :: _ -> "411"
| _ -> "411"
in Jbuild_plugin.V1.send (Printf.sprintf {|
(library
(name cduce_ocamliface)
......
(* Compatibilty for OCaml 4.08 & 4.09 *)
open Cduce_core
let longident_parse = Ocaml_common.Longident.parse
module Mlstub =
struct
......
(* Compatibilty for OCaml 4.10 & 4.11 *)
open Cduce_core
let longident_parse s = Ocaml_common.Parse.longident (Lexing.from_string s)
module Mlstub =
struct
let noloc id = Some id
let str_open l =
let open Ocaml_common.Ast_helper in
Str.open_ (Opn.mk (Mod.ident l))
end
module Mltypes =
struct
let lookup_value li env =
Ocaml_common.Env.find_value_by_name li env
let lookup_module li env =
fst (Ocaml_common.Env.find_module_by_name li env)
let load_path =
let once = ref false in
function () ->
if !once then () else begin
once := true;
List.iter Ocaml_common.Load_path.add_dir (List.rev !Cduce_loc.obj_path);
Ocaml_common.Load_path.add_dir Ocaml_common.Config.standard_library
end
let find_in_path file =
Ocaml_common.Misc.find_in_path_uncap (Ocaml_common.Load_path.get_paths()) file
let get_path_from_pdot e =
match e with
Ocaml_common.Path.Pdot (p, _) -> p
| _ -> assert false
let is_sig_value_val_reg e =
match e with
Ocaml_common.Types.Sig_value (_, {val_type=_;val_kind=Val_reg; _}, _) -> true
| _ -> false
let get_id_t_from_sig_value e =
match e with
Ocaml_common.Types.Sig_value (id, {val_type=t; _}, _) -> (id, t)
| _ -> assert false
let get_sig_type e =
match e with
Ocaml_common.Types.Sig_type(id, t, rs, _) -> (id, t, rs)
| _ -> assert false
end
......@@ -89,7 +89,7 @@ struct
open Ocaml_common
let lid s =
Location.mknoloc (Longident.parse s)
Location.mknoloc (Mlcompat.longident_parse s)
type arg_label = Nolabel
| Labelled of string
......
......@@ -304,7 +304,7 @@ let has_cmi name =
let find_value v =
Mlcompat.Mltypes.load_path ();
let li = Ocaml.Longident.parse v in
let li = Mlcompat.longident_parse v in
ocaml_env := env_initial;
let _, vd = Mlcompat.Mltypes.lookup_value li env_initial in
unfold vd.Ocaml.Types.val_type
......@@ -327,7 +327,7 @@ let values_of_sig name sg =
let load_module name =
Mlcompat.Mltypes.load_path ();
let li = Ocaml.Longident.parse name in
let li = Mlcompat.longident_parse name in
ocaml_env := env_initial;
let path = Mlcompat.Mltypes.lookup_module li env_initial in
let mty = Ocaml.Env.find_modtype_expansion path env_initial in
......
......@@ -4,5 +4,5 @@
(package cduce)
(optional)
(modules dtd2cduce)
(libraries netcgi2 pxp threads)
(libraries threads.posix netcgi2 pxp threads)
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment