@@ -87,7 +87,7 @@ module Scoped_location = struct
87
87
cons scopes Sc_method_definition str s
88
88
89
89
let enter_lazy ~scopes = cons scopes Sc_lazy (str scopes) " "
90
-
90
+
91
91
let enter_partial_or_eta_wrapper ~scopes =
92
92
cons scopes Sc_partial_or_eta_wrapper (dot ~no_parens: () scopes " (partial)" ) " "
93
93
@@ -143,20 +143,21 @@ type item = {
143
143
dinfo_scopes : Scoped_location .scopes ;
144
144
}
145
145
146
- type t = item list
146
+ type t = { dbg : item list ; }
147
147
148
148
type alloc_dbginfo_item =
149
149
{ alloc_words : int ;
150
150
alloc_dbg : t }
151
151
type alloc_dbginfo = alloc_dbginfo_item list
152
152
153
- let none = []
153
+ let none = { dbg = [] ; }
154
154
155
- let is_none = function
155
+ let is_none { dbg } =
156
+ match dbg with
156
157
| [] -> true
157
158
| _ :: _ -> false
158
159
159
- let to_string dbg =
160
+ let to_string { dbg } =
160
161
match dbg with
161
162
| [] -> " "
162
163
| ds ->
@@ -190,12 +191,13 @@ let item_from_location ~scopes loc =
190
191
}
191
192
192
193
let from_location = function
193
- | Scoped_location. Loc_unknown -> []
194
+ | Scoped_location. Loc_unknown -> { dbg = [] ; }
194
195
| Scoped_location. Loc_known {scopes; loc} ->
195
196
assert (not (Location. is_none loc));
196
- [item_from_location ~scopes loc]
197
+ { dbg = [item_from_location ~scopes loc]; }
197
198
198
- let to_location = function
199
+ let to_location { dbg } =
200
+ match dbg with
199
201
| [] -> Location. none
200
202
| d :: _ ->
201
203
let loc_start =
@@ -212,15 +214,15 @@ let to_location = function
212
214
} in
213
215
{ loc_ghost = false ; loc_start; loc_end; }
214
216
215
- let inline dbg1 dbg2 =
216
- dbg1 @ dbg2
217
+ let inline { dbg = dbg1 ; } { dbg = dbg2 ; } =
218
+ { dbg = dbg1 @ dbg2; }
217
219
218
220
(* CR-someday afrisch: FWIW, the current compare function does not seem very
219
221
good, since it reverses the two lists. I don't know how long the lists are,
220
222
nor if the specific currently implemented ordering is useful in other
221
223
contexts, but if one wants to use Map, a more efficient comparison should
222
224
be considered. *)
223
- let compare dbg1 dbg2 =
225
+ let compare { dbg = dbg1 ; } { dbg = dbg2 ; } =
224
226
let rec loop ds1 ds2 =
225
227
match ds1, ds2 with
226
228
| [] , [] -> 0
@@ -245,8 +247,8 @@ let compare dbg1 dbg2 =
245
247
in
246
248
loop (List. rev dbg1) (List. rev dbg2)
247
249
248
- let hash t =
249
- List. fold_left (fun hash item -> Hashtbl. hash (hash, item)) 0 t
250
+ let hash { dbg; } =
251
+ List. fold_left (fun hash item -> Hashtbl. hash (hash, item)) 0 dbg
250
252
251
253
let rec print_compact ppf t =
252
254
let print_item item =
@@ -264,3 +266,9 @@ let rec print_compact ppf t =
264
266
print_item item;
265
267
Format. fprintf ppf " ;" ;
266
268
print_compact ppf t
269
+
270
+ let print_compact ppf { dbg; } = print_compact ppf dbg
271
+
272
+ let to_list { dbg; } = dbg
273
+
274
+ let length { dbg; } = List. length dbg
0 commit comments