Skip to content

Commit 99187b6

Browse files
committed
remove Obj.truncate and Caml_obj_extern.set_length
1 parent 140149a commit 99187b6

File tree

12 files changed

+2284
-2400
lines changed

12 files changed

+2284
-2400
lines changed

jscomp/core/lam_dispatch_primitive.ml

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,6 @@ let translate loc (prim_name : string)
684684
(* "caml_alloc_dummy"; *)
685685
(* TODO: "caml_alloc_dummy_float"; *)
686686
| "caml_obj_dup"
687-
| "caml_obj_truncate"
688687
->
689688
call Js_runtime_modules.obj_runtime
690689

@@ -774,60 +773,7 @@ let translate loc (prim_name : string)
774773
E.runtime_ref Js_runtime_modules.io "stdout"
775774
| "caml_ml_open_descriptor_out" when
776775
args_const_unbox_approx_int_two args ->
777-
E.runtime_ref Js_runtime_modules.io "stderr"
778-
779-
| "caml_ba_create"
780-
| "caml_ba_get_generic"
781-
| "caml_ba_set_generic"
782-
| "caml_ba_num_dims"
783-
| "caml_ba_dim"
784-
| "caml_ba_kind"
785-
| "caml_ba_layout"
786-
| "caml_ba_sub"
787-
| "caml_ba_slice"
788-
| "caml_ba_blit"
789-
| "caml_ba_fill"
790-
| "caml_ba_reshape"
791-
| "caml_ba_map_file_bytecode"
792-
793-
(* caml_ba_get_1, (\* %caml_ba_ref_1 *\) *)
794-
(* caml_ba_get_2, *)
795-
(* caml_ba_get_3, *)
796-
797-
(* caml_ba_set_1, // %caml_ba_set_1 *)
798-
(* caml_ba_set_2, *)
799-
(* caml_ba_set_3, *)
800-
801-
(* caml_ba_dim_1, // %caml_ba_dim_1 *)
802-
(* caml_ba_dim_2, *)
803-
(* caml_ba_dim_3, *)
804-
| "caml_output_value_to_buffer"
805-
| "caml_marshal_data_size"
806-
| "caml_input_value_from_string"
807-
| "caml_output_value"
808-
| "caml_input_value"
809-
| "caml_output_value_to_string"
810-
| "caml_md5_chan"
811-
| "caml_hash_univ_param"
812-
| "caml_sys_close"
813-
| "caml_sys_open"
814-
| "caml_ml_input"
815-
| "caml_ml_input_scan_line"
816-
| "caml_ml_input_int"
817-
| "caml_ml_close_channel"
818-
| "caml_ml_output_int"
819-
820-
| "caml_ml_channel_size_64"
821-
| "caml_ml_channel_size"
822-
| "caml_ml_pos_in_64"
823-
| "caml_ml_pos_in"
824-
| "caml_ml_seek_in"
825-
| "caml_ml_seek_in_64"
826-
| "caml_ml_pos_out"
827-
| "caml_ml_pos_out_64"
828-
| "caml_ml_seek_out"
829-
| "caml_ml_seek_out_64"
830-
| "caml_ml_set_binary_mode"
776+
E.runtime_ref Js_runtime_modules.io "stderr"
831777
| _ ->
832778
Bs_warnings.warn_missing_primitive loc prim_name ;
833779
E.resolve_and_apply prim_name args

jscomp/runtime/caml_obj.ml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,6 @@ let caml_obj_dup : Caml_obj_extern.t -> Caml_obj_extern.t = [%raw{|function(x){
108108

109109

110110

111-
let caml_obj_truncate (x : Caml_obj_extern.t) (new_size : int) =
112-
let len = Caml_obj_extern.length x in
113-
if new_size <= 0 || new_size > len then
114-
raise (Invalid_argument "Obj.truncate")
115-
else
116-
if len <> new_size then
117-
begin
118-
for i = new_size to len - 1 do
119-
Obj.set_field x i (Obj.magic 0)
120-
done;
121-
Caml_obj_extern.set_length x new_size
122-
end
123-
124-
125-
126-
127-
128111

129112
(**
130113
For the empty dummy object, whether it's
@@ -151,9 +134,6 @@ let update_dummy : _ -> _ -> unit= [%raw{|function(x,y){
151134
}
152135
|}]
153136

154-
(* Caml_obj_extern.set_length x (Caml_obj_extern.length y) *)
155-
(* [set_length] seems redundant here given that it is initialized as an array
156-
*)
157137

158138

159139

jscomp/runtime/caml_obj.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ type t = Caml_obj_extern.t
3232
val caml_obj_block : int -> int -> Caml_obj_extern.t
3333
val caml_obj_dup : Caml_obj_extern.t -> Caml_obj_extern.t
3434

35-
val caml_obj_truncate : Caml_obj_extern.t -> int -> unit
36-
3735

3836
val update_dummy : Caml_obj_extern.t -> Caml_obj_extern.t -> unit
3937

jscomp/runtime/caml_obj_extern.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type t = Bs_stdlib_mini.Obj.t
2929

3030

3131

32-
external set_length : t -> int -> unit = "length" [@@bs.set]
32+
3333
external length : t -> int = "#obj_length"
3434

3535

jscomp/stdlib-406/obj.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ external field : t -> int -> t = "%obj_field"
3030
external set_field : t -> int -> t -> unit = "%obj_set_field"
3131

3232
external dup : t -> t = "caml_obj_dup"
33-
external truncate : t -> int -> unit = "caml_obj_truncate"
33+
3434

3535

3636

jscomp/stdlib-406/obj.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ external field : t -> int -> t = "%obj_field"
5555
*)
5656
external set_field : t -> int -> t -> unit = "%obj_set_field"
5757
external dup : t -> t = "caml_obj_dup"
58-
external truncate : t -> int -> unit = "caml_obj_truncate"
58+
5959

6060

6161
module Ephemeron: sig

jscomp/test/ocaml_parsetree_test.js

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -11444,6 +11444,67 @@ function token(lexbuf) {
1144411444
};
1144511445
}
1144611446

11447+
function string(lexbuf) {
11448+
lexbuf.lex_mem = Caml_array.caml_make_vect(2, -1);
11449+
var ___ocaml_lex_state = 164;
11450+
while(true) {
11451+
var __ocaml_lex_state = ___ocaml_lex_state;
11452+
var __ocaml_lex_state$1 = Lexing.new_engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf);
11453+
switch (__ocaml_lex_state$1) {
11454+
case 0 :
11455+
return ;
11456+
case 1 :
11457+
var space = Lexing.sub_lexeme(lexbuf, Caml_array.caml_array_get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos);
11458+
update_loc(lexbuf, undefined, 1, false, space.length);
11459+
return string(lexbuf);
11460+
case 2 :
11461+
store_string_char(char_for_backslash(Lexing.lexeme_char(lexbuf, 1)));
11462+
return string(lexbuf);
11463+
case 3 :
11464+
store_string_char(char_for_decimal_code(lexbuf, 1));
11465+
return string(lexbuf);
11466+
case 4 :
11467+
store_string_char(char_for_hexadecimal_code(lexbuf, 2));
11468+
return string(lexbuf);
11469+
case 5 :
11470+
if (comment_start_loc.contents !== /* [] */0) {
11471+
return string(lexbuf);
11472+
}
11473+
var loc = curr(lexbuf);
11474+
prerr_warning(loc, /* Illegal_backslash */7);
11475+
store_string_char(Lexing.lexeme_char(lexbuf, 0));
11476+
store_string_char(Lexing.lexeme_char(lexbuf, 1));
11477+
return string(lexbuf);
11478+
case 6 :
11479+
if (comment_start_loc.contents === /* [] */0) {
11480+
prerr_warning(curr(lexbuf), /* Eol_in_string */14);
11481+
}
11482+
update_loc(lexbuf, undefined, 1, false, 0);
11483+
store_string(Lexing.lexeme(lexbuf));
11484+
return string(lexbuf);
11485+
case 7 :
11486+
is_in_string.contents = false;
11487+
throw {
11488+
RE_EXN_ID: $$Error$2,
11489+
_1: /* Unterminated_string */0,
11490+
_2: string_start_loc.contents,
11491+
Error: new Error()
11492+
};
11493+
case 8 :
11494+
store_string_char(Lexing.lexeme_char(lexbuf, 0));
11495+
return string(lexbuf);
11496+
default:
11497+
Curry._1(lexbuf.refill_buff, lexbuf);
11498+
___ocaml_lex_state = __ocaml_lex_state$1;
11499+
continue ;
11500+
}
11501+
};
11502+
}
11503+
11504+
function comment(lexbuf) {
11505+
return __ocaml_lex_comment_rec(lexbuf, 132);
11506+
}
11507+
1144711508
function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) {
1144811509
while(true) {
1144911510
var __ocaml_lex_state = ___ocaml_lex_state;
@@ -11625,67 +11686,6 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) {
1162511686
};
1162611687
}
1162711688

11628-
function comment(lexbuf) {
11629-
return __ocaml_lex_comment_rec(lexbuf, 132);
11630-
}
11631-
11632-
function string(lexbuf) {
11633-
lexbuf.lex_mem = Caml_array.caml_make_vect(2, -1);
11634-
var ___ocaml_lex_state = 164;
11635-
while(true) {
11636-
var __ocaml_lex_state = ___ocaml_lex_state;
11637-
var __ocaml_lex_state$1 = Lexing.new_engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf);
11638-
switch (__ocaml_lex_state$1) {
11639-
case 0 :
11640-
return ;
11641-
case 1 :
11642-
var space = Lexing.sub_lexeme(lexbuf, Caml_array.caml_array_get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos);
11643-
update_loc(lexbuf, undefined, 1, false, space.length);
11644-
return string(lexbuf);
11645-
case 2 :
11646-
store_string_char(char_for_backslash(Lexing.lexeme_char(lexbuf, 1)));
11647-
return string(lexbuf);
11648-
case 3 :
11649-
store_string_char(char_for_decimal_code(lexbuf, 1));
11650-
return string(lexbuf);
11651-
case 4 :
11652-
store_string_char(char_for_hexadecimal_code(lexbuf, 2));
11653-
return string(lexbuf);
11654-
case 5 :
11655-
if (comment_start_loc.contents !== /* [] */0) {
11656-
return string(lexbuf);
11657-
}
11658-
var loc = curr(lexbuf);
11659-
prerr_warning(loc, /* Illegal_backslash */7);
11660-
store_string_char(Lexing.lexeme_char(lexbuf, 0));
11661-
store_string_char(Lexing.lexeme_char(lexbuf, 1));
11662-
return string(lexbuf);
11663-
case 6 :
11664-
if (comment_start_loc.contents === /* [] */0) {
11665-
prerr_warning(curr(lexbuf), /* Eol_in_string */14);
11666-
}
11667-
update_loc(lexbuf, undefined, 1, false, 0);
11668-
store_string(Lexing.lexeme(lexbuf));
11669-
return string(lexbuf);
11670-
case 7 :
11671-
is_in_string.contents = false;
11672-
throw {
11673-
RE_EXN_ID: $$Error$2,
11674-
_1: /* Unterminated_string */0,
11675-
_2: string_start_loc.contents,
11676-
Error: new Error()
11677-
};
11678-
case 8 :
11679-
store_string_char(Lexing.lexeme_char(lexbuf, 0));
11680-
return string(lexbuf);
11681-
default:
11682-
Curry._1(lexbuf.refill_buff, lexbuf);
11683-
___ocaml_lex_state = __ocaml_lex_state$1;
11684-
continue ;
11685-
}
11686-
};
11687-
}
11688-
1168911689
function __ocaml_lex_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) {
1169011690
while(true) {
1169111691
var __ocaml_lex_state = ___ocaml_lex_state;

jscomp/test/ocaml_proto_test.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,31 +1505,28 @@ function __ocaml_lex_comment_rec(_l, lexbuf, ___ocaml_lex_state) {
15051505
};
15061506
}
15071507

1508-
function __ocaml_lex_string_rec(_l, lexbuf, ___ocaml_lex_state) {
1508+
function __ocaml_lex_multi_line_comment_rec(_l, lexbuf, ___ocaml_lex_state) {
15091509
while(true) {
15101510
var __ocaml_lex_state = ___ocaml_lex_state;
15111511
var l = _l;
15121512
var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf);
15131513
switch (__ocaml_lex_state$1) {
15141514
case 0 :
1515-
var c = Lexing.lexeme_char(lexbuf, 1);
1516-
___ocaml_lex_state = 55;
1517-
_l = /* :: */[
1518-
Char.escaped(c),
1519-
l
1520-
];
1515+
update_loc(lexbuf);
1516+
___ocaml_lex_state = 47;
15211517
continue ;
15221518
case 1 :
1523-
return /* String_value */[$$String.concat("", List.rev(l))];
1519+
Lexing.lexeme(lexbuf);
1520+
return /* Comment_value */[$$String.concat("", List.rev(l))];
15241521
case 2 :
1525-
___ocaml_lex_state = 55;
1522+
___ocaml_lex_state = 47;
15261523
_l = /* :: */[
15271524
Lexing.lexeme(lexbuf),
15281525
l
15291526
];
15301527
continue ;
15311528
case 3 :
1532-
return /* String_eof */0;
1529+
return /* Comment_eof */0;
15331530
default:
15341531
Curry._1(lexbuf.refill_buff, lexbuf);
15351532
___ocaml_lex_state = __ocaml_lex_state$1;
@@ -1538,28 +1535,31 @@ function __ocaml_lex_string_rec(_l, lexbuf, ___ocaml_lex_state) {
15381535
};
15391536
}
15401537

1541-
function __ocaml_lex_multi_line_comment_rec(_l, lexbuf, ___ocaml_lex_state) {
1538+
function __ocaml_lex_string_rec(_l, lexbuf, ___ocaml_lex_state) {
15421539
while(true) {
15431540
var __ocaml_lex_state = ___ocaml_lex_state;
15441541
var l = _l;
15451542
var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf);
15461543
switch (__ocaml_lex_state$1) {
15471544
case 0 :
1548-
update_loc(lexbuf);
1549-
___ocaml_lex_state = 47;
1545+
var c = Lexing.lexeme_char(lexbuf, 1);
1546+
___ocaml_lex_state = 55;
1547+
_l = /* :: */[
1548+
Char.escaped(c),
1549+
l
1550+
];
15501551
continue ;
15511552
case 1 :
1552-
Lexing.lexeme(lexbuf);
1553-
return /* Comment_value */[$$String.concat("", List.rev(l))];
1553+
return /* String_value */[$$String.concat("", List.rev(l))];
15541554
case 2 :
1555-
___ocaml_lex_state = 47;
1555+
___ocaml_lex_state = 55;
15561556
_l = /* :: */[
15571557
Lexing.lexeme(lexbuf),
15581558
l
15591559
];
15601560
continue ;
15611561
case 3 :
1562-
return /* Comment_eof */0;
1562+
return /* String_eof */0;
15631563
default:
15641564
Curry._1(lexbuf.refill_buff, lexbuf);
15651565
___ocaml_lex_state = __ocaml_lex_state$1;

0 commit comments

Comments
 (0)