Skip to content

Commit e1b3d76

Browse files
committed
Compiler: move some aliases to the runtime
1 parent 953b91e commit e1b3d76

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

compiler/lib/generate.ml

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,15 +2217,9 @@ let f
22172217
let init () =
22182218
List.iter
22192219
~f:(fun (nm, nm') -> Primitive.alias nm nm')
2220-
[ "%int_mul", "caml_mul"
2221-
; "%int_div", "caml_div"
2222-
; "%int_mod", "caml_mod"
2223-
; "caml_int32_neg", "%int_neg"
2220+
[ "caml_int32_neg", "%int_neg"
22242221
; "caml_int32_add", "%int_add"
22252222
; "caml_int32_sub", "%int_sub"
2226-
; "caml_int32_mul", "%int_mul"
2227-
; "caml_int32_div", "%int_div"
2228-
; "caml_int32_mod", "%int_mod"
22292223
; "caml_int32_and", "%int_and"
22302224
; "caml_int32_or", "%int_or"
22312225
; "caml_int32_xor", "%int_xor"
@@ -2236,15 +2230,9 @@ let init () =
22362230
; "caml_int32_to_int", "%identity"
22372231
; "caml_int32_of_float", "caml_int_of_float"
22382232
; "caml_int32_to_float", "%identity"
2239-
; "caml_int32_format", "caml_format_int"
2240-
; "caml_int32_of_string", "caml_int_of_string"
2241-
; "caml_int32_compare", "caml_int_compare"
22422233
; "caml_nativeint_neg", "%int_neg"
22432234
; "caml_nativeint_add", "%int_add"
22442235
; "caml_nativeint_sub", "%int_sub"
2245-
; "caml_nativeint_mul", "%int_mul"
2246-
; "caml_nativeint_div", "%int_div"
2247-
; "caml_nativeint_mod", "%int_mod"
22482236
; "caml_nativeint_and", "%int_and"
22492237
; "caml_nativeint_or", "%int_or"
22502238
; "caml_nativeint_xor", "%int_xor"
@@ -2257,28 +2245,12 @@ let init () =
22572245
; "caml_nativeint_to_float", "%identity"
22582246
; "caml_nativeint_of_int32", "%identity"
22592247
; "caml_nativeint_to_int32", "%identity"
2260-
; "caml_nativeint_format", "caml_format_int"
2261-
; "caml_nativeint_of_string", "caml_int_of_string"
2262-
; "caml_nativeint_compare", "caml_int_compare"
2263-
; "caml_nativeint_bswap", "caml_int32_bswap"
2264-
; "caml_int64_of_int", "caml_int64_of_int32"
2265-
; "caml_int64_to_int", "caml_int64_to_int32"
2266-
; "caml_int64_of_nativeint", "caml_int64_of_int32"
2267-
; "caml_int64_to_nativeint", "caml_int64_to_int32"
22682248
; "caml_float_of_int", "%identity"
2269-
; "caml_array_get_float", "caml_array_get"
2270-
; "caml_floatarray_get", "caml_array_get"
2271-
; "caml_array_get_addr", "caml_array_get"
2272-
; "caml_array_set_float", "caml_array_set"
2273-
; "caml_floatarray_set", "caml_array_set"
2274-
; "caml_array_set_addr", "caml_array_set"
22752249
; "caml_array_unsafe_get_float", "caml_array_unsafe_get"
22762250
; "caml_floatarray_unsafe_get", "caml_array_unsafe_get"
22772251
; "caml_array_unsafe_set_float", "caml_array_unsafe_set"
22782252
; "caml_array_unsafe_set_addr", "caml_array_unsafe_set"
22792253
; "caml_floatarray_unsafe_set", "caml_array_unsafe_set"
2280-
; "caml_check_bound_gen", "caml_check_bound"
2281-
; "caml_check_bound_float", "caml_check_bound"
22822254
; "caml_alloc_dummy_float", "caml_alloc_dummy"
22832255
; "caml_js_from_float", "%identity"
22842256
; "caml_js_to_float", "%identity"

runtime/js/array.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ function caml_uniform_array_blit(a1, i1, a2, i2, len) {
106106
///////////// Pervasive
107107
//Provides: caml_array_set (mutable, const, mutable)
108108
//Requires: caml_array_bound_error
109+
//Alias: caml_array_set_float
110+
//Alias: caml_floatarray_set
111+
//Alias: caml_array_set_addr
109112
function caml_array_set(array, index, newval) {
110113
if (index < 0 || index >= array.length - 1) caml_array_bound_error();
111114
array[index + 1] = newval;
@@ -114,6 +117,9 @@ function caml_array_set(array, index, newval) {
114117

115118
//Provides: caml_array_get mutable (mutable, const)
116119
//Requires: caml_array_bound_error
120+
//Alias: caml_array_get_float
121+
//Alias: caml_floatarray_get
122+
//Alias: caml_array_get_addr
117123
function caml_array_get(array, index) {
118124
if (index < 0 || index >= array.length - 1) caml_array_bound_error();
119125
return array[index + 1];
@@ -150,6 +156,8 @@ function caml_uniform_array_fill(array, ofs, len, v) {
150156

151157
//Provides: caml_check_bound (mutable, const)
152158
//Requires: caml_array_bound_error
159+
//Alias: caml_check_bound_gen
160+
//Alias: caml_check_bound_float
153161
function caml_check_bound(array, index) {
154162
if (index >>> 0 >= array.length - 1) caml_array_bound_error();
155163
return array;

runtime/js/compare.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ function caml_compare(a, b) {
257257
return caml_compare_val(a, b, true);
258258
}
259259
//Provides: caml_int_compare mutable (const, const)
260+
//Alias: caml_int32_compare
261+
//Alias: caml_nativeint_compare
260262
function caml_int_compare(a, b) {
261263
if (a < b) return -1;
262264
if (a === b) return 0;

runtime/js/int64.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,15 @@ function caml_int64_mod(x, y) {
339339

340340
//Provides: caml_int64_of_int32 const
341341
//Requires: MlInt64
342+
//Alias: caml_int64_of_int
343+
//Alias: caml_int64_of_nativeint
342344
function caml_int64_of_int32(x) {
343345
return new MlInt64(x & 0xffffff, (x >> 24) & 0xffffff, (x >> 31) & 0xffff);
344346
}
345347

346348
//Provides: caml_int64_to_int32 const
349+
//Alias: caml_int64_to_int
350+
//Alias: caml_int64_to_nativeint
347351
function caml_int64_to_int32(x) {
348352
return x.toInt();
349353
}

runtime/js/ints.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
//Provides: caml_format_int const (const, const)
1919
//Requires: caml_parse_format, caml_finish_formatting, caml_str_repeat
2020
//Requires: caml_string_of_jsbytes, caml_jsbytes_of_string
21+
//Alias: caml_int32_format
22+
//Alias: caml_nativeint_format
2123
function caml_format_int(fmt, i) {
2224
if (caml_jsbytes_of_string(fmt) === "%d")
2325
return caml_string_of_jsbytes("" + i);
@@ -97,6 +99,8 @@ function caml_parse_digit(c) {
9799
//Provides: caml_int_of_string (const)
98100
//Requires: caml_ml_string_length, caml_string_unsafe_get
99101
//Requires: caml_parse_sign_and_base, caml_parse_digit, caml_failwith
102+
//Alias: caml_int32_of_string
103+
//Alias: caml_nativeint_of_string
100104
function caml_int_of_string(s) {
101105
var r = caml_parse_sign_and_base(s);
102106
var i = r[0],
@@ -129,19 +133,28 @@ function caml_int_of_string(s) {
129133
}
130134

131135
//Provides: caml_mul const
136+
//Alias: caml_int32_mul
137+
//Alias: caml_nativeint_mul
138+
//Alias: %int_mul
132139
function caml_mul(a, b) {
133140
return Math.imul(a, b);
134141
}
135142

136143
//Provides: caml_div
137144
//Requires: caml_raise_zero_divide
145+
//Alias: caml_int32_div
146+
//Alias: caml_nativeint_div
147+
//Alias: %int_div
138148
function caml_div(x, y) {
139149
if (y === 0) caml_raise_zero_divide();
140150
return (x / y) | 0;
141151
}
142152

143153
//Provides: caml_mod
144154
//Requires: caml_raise_zero_divide
155+
//Alias: caml_int32_mod
156+
//Alias: caml_nativeint_mod
157+
//Alias: %int_mod
145158
function caml_mod(x, y) {
146159
if (y === 0) caml_raise_zero_divide();
147160
return x % y;
@@ -152,6 +165,7 @@ function caml_bswap16(x) {
152165
return ((x & 0x00ff) << 8) | ((x & 0xff00) >> 8);
153166
}
154167
//Provides: caml_int32_bswap
168+
//Alias: caml_nativeint_bswap
155169
function caml_int32_bswap(x) {
156170
return (
157171
((x & 0x000000ff) << 24) |

0 commit comments

Comments
 (0)