Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Commit 7440719

Browse files
committed
Change to_bits to return string
1 parent cac3342 commit 7440719

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

interpreter/binary/encode.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ let encode m =
6262
let vs32 i = vs64 (Int64.of_int32 i)
6363
let f32 x = u32 (F32.to_bits x)
6464
let f64 x = u64 (F64.to_bits x)
65+
let v128 v = String.iter (put s) (V128.to_bits v)
6566

6667
let len i =
6768
if Int32.to_int (Int32.of_int i) <> i then
@@ -225,7 +226,7 @@ let encode m =
225226
| Const {it = I64 c; _} -> op 0x42; vs64 c
226227
| Const {it = F32 c; _} -> op 0x43; f32 c
227228
| Const {it = F64 c; _} -> op 0x44; f64 c
228-
| Const {it = V128 c; _} -> simd_op 0x02; Bytes.iter (put s) (V128.to_bits c)
229+
| Const {it = V128 c; _} -> simd_op 0x02; v128 c
229230

230231
| Test (I32 I32Op.Eqz) -> op 0x45
231232
| Test (I64 I64Op.Eqz) -> op 0x50

interpreter/exec/simd.ml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ sig
2020
val to_string : t -> string
2121
val bytewidth : int
2222
val of_strings : shape -> string list -> t
23+
val of_bits : string -> t
24+
val to_bits : t -> string
2325
end
2426

2527
module type S =
@@ -33,14 +35,14 @@ sig
3335
val of_strings : shape -> string list -> t
3436
end
3537

36-
module Make (Rep : RepType) : S with type bits = Rep.t =
38+
module Make (Rep : RepType) : S with type bits = string =
3739
struct
3840
type t = Rep.t
39-
type bits = Rep.t
41+
type bits = string
4042

4143
let default = Rep.make Rep.bytewidth (chr 0)
4244
let to_string = Rep.to_string (* FIXME very very wrong *)
43-
let to_bits x = x
44-
let of_bits x = x
45+
let of_bits = Rep.of_bits
46+
let to_bits = Rep.to_bits
4547
let of_strings = Rep.of_strings
4648
end

interpreter/exec/v128.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ include Simd.Make
22
(struct
33
include Bytes
44
let bytewidth = 16
5+
let of_bits = Bytes.of_string
6+
let to_bits = Bytes.to_string
57

68
let of_strings shape ss =
79
if List.length ss <> Simd.lanes shape then raise (Invalid_argument "wrong length");

0 commit comments

Comments
 (0)