Skip to content

Commit

Permalink
Merge d1cdc16 into 5a37b34
Browse files Browse the repository at this point in the history
  • Loading branch information
bobzhang committed Mar 9, 2018
2 parents 5a37b34 + d1cdc16 commit 4f33e38
Show file tree
Hide file tree
Showing 133 changed files with 731 additions and 728 deletions.
4 changes: 2 additions & 2 deletions jscomp/all.depend
Expand Up @@ -675,8 +675,8 @@ core/lam_compile_main.cmx : ext/literals.cmx core/lam_util.cmx \
core/js_exp_make.cmx core/js_dump_program.cmx common/js_config.cmx \
core/js_cmj_format.cmx core/j.cmx ext/ident_set.cmx ext/ext_string.cmx \
ext/ext_pervasives.cmx ext/ext_path.cmx ext/ext_namespace.cmx \
common/ext_log.cmx ext/ext_list.cmx ext/ext_ident.cmx \
ext/ext_filename.cmx ext/ext_char.cmx core/lam_compile_main.cmi
common/ext_log.cmx ext/ext_list.cmx ext/ext_filename.cmx ext/ext_char.cmx \
core/lam_compile_main.cmi
core/js_implementation.cmx : core/ocaml_parse.cmx ext/literals.cmx \
core/lam_compile_main.cmx core/lam_compile_env.cmx common/js_config.cmx \
ext/ext_string.cmx ext/ext_pervasives.cmx ext/ext_namespace.cmx \
Expand Down
4 changes: 2 additions & 2 deletions jscomp/core/lam_compile_main.ml
Expand Up @@ -71,12 +71,12 @@ let compile_group ({filename = file_name; env;} as meta : Lam_stats.t)
Note the arity of [print_endline] is already analyzed before,
so it should be safe
*)
| Single(_, ({name="string_of_int";_} as id),_ ), "pervasives.ml" ->
(* | Single(_, ({name="string_of_int";_} as id),_ ), "pervasives.ml" ->
Js_output.of_stmt @@ S.alias_variable id
~exp:(
let arg = Ext_ident.create "param" in
E.ocaml_fun [arg] [S.return_stmt (E.int_to_string (E.var arg))]
)
) *)

(** Special handling for values in [Sys] *)
| Single(_, ({name="max_array_length" | "max_string_length";_} as id) ,_ ), "sys.ml" ->
Expand Down
5 changes: 4 additions & 1 deletion jscomp/stdlib/pervasives.ml
Expand Up @@ -244,9 +244,12 @@ let bool_of_string = function
| "false" -> false
| _ -> invalid_arg "bool_of_string"

#if BS then
external string_of_int : int -> string = "String" [@@bs.val]
#else
let string_of_int n =
format_int "%d" n

#end
external int_of_string : string -> int = "caml_int_of_string"
external string_get : string -> int -> char = "%string_safe_get"

Expand Down
5 changes: 4 additions & 1 deletion jscomp/stdlib/pervasives.mli
Expand Up @@ -568,9 +568,12 @@ val bool_of_string : string -> bool
Raise [Invalid_argument "bool_of_string"] if the string is not
["true"] or ["false"]. *)

#if BS then
external string_of_int : int -> string = "String" [@@bs.val]
#else
val string_of_int : int -> string
(** Return the string representation of an integer, in decimal. *)

#end
external int_of_string : string -> int = "caml_int_of_string"
(** Convert the given string to an integer.
The string is read in decimal (by default) or in hexadecimal (if it
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/a_filename_test.js
Expand Up @@ -13,7 +13,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/a_scope_bug.js
Expand Up @@ -7,7 +7,7 @@ function odd(_z) {
var z = _z;
var even = Caml_int32.imul(z, z);
var a = (even + 4 | 0) + even | 0;
console.log("" + a);
console.log(String(a));
_z = 32;
continue ;

Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/arity_deopt.js
Expand Up @@ -12,7 +12,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/array_subtle_test.js
Expand Up @@ -15,7 +15,7 @@ function eq(loc, param) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/ast_abstract_test.js
Expand Up @@ -12,7 +12,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/ast_js_mapper_poly_test.js
Expand Up @@ -13,7 +13,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/ast_mapper_defensive_test.js
Expand Up @@ -12,7 +12,7 @@ function $$throw(loc, x) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* ThrowAny */Block.__(7, [x]);
})
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/bs_array_test.js
Expand Up @@ -32,7 +32,7 @@ function neq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Neq */Block.__(1, [
x,
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/bs_auto_uncurry_test.js
Expand Up @@ -11,7 +11,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down
18 changes: 9 additions & 9 deletions jscomp/test/bs_hashtbl_string_test.js
Expand Up @@ -70,10 +70,10 @@ function bench() {
function bench2(m) {
var empty = Belt_HashMap.make(1000000, m);
for(var i = 0; i <= 1000000; ++i){
Belt_HashMap.set(empty, "" + i, i);
Belt_HashMap.set(empty, String(i), i);
}
for(var i$1 = 0; i$1 <= 1000000; ++i$1){
if (!Belt_HashMap.has(empty, "" + i$1)) {
if (!Belt_HashMap.has(empty, String(i$1))) {
throw [
Caml_builtin_exceptions.assert_failure,
[
Expand All @@ -86,7 +86,7 @@ function bench2(m) {

}
for(var i$2 = 0; i$2 <= 1000000; ++i$2){
Belt_HashMap.remove(empty, "" + i$2);
Belt_HashMap.remove(empty, String(i$2));
}
if (empty.size === 0) {
return 0;
Expand All @@ -110,10 +110,10 @@ function bench3(m) {
var cmp = m[/* cmp */0];
var table = empty.data;
for(var i = 0; i <= 1000000; ++i){
table = Belt_MapDict.set(table, "" + i, i, cmp);
table = Belt_MapDict.set(table, String(i), i, cmp);
}
for(var i$1 = 0; i$1 <= 1000000; ++i$1){
if (!Belt_MapDict.has(table, "" + i$1, cmp)) {
if (!Belt_MapDict.has(table, String(i$1), cmp)) {
throw [
Caml_builtin_exceptions.assert_failure,
[
Expand All @@ -126,7 +126,7 @@ function bench3(m) {

}
for(var i$2 = 0; i$2 <= 1000000; ++i$2){
table = Belt_MapDict.remove(table, "" + i$2, cmp);
table = Belt_MapDict.remove(table, String(i$2), cmp);
}
if (Belt_MapDict.size(table) === 0) {
return 0;
Expand All @@ -147,10 +147,10 @@ var Sx = Belt_Id.comparable(Caml_primitive.caml_string_compare);
function bench4() {
var table = Belt_internalBucketsType.make(/* () */0, /* () */0, 1000000);
for(var i = 0; i <= 1000000; ++i){
Belt_HashMapString.set(table, "" + i, i);
Belt_HashMapString.set(table, String(i), i);
}
for(var i$1 = 0; i$1 <= 1000000; ++i$1){
if (!Belt_HashMapString.has(table, "" + i$1)) {
if (!Belt_HashMapString.has(table, String(i$1))) {
throw [
Caml_builtin_exceptions.assert_failure,
[
Expand All @@ -163,7 +163,7 @@ function bench4() {

}
for(var i$2 = 0; i$2 <= 1000000; ++i$2){
Belt_HashMapString.remove(table, "" + i$2);
Belt_HashMapString.remove(table, String(i$2));
}
if (Belt_HashMapString.isEmpty(table)) {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/bs_ignore_effect.js
Expand Up @@ -11,7 +11,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down
4 changes: 2 additions & 2 deletions jscomp/test/bs_list_test.js
Expand Up @@ -1665,7 +1665,7 @@ eq("File \"bs_list_test.ml\", line 259, characters 5-12", Belt_List.has(/* :: */
]
]
], "2", (function (x, s) {
return +("" + x === s);
return +(String(x) === s);
})), /* true */1);

eq("File \"bs_list_test.ml\", line 260, characters 5-12", Belt_List.has(/* :: */[
Expand All @@ -1678,7 +1678,7 @@ eq("File \"bs_list_test.ml\", line 260, characters 5-12", Belt_List.has(/* :: */
]
]
], "0", (function (x, s) {
return +("" + x === s);
return +(String(x) === s);
})), /* false */0);

b("File \"bs_list_test.ml\", line 262, characters 4-11", +(Belt_List.reduceReverse(/* :: */[
Expand Down
4 changes: 2 additions & 2 deletions jscomp/test/bs_map_test.js
Expand Up @@ -14,7 +14,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand All @@ -31,7 +31,7 @@ function b(loc, v) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Ok */Block.__(4, [v]);
})
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/bs_string_test.js
Expand Up @@ -11,7 +11,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/buffer_test.js
Expand Up @@ -48,7 +48,7 @@ var suites_001 = /* :: */[
(function () {
var v = Buffer.create(30);
for(var i = 0; i <= 10; ++i){
Buffer.add_string(v, "" + i);
Buffer.add_string(v, String(i));
}
return /* Eq */Block.__(0, [
Buffer.contents(v),
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/bytes_split_gpr_743_test.js
Expand Up @@ -15,7 +15,7 @@ function eq(loc, param) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/caml_sys_poly_fill_test.js
Expand Up @@ -13,7 +13,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/chain_code_test.js
Expand Up @@ -11,7 +11,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/chn_test.js
Expand Up @@ -14,7 +14,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/class3_test.js
Expand Up @@ -69,7 +69,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/class4_test.js
Expand Up @@ -26,7 +26,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down
6 changes: 3 additions & 3 deletions jscomp/test/class5_test.js
Expand Up @@ -28,7 +28,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down Expand Up @@ -63,7 +63,7 @@ function printable_point_init($$class) {
}),
print,
(function (self$1) {
return "" + Curry._1(self$1[0][get_x], self$1);
return String(Curry._1(self$1[0][get_x], self$1));
})
]);
return (function (_, self, x_init) {
Expand Down Expand Up @@ -240,7 +240,7 @@ eq("File \"class5_test.ml\", line 67, characters 5-12", /* tuple */[
return x + y | 0;
}), 0),
Caml_oo_curry.js3(-1010803711, 6, l$1, (function (s, x) {
return s + (x + " ");
return s + (String(x) + " ");
}), "")
]);

Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/class6_test.js
Expand Up @@ -26,7 +26,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/class7_test.js
Expand Up @@ -40,7 +40,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/class_fib_open_recursion_test.js
Expand Up @@ -18,7 +18,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/complex_while_loop.js
Expand Up @@ -13,7 +13,7 @@ function f() {
};
return +(fib(n) > 10);
})()) {
console.log("" + n);
console.log(String(n));
n = n + 1 | 0;
};
return /* () */0;
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/condition_compilation_test.js
Expand Up @@ -17,7 +17,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/div_by_zero_test.js
Expand Up @@ -13,7 +13,7 @@ function eq(loc, x, y) {
test_id[0] = test_id[0] + 1 | 0;
suites[0] = /* :: */[
/* tuple */[
loc + (" id " + test_id[0]),
loc + (" id " + String(test_id[0])),
(function () {
return /* Eq */Block.__(0, [
x,
Expand Down

0 comments on commit 4f33e38

Please sign in to comment.