4 symbols : (string list * string) list;
6 modules : string list list;
10 let module_ name program : Ast.stmt' =
11 `Module {Ast.module_name = Node.ghost name;
16 val entries = [] with reader
18 method mem_symbol (ns,name) =
26 let lazy {symbols=symbols} =
27 List.assoc file entries in
32 method mem_method meth =
33 List.exists (fun (_,lazy {methods=methods}) ->
34 List.mem meth methods) entries
36 method mem_module name =
42 let lazy {modules=modules} =
43 List.assoc file entries in
49 List.map (fun (name,lazy {program=program}) -> module_ name program) entries
51 method add name entry =
52 {< entries = entries @ [name,entry] >}
55 (* program -> table *)
59 let to_entry program= {
62 +> HList.concat_map Ast.public_symbols
63 +> List.map Node.value;
66 +> HList.concat_map Ast.public_methods
67 +> List.map Node.value;
70 +> HList.concat_map Ast.public_modules
71 +> List.map Node.value;
76 let chop_suffix name suffix =
77 if Filename.check_suffix name suffix then
78 Filename.chop_suffix name suffix
84 let add name program table =
85 table#add name @@ (lazy (to_entry program))
87 let input name path table =
89 open_in_with path begin fun ch ->
92 if version' = version then
93 let symbols = input_value ch in
94 let methods = input_value ch in
95 let modules = input_value ch in
96 let program = input_value ch in
102 failwith ("invalid format:"^path)
104 table#add name (lazy (entry ()))
106 let output name path table =
109 +> (fun (lazy entry) ->
110 open_out_with path begin fun ch ->
111 output_value ch version;
112 output_value ch entry.symbols;
113 output_value ch entry.methods;
114 output_value ch entry.modules;
115 output_value ch entry.program