@@ -169,58 +169,73 @@ end = struct
169
169
let to_list t = t
170
170
end
171
171
172
- (* As with [Name.t], changing [with_prefix] or [t] requires bumping magic
173
- numbers. *)
174
- type with_prefix =
175
- { name : Name .t ;
176
- for_pack_prefix : Prefix .t
177
- }
178
-
179
- (* type t = Without_prefix of Name.t [@@unboxed] | With_prefix of with_prefix *)
180
- type t = Obj .t
181
-
182
- (* Some manual inlining is done here to ensure good performance under
183
- Closure. *)
184
-
185
- let for_pack_prefix_and_name t =
186
- let tag = Obj. tag t in
187
- assert (tag = 0 || tag = Obj. string_tag);
188
- if tag <> 0
189
- then Prefix. empty, Sys. opaque_identity (Obj. obj t : Name.t )
190
- else
191
- let with_prefix = Sys. opaque_identity (Obj. obj t : with_prefix ) in
192
- with_prefix.for_pack_prefix, with_prefix.name
193
-
194
- let name t =
195
- let tag = Obj. tag t in
196
- assert (tag = 0 || tag = Obj. string_tag);
197
- if tag <> 0
198
- then Sys. opaque_identity (Obj. obj t : Name.t )
199
- else
200
- let with_prefix = Sys. opaque_identity (Obj. obj t : with_prefix ) in
201
- with_prefix.name
202
-
203
- let for_pack_prefix t =
204
- let tag = Obj. tag t in
205
- assert (tag = 0 || tag = Obj. string_tag);
206
- if tag <> 0
207
- then Prefix. empty
208
- else
209
- let with_prefix = Sys. opaque_identity (Obj. obj t : with_prefix ) in
210
- with_prefix.for_pack_prefix
211
-
212
- let create for_pack_prefix name =
213
- let empty_prefix = Prefix. is_empty for_pack_prefix in
214
- let () =
215
- if not empty_prefix
216
- then (
217
- Name. check_as_path_component name;
218
- ListLabels. iter ~f: Name. check_as_path_component
219
- (for_pack_prefix |> Prefix. to_list))
220
- in
221
- if empty_prefix
222
- then Sys. opaque_identity (Obj. repr name)
223
- else Sys. opaque_identity (Obj. repr { for_pack_prefix; name })
172
+ module T0 : sig
173
+ type t
174
+
175
+ val for_pack_prefix_and_name : t -> Prefix .t * Name .t
176
+
177
+ val name : t -> Name .t
178
+
179
+ val for_pack_prefix : t -> Prefix .t
180
+
181
+ val create : Prefix .t -> Name .t -> t
182
+ end = struct
183
+ (* As with [Name.t], changing [with_prefix] or [t] requires bumping magic
184
+ numbers. *)
185
+ type with_prefix =
186
+ { name : Name .t ;
187
+ for_pack_prefix : Prefix .t
188
+ }
189
+
190
+ (* type t = Without_prefix of Name.t [@@unboxed] | With_prefix of
191
+ with_prefix *)
192
+ type t = Obj .t
193
+
194
+ (* Some manual inlining is done here to ensure good performance under
195
+ Closure. *)
196
+
197
+ let for_pack_prefix_and_name t =
198
+ let tag = Obj. tag t in
199
+ assert (tag = 0 || tag = Obj. string_tag);
200
+ if tag <> 0
201
+ then Prefix. empty, Sys. opaque_identity (Obj. obj t : Name.t )
202
+ else
203
+ let with_prefix = Sys. opaque_identity (Obj. obj t : with_prefix ) in
204
+ with_prefix.for_pack_prefix, with_prefix.name
205
+
206
+ let name t =
207
+ let tag = Obj. tag t in
208
+ assert (tag = 0 || tag = Obj. string_tag);
209
+ if tag <> 0
210
+ then Sys. opaque_identity (Obj. obj t : Name.t )
211
+ else
212
+ let with_prefix = Sys. opaque_identity (Obj. obj t : with_prefix ) in
213
+ with_prefix.name
214
+
215
+ let for_pack_prefix t =
216
+ let tag = Obj. tag t in
217
+ assert (tag = 0 || tag = Obj. string_tag);
218
+ if tag <> 0
219
+ then Prefix. empty
220
+ else
221
+ let with_prefix = Sys. opaque_identity (Obj. obj t : with_prefix ) in
222
+ with_prefix.for_pack_prefix
223
+
224
+ let create for_pack_prefix name =
225
+ let empty_prefix = Prefix. is_empty for_pack_prefix in
226
+ let () =
227
+ if not empty_prefix
228
+ then (
229
+ Name. check_as_path_component name;
230
+ ListLabels. iter ~f: Name. check_as_path_component
231
+ (for_pack_prefix |> Prefix. to_list))
232
+ in
233
+ if empty_prefix
234
+ then Sys. opaque_identity (Obj. repr name)
235
+ else Sys. opaque_identity (Obj. repr { for_pack_prefix; name })
236
+ end
237
+
238
+ include T0
224
239
225
240
let create_child parent name_ =
226
241
let prefix =
0 commit comments