package MlFront_Core

  1. Overview
  2. Docs

Source file UnitMods.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
type library_aliased = {
  bound_name : string;
  qualified_module_id : string;
  unwrapper_opt : string option;
}

let pp_library_aliased ppf { bound_name; qualified_module_id; unwrapper_opt } =
  Format.fprintf ppf "%s=%s%s" bound_name qualified_module_id
    (match unwrapper_opt with None -> "" | Some u -> "." ^ u)

type t = {
  no_standard_lib : bool;
  module_alert_specs : string list;
  libraries_aliased : library_aliased list;
  modules_opened : string list;
  unmodelled_ocamlc_opt_compile_flags : string list;
  unmodelled_ocamlc_opt_link_flags : string list;
  unmodelled_libraries : string list;
}

let pp ppf
    {
      no_standard_lib;
      module_alert_specs;
      libraries_aliased;
      modules_opened;
      unmodelled_ocamlc_opt_compile_flags;
      unmodelled_ocamlc_opt_link_flags;
      unmodelled_libraries;
    } =
  let pp_list_string =
    Format.pp_print_list ~pp_sep:Format.pp_print_space Format.pp_print_string
  in
  Format.fprintf ppf
    "@[<v 2>Unit modifications:@ @[<v>%s.@;\
     @[<hov 2>Alerts: %a@]@;\
     @[<hov 2>Libraries: %a@]@;\
     @[<hov 2>Library Aliases: %a@]@;\
     @[<hov 2>Opened modules: %a@]@;\
     @[<hov 2>OCaml compile flags: %a@]@;\
     @[<hov 2>OCaml link flags: %a@]@]@]"
    (if no_standard_lib then "No stdlib" else "Stdlib")
    pp_list_string module_alert_specs pp_list_string unmodelled_libraries
    (Format.pp_print_list ~pp_sep:Format.pp_print_space pp_library_aliased)
    libraries_aliased pp_list_string modules_opened pp_list_string
    unmodelled_ocamlc_opt_compile_flags pp_list_string
    unmodelled_ocamlc_opt_link_flags

let none_with_standard_lib : t =
  {
    no_standard_lib = false;
    module_alert_specs = [];
    libraries_aliased = [];
    modules_opened = [];
    unmodelled_ocamlc_opt_compile_flags = [];
    unmodelled_ocamlc_opt_link_flags = [];
    unmodelled_libraries = [];
  }

let none_with_no_standard_lib =
  { none_with_standard_lib with no_standard_lib = true }

let union
    {
      no_standard_lib = a1;
      module_alert_specs = a2;
      libraries_aliased = a3;
      modules_opened = a4;
      unmodelled_ocamlc_opt_compile_flags = a5;
      unmodelled_ocamlc_opt_link_flags = a6;
      unmodelled_libraries = a7;
    }
    {
      no_standard_lib = b1;
      module_alert_specs = b2;
      libraries_aliased = b3;
      modules_opened = b4;
      unmodelled_ocamlc_opt_compile_flags = b5;
      unmodelled_ocamlc_opt_link_flags = b6;
      unmodelled_libraries = b7;
    } =
  let standard_lib =
    (* If any standard library, then the union has the standard library. *)
    (not a1) || not b1
  in
  {
    no_standard_lib = not standard_lib;
    module_alert_specs = a2 @ b2;
    libraries_aliased = a3 @ b3;
    modules_opened = a4 @ b4;
    unmodelled_ocamlc_opt_compile_flags = a5 @ b5;
    unmodelled_ocamlc_opt_link_flags = a6 @ b6;
    unmodelled_libraries = a7 @ b7;
  }
OCaml

Innovation. Community. Security.