@@ -45,6 +45,9 @@ type field = {
45
45
off : int ;
46
46
}
47
47
48
+ let field_is_ignored f =
49
+ String. get f.field 0 = '_'
50
+
48
51
type t = {
49
52
name : string ;
50
53
fields : field list ;
@@ -220,14 +223,17 @@ let hexdump_to_buffer_expr s =
220
223
| UInt64 -> [% expr " 0x%Lx\n " ]
221
224
in
222
225
let hexdump_field f =
223
- let get_f = op_evar s (Op_get f) in
224
- let expr =
225
- match f.ty with
226
- | Prim p ->
227
- [% expr Printf. bprintf buf [% e prim_format_string p] ([% e get_f] v)]
228
- | Buffer (_ ,_ ) ->
229
- [% expr Printf. bprintf buf " <buffer %s>" [% e Ast. str (field_to_string f)];
230
- Cstruct. hexdump_to_buffer buf ([% e get_f] v)]
226
+ if field_is_ignored f then
227
+ [% expr () ]
228
+ else
229
+ let get_f = op_evar s (Op_get f) in
230
+ let expr =
231
+ match f.ty with
232
+ | Prim p ->
233
+ [% expr Printf. bprintf buf [% e prim_format_string p] ([% e get_f] v)]
234
+ | Buffer (_ ,_ ) ->
235
+ [% expr Printf. bprintf buf " <buffer %s>" [% e Ast. str (field_to_string f)];
236
+ Cstruct. hexdump_to_buffer buf ([% e get_f] v)]
231
237
in
232
238
[% expr
233
239
Printf. bprintf buf " %s = " [% e Ast. str f.field];
@@ -249,26 +255,25 @@ let op_expr loc s = function
249
255
[% expr fun src srcoff dst ->
250
256
Cstruct. blit src srcoff dst [% e Ast. int f.off] [% e Ast. int len]]
251
257
258
+ let field_ops_for f =
259
+ if field_is_ignored f then
260
+ []
261
+ else
262
+ let if_buffer x =
263
+ match f.ty with
264
+ | Buffer (_ ,_ ) -> [x]
265
+ | Prim _ -> []
266
+ in
267
+ List. concat
268
+ [ [Op_get f]
269
+ ; if_buffer (Op_copy f)
270
+ ; [Op_set f]
271
+ ; if_buffer (Op_blit f)
272
+ ]
273
+
252
274
let ops_for s =
253
- let field_ops =
254
- List. concat (
255
- List. map (fun f ->
256
- let if_buffer x =
257
- match f.ty with
258
- | Buffer (_ ,_ ) -> [x]
259
- | Prim _ -> []
260
- in
261
- List. concat
262
- [ [Op_get f]
263
- ; if_buffer (Op_copy f)
264
- ; [Op_set f]
265
- ; if_buffer (Op_blit f)
266
- ]
267
- ) s.fields
268
- )
269
- in
270
275
( [Op_sizeof ]
271
- @ field_ops
276
+ @ List. concat ( List. map field_ops_for s.fields)
272
277
@ [Op_hexdump_to_buffer ;
273
278
Op_hexdump ;
274
279
])
0 commit comments