Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
tatchi committed May 16, 2021
1 parent 3373bf5 commit d8b346c
Show file tree
Hide file tree
Showing 13 changed files with 458 additions and 380 deletions.
2 changes: 2 additions & 0 deletions src/compat/env_lookup_ge_000.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
let lookup_module ~loc:_ lid env = Env.lookup_module ~load:true lid env

let find_type env ~loc head_id = Typetexp.find_type env loc head_id

let find_modtype env ~loc head_id = Typetexp.find_modtype env loc head_id
2 changes: 2 additions & 0 deletions src/compat/env_lookup_ge_410.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
let lookup_module ~loc lid env = Env.lookup_module ~loc lid env |> fst

let find_type env ~loc head_id = Env.lookup_type ~loc head_id env

let find_modtype env ~loc:_ head_id = Env.find_modtype_by_name head_id env
17 changes: 8 additions & 9 deletions src/compat/gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@ let make_version ~version f_prefix =
(* List of versions that need special treatment, check is greater or
equal than. Order is important! *)
let include_table =
[ "types_module_type" , [4,10; 4,8]
; "types_signature_item" , [4,8]
; "init_path" , [4,9]
; "env_lookup" , [4,10]
[
("types_module_type", [ (4, 10); (4, 8) ]);
("types_signature_item", [ (4, 8) ]);
("init_path", [ (4, 9) ]);
("env_lookup", [ (4, 10) ]);
]

let rec gen_compat real_version (f_prefix, version_list) =
match version_list with
| [] -> include_ (make_version ~version:(0,0) f_prefix)
| [] -> include_ (make_version ~version:(0, 0) f_prefix)
| version :: vlist ->
if real_version >= version then
include_ (make_version ~version f_prefix)
else
gen_compat real_version (f_prefix, vlist)
if real_version >= version then include_ (make_version ~version f_prefix)
else gen_compat real_version (f_prefix, vlist)

let () =
let version = Scanf.sscanf Sys.ocaml_version "%d.%d" (fun a b -> (a, b)) in
Expand Down
3 changes: 1 addition & 2 deletions src/compat/types_module_type_ge_000.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
type module_type_407 = Types.module_type

let migrate_module_type : Types.module_type -> module_type_407 =
fun x -> x
let migrate_module_type : Types.module_type -> module_type_407 = fun x -> x
12 changes: 6 additions & 6 deletions src/compat/types_module_type_ge_410.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ type module_type_407 =
let migrate_module_type : Types.module_type -> module_type_407 = function
| Mty_ident p -> Mty_ident p
| Mty_signature s -> Mty_signature s
| Mty_functor (fp, mt) ->
(match fp with
| Unit -> Mty_functor(Ident.create_local "_", None, mt)
| Named(i,mt) ->
let i = (match i with None -> Ident.create_local "_" | Some i -> i) in
Mty_functor (i, Some mt, mt))
| Mty_functor (fp, mt) -> (
match fp with
| Unit -> Mty_functor (Ident.create_local "_", None, mt)
| Named (i, mt) ->
let i = match i with None -> Ident.create_local "_" | Some i -> i in
Mty_functor (i, Some mt, mt))
| Mty_alias p -> Mty_alias ((), p)
2 changes: 1 addition & 1 deletion src/compat/types_signature_item_ge_000.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type signature_item_407 = Types.signature_item

let migrate_signature_item : Types.signature_item -> signature_item_407 =
fun x -> x
fun x -> x
13 changes: 8 additions & 5 deletions src/dune
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
(library
(public_name ppx_import)
(kind ppx_rewriter)
(preprocess (pps ppx_tools_versioned.metaquot_411))
(libraries ppx_tools_versioned
ocaml-migrate-parsetree))
(preprocess
(pps ppx_tools_versioned.metaquot_411))
(libraries ppx_tools_versioned ocaml-migrate-parsetree))

(rule
(deps (glob_files compat/*.ml))
(deps
(glob_files compat/*.ml))
(targets compat.ml)
(action
(with-stdout-to %{targets} (run ./compat/gen.exe))))
(with-stdout-to
%{targets}
(run ./compat/gen.exe))))
Loading

0 comments on commit d8b346c

Please sign in to comment.