Source file byte_sequence_impl.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
(** [byte_sequence_ocaml.lem], a list of bytes used for ELF I/O and other basic
* tasks in the ELF model.
*)
open Lem_basic_classes
open Lem_bool
open Lem_list
open Lem_num
open Lem_string
open Lem_assert_extra
open Error
open Lem_maybe
open Missing_pervasives
open Show
(** A [byte_sequence], [bs], denotes a consecutive list of bytes. Can be read
* from or written to a binary file. Most basic type in the ELF formalisation.
* This is a faster OCaml byte sequence implementation.
*)
let instance_Basic_classes_Ord_Byte_sequence_impl_byte_sequence_dict:(Byte_sequence_wrapper.byte_sequence)ord_class= ({
compare_method = Byte_sequence_wrapper.compare;
isLess_method = (fun f1 -> (fun f2 -> ( Lem.orderingEqual(Byte_sequence_wrapper.compare f1 f2) (-1))));
isLessEqual_method = (fun f1 -> (fun f2 -> let result = (Byte_sequence_wrapper.compare f1 f2) in Lem.orderingEqual result (-1) || Lem.orderingEqual result 0));
isGreater_method = (fun f1 -> (fun f2 -> ( Lem.orderingEqual(Byte_sequence_wrapper.compare f1 f2) 1)));
isGreaterEqual_method = (fun f1 -> (fun f2 -> let result = (Byte_sequence_wrapper.compare f1 f2) in Lem.orderingEqual result 1 || Lem.orderingEqual result 0))})
let instance_Show_Show_Byte_sequence_impl_byte_sequence_dict:(Byte_sequence_wrapper.byte_sequence)show_class= ({
show_method = Byte_sequence_wrapper.to_string})
let instance_Basic_classes_Eq_Byte_sequence_impl_byte_sequence_dict:(Byte_sequence_wrapper.byte_sequence)eq_class= ({
isEqual_method = Byte_sequence_wrapper.equal;
isInequal_method = (fun l r->not (Byte_sequence_wrapper.equal l r))})
let takebytes_with_length count ts_length ts:(Byte_sequence_wrapper.byte_sequence)error=
(if not (Nat_big_num.equal (Byte_sequence_wrapper.big_num_length ts) ts_length) then fail "takebytes_with_length: invalid length"
else Byte_sequence_wrapper.big_num_takebytes count ts)