|
69 | 69 | (import "bindings" "ta_subarray" |
70 | 70 | (func $ta_subarray |
71 | 71 | (param (ref extern)) (param i32) (param i32) (result (ref extern)))) |
72 | | - (import "bindings" "ta_blit_from_string" |
73 | | - (func $ta_blit_from_string |
74 | | - (param (ref $string)) (param i32) (param (ref extern)) (param i32) |
| 72 | + (import "bindings" "ta_blit_from_bytes" |
| 73 | + (func $ta_blit_from_bytes |
| 74 | + (param (ref $bytes)) (param i32) (param (ref extern)) (param i32) |
75 | 75 | (param i32))) |
76 | | - (import "bindings" "ta_blit_to_string" |
77 | | - (func $ta_blit_to_string |
78 | | - (param (ref extern)) (param i32) (param (ref $string)) (param i32) |
| 76 | + (import "bindings" "ta_blit_to_bytes" |
| 77 | + (func $ta_blit_to_bytes |
| 78 | + (param (ref extern)) (param i32) (param (ref $bytes)) (param i32) |
79 | 79 | (param i32))) |
80 | 80 | (import "fail" "caml_bound_error" (func $caml_bound_error)) |
81 | 81 | (import "fail" "caml_raise_out_of_memory" (func $caml_raise_out_of_memory)) |
|
128 | 128 | (func $caml_deserialize_int_8 (param (ref eq)) (result i64))) |
129 | 129 |
|
130 | 130 | (type $block (array (mut (ref eq)))) |
131 | | - (type $string (array (mut i8))) |
| 131 | + (type $bytes (array (mut i8))) |
132 | 132 | (type $float (struct (field f64))) |
133 | 133 | (type $float_array (array (mut f64))) |
134 | 134 |
|
|
143 | 143 | (type $dup (func (param (ref eq)) (result (ref eq)))) |
144 | 144 | (type $custom_operations |
145 | 145 | (struct |
146 | | - (field $id (ref $string)) |
| 146 | + (field $id (ref $bytes)) |
147 | 147 | (field $compare (ref null $compare)) |
148 | 148 | (field $compare_ext (ref null $compare)) |
149 | 149 | (field $hash (ref null $hash)) |
|
155 | 155 |
|
156 | 156 | (global $bigarray_ops (export "bigarray_ops") (ref $custom_operations) |
157 | 157 | (struct.new $custom_operations |
158 | | - (array.new_fixed $string 9 ;; "_bigarr02" |
| 158 | + (array.new_fixed $bytes 9 ;; "_bigarr02" |
159 | 159 | (i32.const 95) (i32.const 98) (i32.const 105) (i32.const 103) |
160 | 160 | (i32.const 97) (i32.const 114) (i32.const 114) (i32.const 48) |
161 | 161 | (i32.const 50)) |
|
682 | 682 | (if (call $caml_deserialize_uint_1 (local.get $s)) |
683 | 683 | (then |
684 | 684 | (call $caml_failwith |
685 | | - (array.new_data $string $intern_overflow |
| 685 | + (array.new_data $bytes $intern_overflow |
686 | 686 | (i32.const 0) (i32.const 56)))))) |
687 | 687 | ;; int32 |
688 | 688 | (loop $loop |
|
807 | 807 | (if (i32.gt_u (local.get $num_dims) (global.get $CAML_BA_MAX_NUM_DIMS)) |
808 | 808 | (then |
809 | 809 | (call $caml_invalid_argument |
810 | | - (array.new_data $string $ba_create_bad_dims |
| 810 | + (array.new_data $bytes $ba_create_bad_dims |
811 | 811 | (i32.const 0) (i32.const 41))))) |
812 | 812 | (local.set $dim |
813 | 813 | (array.new $int_array (i32.const 0) (local.get $num_dims))) |
|
823 | 823 | (if (i32.lt_s (local.get $n) (i32.const 0)) |
824 | 824 | (then |
825 | 825 | (call $caml_invalid_argument |
826 | | - (array.new_data $string $ba_create_negative_dim |
| 826 | + (array.new_data $bytes $ba_create_negative_dim |
827 | 827 | (i32.const 0) (i32.const 35))))) |
828 | 828 | (array.set $int_array |
829 | 829 | (local.get $dim) (local.get $i) (local.get $n)) |
|
852 | 852 | (if (i32.lt_s (local.get $kind) (i32.const 0)) |
853 | 853 | (then |
854 | 854 | (call $caml_invalid_argument |
855 | | - (array.new_data $string $ta_unsupported_kind |
| 855 | + (array.new_data $bytes $ta_unsupported_kind |
856 | 856 | (i32.const 0) (i32.const 41))))) |
857 | 857 | (if (i32.eq (local.get $kind) (i32.const 14)) ;; Uint8ClampedArray |
858 | 858 | (then (local.set $kind (i32.const 3)))) |
859 | 859 | (local.set $len (call $ta_length (local.get $data))) |
860 | 860 | (if (i32.lt_s (local.get $len) (i32.const 0)) |
861 | 861 | (then |
862 | 862 | (call $caml_invalid_argument |
863 | | - (array.new_data $string $ta_too_large |
| 863 | + (array.new_data $bytes $ta_too_large |
864 | 864 | (i32.const 0) (i32.const 34))))) |
865 | 865 | (struct.new $bigarray |
866 | 866 | (global.get $bigarray_ops) |
|
1062 | 1062 | (local.set $i (i31.get_s (ref.cast (ref i31) (local.get 1)))) |
1063 | 1063 | (if (i32.ge_u (local.get $i) (array.len (local.get $dim))) |
1064 | 1064 | (then (call $caml_invalid_argument |
1065 | | - (array.new_data $string $Bigarray_dim |
| 1065 | + (array.new_data $bytes $Bigarray_dim |
1066 | 1066 | (i32.const 0) (i32.const 12))))) |
1067 | 1067 | (ref.i31 (array.get $int_array (local.get $dim) (local.get $i)))) |
1068 | 1068 |
|
|
1427 | 1427 | (struct.get $bigarray $ba_num_dims (local.get $b))) |
1428 | 1428 | (then |
1429 | 1429 | (call $caml_invalid_argument |
1430 | | - (array.new_data $string $too_many_indices |
| 1430 | + (array.new_data $bytes $too_many_indices |
1431 | 1431 | (i32.const 0) (i32.const 32))))) |
1432 | 1432 | (local.set $sub_dim |
1433 | 1433 | (array.new $int_array (i32.const 0) |
|
1544 | 1544 | (local.get $changed_dim)))) |
1545 | 1545 | (then |
1546 | 1546 | (call $caml_invalid_argument |
1547 | | - (array.new_data $string $bad_subarray |
| 1547 | + (array.new_data $bytes $bad_subarray |
1548 | 1548 | (i32.const 0) (i32.const 27))))) |
1549 | 1549 | (local.set $new_dim |
1550 | 1550 | (array.new $int_array (i32.const 0) (local.get $num_dims))) |
|
1674 | 1674 | (struct.get $bigarray $ba_num_dims (local.get $src))) |
1675 | 1675 | (then |
1676 | 1676 | (call $caml_invalid_argument |
1677 | | - (array.new_data $string $dim_mismatch |
| 1677 | + (array.new_data $bytes $dim_mismatch |
1678 | 1678 | (i32.const 0) (i32.const 33))))) |
1679 | 1679 | (local.set $sdim (struct.get $bigarray $ba_dim (local.get $src))) |
1680 | 1680 | (local.set $ddim (struct.get $bigarray $ba_dim (local.get $dst))) |
|
1686 | 1686 | (array.get $int_array (local.get $ddim) (local.get $i))) |
1687 | 1687 | (then |
1688 | 1688 | (call $caml_invalid_argument |
1689 | | - (array.new_data $string $dim_mismatch |
| 1689 | + (array.new_data $bytes $dim_mismatch |
1690 | 1690 | (i32.const 0) (i32.const 33))))) |
1691 | 1691 | (local.set $i (i32.add (local.get $i) (i32.const 1))) |
1692 | 1692 | (br $loop)))) |
|
1711 | 1711 | (if (i32.gt_u (local.get $num_dims) (global.get $CAML_BA_MAX_NUM_DIMS)) |
1712 | 1712 | (then |
1713 | 1713 | (call $caml_invalid_argument |
1714 | | - (array.new_data $string $bad_number_dim |
| 1714 | + (array.new_data $bytes $bad_number_dim |
1715 | 1715 | (i32.const 0) (i32.const 42))))) |
1716 | 1716 | (local.set $num_elts (i64.const 1)) |
1717 | 1717 | (local.set $dim (array.new $int_array (i32.const 0) (local.get $num_dims))) |
|
1726 | 1726 | (if (i32.lt_s (local.get $d) (i32.const 0)) |
1727 | 1727 | (then |
1728 | 1728 | (call $caml_invalid_argument |
1729 | | - (array.new_data $string $negative_dim |
| 1729 | + (array.new_data $bytes $negative_dim |
1730 | 1730 | (i32.const 0) (i32.const 36))))) |
1731 | 1731 | (array.set $int_array (local.get $dim) (local.get $i) |
1732 | 1732 | (local.get $d)) |
|
1743 | 1743 | (struct.get $bigarray $ba_dim (local.get $b)))) |
1744 | 1744 | (then |
1745 | 1745 | (call $caml_invalid_argument |
1746 | | - (array.new_data $string $size_mismatch |
| 1746 | + (array.new_data $bytes $size_mismatch |
1747 | 1747 | (i32.const 0) (i32.const 31))))) |
1748 | 1748 | (struct.new $bigarray |
1749 | 1749 | (global.get $bigarray_ops) |
|
2163 | 2163 | (param (ref eq)) (result (ref eq)) |
2164 | 2164 | ;; used to convert a typed array to a string |
2165 | 2165 | (local $a (ref extern)) (local $len i32) |
2166 | | - (local $s (ref $string)) |
| 2166 | + (local $s (ref $bytes)) |
2167 | 2167 | (local.set $a |
2168 | 2168 | (ref.as_non_null (extern.convert_any (call $unwrap (local.get 0))))) |
2169 | 2169 | (local.set $len (call $ta_length (local.get $a))) |
2170 | | - (local.set $s (array.new $string (i32.const 0) (local.get $len))) |
2171 | | - (call $ta_blit_to_string |
| 2170 | + (local.set $s (array.new $bytes (i32.const 0) (local.get $len))) |
| 2171 | + (call $ta_blit_to_bytes |
2172 | 2172 | (local.get $a) (i32.const 0) (local.get $s) (i32.const 0) |
2173 | 2173 | (local.get $len)) |
2174 | 2174 | (local.get $s)) |
2175 | 2175 |
|
2176 | 2176 | (export "caml_uint8_array_of_bytes" (func $caml_uint8_array_of_string)) |
2177 | 2177 | (func $caml_uint8_array_of_string (export "caml_uint8_array_of_string") |
2178 | 2178 | (param (ref eq)) (result (ref eq)) |
2179 | | - ;; Convert a string to a typed array |
| 2179 | + ;; Convert bytes to a typed array |
2180 | 2180 | (local $ta (ref extern)) (local $len i32) |
2181 | | - (local $s (ref $string)) |
2182 | | - (local.set $s (ref.cast (ref $string) (local.get 0))) |
| 2181 | + (local $s (ref $bytes)) |
| 2182 | + (local.set $s (ref.cast (ref $bytes) (local.get 0))) |
2183 | 2183 | (local.set $len (array.len (local.get $s))) |
2184 | 2184 | (local.set $ta |
2185 | 2185 | (call $ta_create |
2186 | 2186 | (i32.const 3) ;; Uint8Array |
2187 | 2187 | (local.get $len))) |
2188 | | - (call $ta_blit_from_string |
| 2188 | + (call $ta_blit_from_bytes |
2189 | 2189 | (local.get $s) (i32.const 0) (local.get $ta) (i32.const 0) |
2190 | 2190 | (local.get $len)) |
2191 | 2191 | (call $wrap (any.convert_extern (local.get $ta)))) |
|
2219 | 2219 | (local.get $kind) |
2220 | 2220 | (local.get $layout))) |
2221 | 2221 |
|
2222 | | - (func (export "string_set") |
| 2222 | + (func (export "bytes_set") |
2223 | 2223 | (param $s externref) (param $i i32) (param $v i32) |
2224 | | - (array.set $string |
2225 | | - (ref.cast (ref null $string) (any.convert_extern (local.get $s))) |
| 2224 | + (array.set $bytes |
| 2225 | + (ref.cast (ref null $bytes) (any.convert_extern (local.get $s))) |
2226 | 2226 | (local.get $i) (local.get $v))) |
2227 | 2227 |
|
2228 | | - (func (export "string_get") |
| 2228 | + (func (export "bytes_get") |
2229 | 2229 | (param $s externref) (param $i i32) (result i32) |
2230 | | - (array.get $string |
2231 | | - (ref.cast (ref null $string) (any.convert_extern (local.get $s))) |
| 2230 | + (array.get $bytes |
| 2231 | + (ref.cast (ref null $bytes) (any.convert_extern (local.get $s))) |
2232 | 2232 | (local.get $i))) |
2233 | 2233 | ) |
0 commit comments