exn_used := true;
<:expr<
- Bitmatch.$lid:construct_func$ $lid:buffer$ $fexpr$ $flen$
+ Bitmatch.$lid:construct_func$ $lid:buffer$ $fexpr$ $`int:i$
$lid:exn$
>>
(* String, constant length > 0, must be a multiple of 8. *)
| String, Some i when i > 0 && i land 7 = 0 ->
let bs = gensym "bs" in
+ let j = i lsr 3 in
<:expr<
let $lid:bs$ = $fexpr$ in
- if String.length $lid:bs$ = ($flen$ lsr 3) then
+ if String.length $lid:bs$ = $`int:j$ then
Bitmatch.construct_string $lid:buffer$ $lid:bs$
else
raise (Bitmatch.Construct_failure
let bs = gensym "bs" in
<:expr<
let $lid:bs$ = $fexpr$ in
- if Bitmatch.bitstring_length $lid:bs$ = $flen$ then
+ if Bitmatch.bitstring_length $lid:bs$ = $`int:i$ then
Bitmatch.construct_bitstring $lid:buffer$ $lid:bs$
else
raise (Bitmatch.Construct_failure
let extract_func = name_of_int_extract_const (i,endian,signed) in
let v = gensym "val" in
<:expr<
- if $lid:len$ >= $flen$ then (
+ if $lid:len$ >= $`int:i$ then (
let $lid:v$, $lid:off$, $lid:len$ =
Bitmatch.$lid:extract_func$ $lid:data$ $lid:off$ $lid:len$
- $flen$ in
+ $`int:i$ in
match $lid:v$ with $fpatt$ when true -> $inner$ | _ -> ()
)
>>
| String, Some i when i > 0 && i land 7 = 0 ->
let bs = gensym "bs" in
<:expr<
- if $lid:len$ >= $flen$ then (
+ if $lid:len$ >= $`int:i$ then (
let $lid:bs$, $lid:off$, $lid:len$ =
Bitmatch.extract_bitstring $lid:data$ $lid:off$ $lid:len$
- $flen$ in
+ $`int:i$ in
match Bitmatch.string_of_bitstring $lid:bs$ with
| $fpatt$ when true -> $inner$
| _ -> ()
Loc.raise _loc
(Failure "cannot compare a bitstring to a constant") in
<:expr<
- if $lid:len$ >= $flen$ then (
+ if $lid:len$ >= $`int:i$ then (
let $lid:ident$, $lid:off$, $lid:len$ =
Bitmatch.extract_bitstring $lid:data$ $lid:off$ $lid:len$
- $flen$ in
+ $`int:i$ in
$inner$
)
>>