diff options
Diffstat (limited to 'plugins/extraction/ocaml.ml')
-rw-r--r-- | plugins/extraction/ocaml.ml | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/plugins/extraction/ocaml.ml b/plugins/extraction/ocaml.ml index 39ec20617..377648422 100644 --- a/plugins/extraction/ocaml.ml +++ b/plugins/extraction/ocaml.ml @@ -607,8 +607,8 @@ let rec pp_specif = function pp_alias_spec ren s with Not_found -> pp_spec s) | (l,Smodule mt) -> - let def = pp_module_type (Some l) mt in - let def' = pp_module_type (Some l) mt in + let def = pp_module_type mt in + let def' = pp_module_type mt in let name = pp_modname (MPdot (top_visible_mp (), l)) in hov 1 (str "module " ++ name ++ str " : " ++ fnl () ++ def) ++ (try @@ -616,7 +616,7 @@ let rec pp_specif = function fnl () ++ hov 1 (str ("module "^ren^" : ") ++ fnl () ++ def') with Not_found -> Pp.mt ()) | (l,Smodtype mt) -> - let def = pp_module_type None mt in + let def = pp_module_type mt in let name = pp_modname (MPdot (top_visible_mp (), l)) in hov 1 (str "module type " ++ name ++ str " = " ++ fnl () ++ def) ++ (try @@ -624,20 +624,16 @@ let rec pp_specif = function fnl () ++ str ("module type "^ren^" = ") ++ name with Not_found -> Pp.mt ()) -and pp_module_type ol = function +and pp_module_type = function | MTident kn -> pp_modname kn | MTfunsig (mbid, mt, mt') -> - let typ = pp_module_type None mt in + let typ = pp_module_type mt in let name = pp_modname (MPbound mbid) in - let def = pp_module_type None mt' in + let def = pp_module_type mt' in str "functor (" ++ name ++ str ":" ++ typ ++ str ") ->" ++ fnl () ++ def | MTsig (mp1, sign) -> - let tvm = top_visible_mp () in - let mp = match ol with None -> mp1 | Some l -> MPdot (tvm,l) in - (* References in [sign] are in short form (relative to [msid]). - In push_visible, [msid-->mp] is added to the current subst. *) - push_visible mp (Some mp1); + push_visible mp1; let l = map_succeed pp_specif sign in pop_visible (); str "sig " ++ fnl () ++ @@ -652,9 +648,9 @@ and pp_module_type ol = function in let r = ConstRef (make_con mp_w empty_dirpath (label_of_id l)) in - push_visible mp_mt None; + push_visible mp_mt; let s = - pp_module_type None mt ++ str " with type " ++ + pp_module_type mt ++ str " with type " ++ pp_global Type r ++ ids in pop_visible(); @@ -664,9 +660,9 @@ and pp_module_type ol = function let mp_w = List.fold_left (fun mp id -> MPdot(mp,label_of_id id)) mp_mt idl in - push_visible mp_mt None; + push_visible mp_mt; let s = - pp_module_type None mt ++ str " with module " ++ pp_modname mp_w + pp_module_type mt ++ str " with module " ++ pp_modname mp_w in pop_visible (); s ++ str " = " ++ pp_modname mp @@ -685,10 +681,10 @@ let rec pp_structure_elem = function let typ = (* virtual printing of the type, in order to have a correct mli later*) if Common.get_phase () = Pre then - str ": " ++ pp_module_type (Some l) m.ml_mod_type + str ": " ++ pp_module_type m.ml_mod_type else mt () in - let def = pp_module_expr (Some l) m.ml_mod_expr in + let def = pp_module_expr m.ml_mod_expr in let name = pp_modname (MPdot (top_visible_mp (), l)) in hov 1 (str "module " ++ name ++ typ ++ str " = " ++ @@ -698,7 +694,7 @@ let rec pp_structure_elem = function fnl () ++ str ("module "^ren^" = ") ++ name with Not_found -> mt ()) | (l,SEmodtype m) -> - let def = pp_module_type None m in + let def = pp_module_type m in let name = pp_modname (MPdot (top_visible_mp (), l)) in hov 1 (str "module type " ++ name ++ str " = " ++ fnl () ++ def) ++ (try @@ -706,21 +702,17 @@ let rec pp_structure_elem = function fnl () ++ str ("module type "^ren^" = ") ++ name with Not_found -> mt ()) -and pp_module_expr ol = function +and pp_module_expr = function | MEident mp' -> pp_modname mp' | MEfunctor (mbid, mt, me) -> let name = pp_modname (MPbound mbid) in - let typ = pp_module_type None mt in - let def = pp_module_expr None me in + let typ = pp_module_type mt in + let def = pp_module_expr me in str "functor (" ++ name ++ str ":" ++ typ ++ str ") ->" ++ fnl () ++ def | MEapply (me, me') -> - pp_module_expr None me ++ str "(" ++ pp_module_expr None me' ++ str ")" + pp_module_expr me ++ str "(" ++ pp_module_expr me' ++ str ")" | MEstruct (mp, sel) -> - let tvm = top_visible_mp () in - let mp = match ol with None -> mp | Some l -> MPdot (tvm,l) in - (* No need to update the subst with [Some msid] below : names are - already in long form (see [subst_structure] in [Extract_env]). *) - push_visible mp None; + push_visible mp; let l = map_succeed pp_structure_elem sel in pop_visible (); str "struct " ++ fnl () ++ @@ -731,7 +723,7 @@ let do_struct f s = let pp s = try f s ++ fnl2 () with Failure "empty phrase" -> mt () in let ppl (mp,sel) = - push_visible mp None; + push_visible mp; let p = prlist_strict pp sel in (* for monolithic extraction, we try to simulate the unavailability of [MPfile] in names by artificially nesting these [MPfile] *) |