@@ -1415,19 +1415,30 @@ module Bigarray = struct
1415
1415
| Int -> " dv_get_i32" , I32 , 2 , Fun. id
1416
1416
| Complex32 | Complex64 | Float16 -> assert false (* ZZZ*)
1417
1417
in
1418
+ let * little_endian =
1419
+ register_import
1420
+ ~import_module: " bindings"
1421
+ ~name: " littleEndian"
1422
+ (Global { mut = false ; typ = I32 })
1423
+ in
1418
1424
let * f =
1419
1425
register_import
1420
1426
~import_module: " bindings"
1421
1427
~name
1422
1428
(Fun
1423
- { W. params = [ Ref { nullable = false ; typ = Extern }; I32 ]
1429
+ { W. params =
1430
+ Ref { nullable = true ; typ = Extern }
1431
+ :: I32
1432
+ :: (if size = 0 then [] else [ I32 ])
1424
1433
; result = [ typ ]
1425
1434
})
1426
1435
in
1427
1436
let * ty = Type. bigarray_type in
1428
1437
let * ta = Memory. wasm_struct_get ty (Memory. wasm_cast ty a) 2 in
1429
1438
let * ofs = Arith. (i lsl const (Int32. of_int size)) in
1430
- box (return (W. Call (f, [ ta; ofs ])))
1439
+ box
1440
+ (return
1441
+ (W. Call (f, ta :: ofs :: (if size = 0 then [] else [ W. GlobalGet little_endian ]))))
1431
1442
1432
1443
let set ~kind a i v =
1433
1444
let name, (typ : Wasm_ast.value_type ), size, unbox =
@@ -1452,16 +1463,28 @@ module Bigarray = struct
1452
1463
let * ta = Memory. wasm_struct_get ty (Memory. wasm_cast ty a) 2 in
1453
1464
let * ofs = Arith. (i lsl const (Int32. of_int size)) in
1454
1465
let * v = unbox v in
1466
+ let * little_endian =
1467
+ register_import
1468
+ ~import_module: " bindings"
1469
+ ~name: " littleEndian"
1470
+ (Global { mut = false ; typ = I32 })
1471
+ in
1455
1472
let * f =
1456
1473
register_import
1457
1474
~import_module: " bindings"
1458
1475
~name
1459
1476
(Fun
1460
- { W. params = [ Ref { nullable = false ; typ = Extern }; I32 ; typ ]
1477
+ { W. params =
1478
+ Ref { nullable = true ; typ = Extern }
1479
+ :: I32
1480
+ :: typ
1481
+ :: (if size = 0 then [] else [ I32 ])
1461
1482
; result = []
1462
1483
})
1463
1484
in
1464
- instr (W. CallInstr (f, [ ta; ofs; v ]))
1485
+ instr
1486
+ (W. CallInstr
1487
+ (f, ta :: ofs :: v :: (if size = 0 then [] else [ W. GlobalGet little_endian ])))
1465
1488
end
1466
1489
1467
1490
module JavaScript = struct
0 commit comments