Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better handling M.q #224

Merged
merged 1 commit into from
Apr 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jscomp/lam_pass_lets_dce.ml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ let lets_helper (count_var : Ident.t -> used_info) lam =
| _, (Lconst (Const_base (
Const_int _ | Const_char _ | Const_float _ | Const_int32 _
| Const_nativeint _ ))
(* | Lprim (Lambda.Pfield (_), [Lprim (Lambda.Pgetglobal _, _)] ) *)
| Lprim (Lambda.Pfield (_), [Lprim (Lambda.Pgetglobal _, _)] )
)
(* Const_int64 is no longer primitive
Note for some constant which is not
Expand Down
8 changes: 4 additions & 4 deletions jscomp/runtime/caml_format.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ var Caml_builtin_exceptions = require("./caml_builtin_exceptions");
var Caml_utils = require("./caml_utils");
var Caml_string = require("./caml_string");

var repeat = Caml_utils.repeat;

function caml_failwith(s) {
throw [
Caml_builtin_exceptions.failure,
Expand Down Expand Up @@ -596,7 +594,7 @@ function caml_format_int(fmt, i) {
f$1[/* filter */2] = " ";
var n = f$1[/* prec */9] - s.length;
if (n > 0) {
s = repeat(n, "0") + s;
s = Caml_utils.repeat(n, "0") + s;
}

}
Expand Down Expand Up @@ -714,7 +712,7 @@ function caml_int64_format(fmt, x) {
f[/* filter */2] = " ";
var n = f[/* prec */9] - s.length;
if (n > 0) {
s = repeat(n, "0") + s;
s = Caml_utils.repeat(n, "0") + s;
}

}
Expand Down Expand Up @@ -840,6 +838,8 @@ function (s) {

);

var repeat = Caml_utils.repeat;

var caml_nativeint_format = caml_format_int;

var caml_int32_format = caml_format_int;
Expand Down
9 changes: 6 additions & 3 deletions jscomp/stdlib/arg.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions");
var Caml_obj = require("../runtime/caml_obj");
var Bytes = require("./bytes");
var Pervasives = require("./pervasives");
var Caml_format = require("../runtime/caml_format");
var Sys = require("./sys");
Expand All @@ -11,6 +12,7 @@ var Buffer = require("./buffer");
var Caml_curry = require("../runtime/caml_curry");
var $$String = require("./string");
var List = require("./list");
var Caml_string = require("../runtime/caml_string");

var Bad = {
0: "Arg.Bad",
Expand Down Expand Up @@ -863,7 +865,7 @@ function parse_dynamic(l, f, msg) {
function second_word(s) {
var len = s.length;
try {
var _n = $$String.index(s, /* " " */32);
var _n = Bytes.index(Caml_string.bytes_of_string(s), /* " " */32);
while(true) {
var n = _n;
if (n >= len) {
Expand Down Expand Up @@ -915,7 +917,8 @@ function align($staropt$star, speclist) {
else if (spec.tag === 11) {
var msg = ksd[2];
var cutcol = second_word(msg);
var spaces = $$String.make(Pervasives.max(0, len$2 - cutcol) + 3, /* " " */32);
var n = Pervasives.max(0, len$2 - cutcol) + 3;
var spaces = Caml_string.bytes_to_string(Bytes.make(n, /* " " */32));
return /* tuple */[
kwd,
spec,
Expand All @@ -935,7 +938,7 @@ function align($staropt$star, speclist) {
];
}
else {
var spaces$1 = $$String.make(diff, /* " " */32);
var spaces$1 = Caml_string.bytes_to_string(Bytes.make(diff, /* " " */32));
var prefix = $$String.sub(msg$1, 0, cutcol$1);
var suffix = $$String.sub(msg$1, cutcol$1, msg$1.length - cutcol$1);
return /* tuple */[
Expand Down
4 changes: 2 additions & 2 deletions jscomp/stdlib/camlinternalFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ function string_of_formatting_lit(formatting_lit) {
case 1 :
return formatting_lit[0];
case 2 :
return "@" + $$String.make(1, formatting_lit[0]);
return "@" + Caml_string.bytes_to_string(Bytes.make(1, formatting_lit[0]));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caml_string.bytes_to_string @@ Bytes.make (1, ..)

can be optimized as (String.fromCharCode ...


}
}
Expand Down Expand Up @@ -3697,7 +3697,7 @@ function format_of_aconv(iconv, c) {
break;

}
return $$String.concat($$String.make(1, c), seps);
return $$String.concat(Caml_string.bytes_to_string(Bytes.make(1, c)), seps);
}

function format_of_fconv(fconv, prec) {
Expand Down
10 changes: 6 additions & 4 deletions jscomp/stdlib/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions");
var Caml_obj = require("../runtime/caml_obj");
var Bytes = require("./bytes");
var Caml_io = require("../runtime/caml_io");
var Pervasives = require("./pervasives");
var Buffer = require("./buffer");
var Caml_curry = require("../runtime/caml_curry");
var $$String = require("./string");
var Caml_string = require("../runtime/caml_string");
var CamlinternalFormat = require("./camlinternalFormat");

function add_queue(x, q) {
Expand Down Expand Up @@ -670,7 +672,7 @@ function pp_print_bool(state, b) {
}

function pp_print_char(state, c) {
return pp_print_as(state, 1, $$String.make(1, c));
return pp_print_as(state, 1, Caml_string.bytes_to_string(Bytes.make(1, c)));
}

function pp_open_hbox(state, _) {
Expand Down Expand Up @@ -1017,7 +1019,7 @@ function display_newline(state, _) {
return Caml_curry.app3(state[/* pp_out_string */16], "\n", 0, 1);
}

var blank_line = $$String.make(80, /* " " */32);
var blank_line = Caml_string.bytes_to_string(Bytes.make(80, /* " " */32));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be optimized as " ".repeat(80)


function display_blanks(state, _n) {
while(true) {
Expand Down Expand Up @@ -1593,7 +1595,7 @@ function output_acc(ppf, acc) {
return pp_print_as_size(ppf, size, s);
case 2 :
output_acc(ppf, p$1);
return pp_print_as_size(ppf, size$1, $$String.make(1, c));
return pp_print_as_size(ppf, size$1, Caml_string.bytes_to_string(Bytes.make(1, c)));

}
}
Expand Down Expand Up @@ -1787,7 +1789,7 @@ function strput_acc(ppf, acc) {
return pp_print_as_size(ppf, size, s);
case 2 :
strput_acc(ppf, p$1);
return pp_print_as_size(ppf, size$1, $$String.make(1, c));
return pp_print_as_size(ppf, size$1, Caml_string.bytes_to_string(Bytes.make(1, c)));

}
}
Expand Down
3 changes: 1 addition & 2 deletions jscomp/stdlib/genlex.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ var Hashtbl = require("./hashtbl");
var Stream = require("./stream");
var Caml_format = require("../runtime/caml_format");
var Char = require("./char");
var $$String = require("./string");
var Caml_string = require("../runtime/caml_string");
var List = require("./list");

Expand Down Expand Up @@ -66,7 +65,7 @@ function make_lexer(keywords) {
}
};
var keyword_or_error = function (c) {
var s = $$String.make(1, c);
var s = Caml_string.bytes_to_string(Bytes.make(1, c));
try {
return Hashtbl.find(kwd_table, s);
}
Expand Down
5 changes: 3 additions & 2 deletions jscomp/stdlib/hashtbl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'use strict';

var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions");
var Bytes = require("./bytes");
var Caml_obj = require("../runtime/caml_obj");
var CamlinternalLazy = require("./camlinternalLazy");
var Caml_sys = require("../runtime/caml_sys");
Expand All @@ -10,8 +11,8 @@ var Sys = require("./sys");
var Caml_primitive = require("../runtime/caml_primitive");
var Caml_array = require("../runtime/caml_array");
var $$Array = require("./array");
var $$String = require("./string");
var Caml_curry = require("../runtime/caml_curry");
var Caml_string = require("../runtime/caml_string");
var Random = require("./random");

function hash(x) {
Expand Down Expand Up @@ -50,7 +51,7 @@ catch (exn){
}
}

var randomized_default = $$String.contains(params, /* "R" */82);
var randomized_default = Bytes.contains(Caml_string.bytes_of_string(params), /* "R" */82);

var randomized = [randomized_default];

Expand Down
4 changes: 2 additions & 2 deletions jscomp/stdlib/nativeint.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ function abs(n) {
}
}

var size = Sys.word_size;

var min_int = -9007199254740991;

var max_int = 9007199254740991;
Expand All @@ -46,6 +44,8 @@ var one = 1;

var minus_one = -1;

var size = Sys.word_size;

exports.zero = zero;
exports.one = one;
exports.minus_one = minus_one;
Expand Down
24 changes: 14 additions & 10 deletions jscomp/stdlib/scanf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'use strict';

var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions");
var Bytes = require("./bytes");
var Pervasives = require("./pervasives");
var Caml_format = require("../runtime/caml_format");
var Printf = require("./printf");
Expand Down Expand Up @@ -1885,9 +1886,10 @@ function make_scanf(ib, _fmt, readers) {
}
break;
case 11 :
$$String.iter(function (param) {
return check_char(ib, param);
}, fmt[0]);
var f = function (param) {
return check_char(ib, param);
};
Bytes.iter(f, Caml_string.bytes_of_string(fmt[0]));
_fmt = fmt[1];
continue ;
case 12 :
Expand Down Expand Up @@ -1964,9 +1966,11 @@ function make_scanf(ib, _fmt, readers) {
'scanf: bad conversion "%t"'
];
case 17 :
$$String.iter(function (param) {
return check_char(ib, param);
}, CamlinternalFormat.string_of_formatting_lit(fmt[0]));
var s$2 = CamlinternalFormat.string_of_formatting_lit(fmt[0]);
var f$1 = function (param) {
return check_char(ib, param);
};
Bytes.iter(f$1, Caml_string.bytes_of_string(s$2));
_fmt = fmt[1];
continue ;
case 18 :
Expand Down Expand Up @@ -2005,7 +2009,7 @@ function make_scanf(ib, _fmt, readers) {
var match$6 = stopper_of_formatting_lit(rest$1[0]);
var width = width_of_pad_opt(width_opt);
scan_chars_in_char_set(char_set, /* Some */[match$6[0]], width, ib);
var s$2 = token(ib);
var s$3 = token(ib);
var str_rest_000$1 = match$6[1];
var str_rest_001$1 = rest$1[1];
var str_rest$1 = /* String_literal */{
Expand All @@ -2015,7 +2019,7 @@ function make_scanf(ib, _fmt, readers) {
tag: 11
};
return /* Cons */{
0: s$2,
0: s$3,
1: make_scanf(ib, str_rest$1, readers),
length: 2,
tag: 0
Expand All @@ -2027,9 +2031,9 @@ function make_scanf(ib, _fmt, readers) {
if (exit$1 === 1) {
var width$1 = width_of_pad_opt(width_opt);
scan_chars_in_char_set(char_set, /* None */0, width$1, ib);
var s$3 = token(ib);
var s$4 = token(ib);
return /* Cons */{
0: s$3,
0: s$4,
1: make_scanf(ib, rest$1, readers),
length: 2,
tag: 0
Expand Down
Loading