Skip to content

Commit a2a1a8f

Browse files
author
Hongbo Zhang
committed
also need to transform attrbiutes, remove some unused dead code
1 parent 08c3628 commit a2a1a8f

18 files changed

+189
-84
lines changed

jscomp/bin/bs_ppx.ml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(** Bundled by bspack 08/24-16:25 *)
1+
(** Bundled by bspack 08/25-10:52 *)
22
module String_map : sig
33
#1 "string_map.mli"
44
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -1399,7 +1399,7 @@ val init : int -> (int -> 'a) -> 'a list
13991399
val take : int -> 'a list -> 'a list * 'a list
14001400
val try_take : int -> 'a list -> 'a list * int * 'a list
14011401

1402-
val exclude_tail : 'a list -> 'a list
1402+
val exclude_tail : 'a list -> 'a * 'a list
14031403

14041404
val filter_map2 : ('a -> 'b -> 'c option) -> 'a list -> 'b list -> 'c list
14051405

@@ -1463,6 +1463,8 @@ val ref_push : 'a -> 'a t -> unit
14631463

14641464
val ref_pop : 'a t -> 'a
14651465

1466+
val rev_except_last : 'a list -> 'a list * 'a
1467+
14661468
end = struct
14671469
#1 "ext_list.ml"
14681470
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -1651,11 +1653,11 @@ let try_take n l =
16511653
l, arr_length, []
16521654
else Array.to_list (Array.sub arr 0 n ), n, (Array.to_list (Array.sub arr n (arr_length - n)))
16531655

1654-
let exclude_tail (x : 'a list) : 'a list =
1656+
let exclude_tail (x : 'a list) =
16551657
let rec aux acc x =
16561658
match x with
16571659
| [] -> invalid_arg "Ext_list.exclude_tail"
1658-
| [ _ ] -> List.rev acc
1660+
| [ x ] -> x, List.rev acc
16591661
| y0::ys -> aux (y0::acc) ys in
16601662
aux [] x
16611663

@@ -1800,6 +1802,14 @@ let ref_pop refs =
18001802
refs := rest ;
18011803
x
18021804

1805+
let rev_except_last xs =
1806+
let rec aux acc xs =
1807+
match xs with
1808+
| [ ] -> invalid_arg "Ext_list.rev_except_last"
1809+
| [ x ] -> acc ,x
1810+
| x :: xs -> aux (x::acc) xs in
1811+
aux [] xs
1812+
18031813
end
18041814
module Ast_comb : sig
18051815
#1 "ast_comb.mli"
@@ -4267,7 +4277,9 @@ type t =
42674277

42684278

42694279

4270-
4280+
(**
4281+
return value is of [pval_type, pval_prim]
4282+
*)
42714283
val handle_attributes_as_string :
42724284
Bs_loc.t ->
42734285
string ->
@@ -4276,6 +4288,7 @@ val handle_attributes_as_string :
42764288
string ->
42774289
Ast_core_type.t * string list
42784290

4291+
42794292
val bs_external : string
42804293
val to_string : t -> string
42814294
val from_string : string -> t

jscomp/bin/compiler.ml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(** Bundled by bspack 08/24-16:25 *)
1+
(** Bundled by bspack 08/25-10:52 *)
22
module String_map : sig
33
#1 "string_map.mli"
44
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -1399,7 +1399,7 @@ val init : int -> (int -> 'a) -> 'a list
13991399
val take : int -> 'a list -> 'a list * 'a list
14001400
val try_take : int -> 'a list -> 'a list * int * 'a list
14011401

1402-
val exclude_tail : 'a list -> 'a list
1402+
val exclude_tail : 'a list -> 'a * 'a list
14031403

14041404
val filter_map2 : ('a -> 'b -> 'c option) -> 'a list -> 'b list -> 'c list
14051405

@@ -1463,6 +1463,8 @@ val ref_push : 'a -> 'a t -> unit
14631463

14641464
val ref_pop : 'a t -> 'a
14651465

1466+
val rev_except_last : 'a list -> 'a list * 'a
1467+
14661468
end = struct
14671469
#1 "ext_list.ml"
14681470
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -1651,11 +1653,11 @@ let try_take n l =
16511653
l, arr_length, []
16521654
else Array.to_list (Array.sub arr 0 n ), n, (Array.to_list (Array.sub arr n (arr_length - n)))
16531655

1654-
let exclude_tail (x : 'a list) : 'a list =
1656+
let exclude_tail (x : 'a list) =
16551657
let rec aux acc x =
16561658
match x with
16571659
| [] -> invalid_arg "Ext_list.exclude_tail"
1658-
| [ _ ] -> List.rev acc
1660+
| [ x ] -> x, List.rev acc
16591661
| y0::ys -> aux (y0::acc) ys in
16601662
aux [] x
16611663

@@ -1800,6 +1802,14 @@ let ref_pop refs =
18001802
refs := rest ;
18011803
x
18021804

1805+
let rev_except_last xs =
1806+
let rec aux acc xs =
1807+
match xs with
1808+
| [ ] -> invalid_arg "Ext_list.rev_except_last"
1809+
| [ x ] -> acc ,x
1810+
| x :: xs -> aux (x::acc) xs in
1811+
aux [] xs
1812+
18031813
end
18041814
module Ast_comb : sig
18051815
#1 "ast_comb.mli"
@@ -4267,7 +4277,9 @@ type t =
42674277

42684278

42694279

4270-
4280+
(**
4281+
return value is of [pval_type, pval_prim]
4282+
*)
42714283
val handle_attributes_as_string :
42724284
Bs_loc.t ->
42734285
string ->
@@ -4276,6 +4288,7 @@ val handle_attributes_as_string :
42764288
string ->
42774289
Ast_core_type.t * string list
42784290

4291+
42794292
val bs_external : string
42804293
val to_string : t -> string
42814294
val from_string : string -> t
@@ -26040,14 +26053,8 @@ let translate_ffi (ffi : Ast_external_attributes.ffi ) prim_name
2604026053
end
2604126054
| Js_send { name ; pipe = true ; splice = js_splice}
2604226055
-> (* splice should not happen *)
26043-
let self, args =
26044-
match List.rev args with
26045-
| self :: args -> self, List.rev args
26046-
| _ -> assert false in
26047-
let self_type, arg_types =
26048-
match List.rev arg_types with
26049-
| self_type :: arg_types -> self_type, List.rev arg_types
26050-
| _ -> assert false in
26056+
let self, args = Ext_list.exclude_tail args in
26057+
let self_type, arg_types = Ext_list.exclude_tail arg_types in
2605126058
let args = Ext_list.flat_map2_last (ocaml_to_js js_splice) arg_types args in
2605226059
E.call ~info:{arity=Full; call_info = Call_na} (E.dot self name) args
2605326060

jscomp/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,5 @@ make _build/bspack 2>> ./build.compile
6969

7070
# make snapshot
7171
# generate new js_cmj_datasets
72-
make snapshotml
72+
# make snapshotml
7373
echo "Done" >> ./build.compile

jscomp/ext/ext_list.ml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@ let try_take n l =
184184
l, arr_length, []
185185
else Array.to_list (Array.sub arr 0 n ), n, (Array.to_list (Array.sub arr n (arr_length - n)))
186186

187-
let exclude_tail (x : 'a list) : 'a list =
187+
let exclude_tail (x : 'a list) =
188188
let rec aux acc x =
189189
match x with
190190
| [] -> invalid_arg "Ext_list.exclude_tail"
191-
| [ _ ] -> List.rev acc
191+
| [ x ] -> x, List.rev acc
192192
| y0::ys -> aux (y0::acc) ys in
193193
aux [] x
194194

@@ -332,3 +332,11 @@ let ref_pop refs =
332332
| x::rest ->
333333
refs := rest ;
334334
x
335+
336+
let rev_except_last xs =
337+
let rec aux acc xs =
338+
match xs with
339+
| [ ] -> invalid_arg "Ext_list.rev_except_last"
340+
| [ x ] -> acc ,x
341+
| x :: xs -> aux (x::acc) xs in
342+
aux [] xs

jscomp/ext/ext_list.mli

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ val init : int -> (int -> 'a) -> 'a list
4646
val take : int -> 'a list -> 'a list * 'a list
4747
val try_take : int -> 'a list -> 'a list * int * 'a list
4848

49-
val exclude_tail : 'a list -> 'a list
49+
val exclude_tail : 'a list -> 'a * 'a list
5050

5151
val filter_map2 : ('a -> 'b -> 'c option) -> 'a list -> 'b list -> 'c list
5252

@@ -109,3 +109,5 @@ val ref_empty : 'a t -> bool
109109
val ref_push : 'a -> 'a t -> unit
110110

111111
val ref_pop : 'a t -> 'a
112+
113+
val rev_except_last : 'a list -> 'a list * 'a

jscomp/lam_compile_external_call.ml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,8 @@ let translate_ffi (ffi : Ast_external_attributes.ffi ) prim_name
241241
end
242242
| Js_send { name ; pipe = true ; splice = js_splice}
243243
-> (* splice should not happen *)
244-
let self, args =
245-
match List.rev args with
246-
| self :: args -> self, List.rev args
247-
| _ -> assert false in
248-
let self_type, arg_types =
249-
match List.rev arg_types with
250-
| self_type :: arg_types -> self_type, List.rev arg_types
251-
| _ -> assert false in
244+
let self, args = Ext_list.exclude_tail args in
245+
let self_type, arg_types = Ext_list.exclude_tail arg_types in
252246
let args = Ext_list.flat_map2_last (ocaml_to_js js_splice) arg_types args in
253247
E.call ~info:{arity=Full; call_info = Call_na} (E.dot self name) args
254248

jscomp/syntax/ast_attributes.ml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,6 @@ let process_external attrs =
117117
else false
118118
) attrs
119119

120-
let process_bs_type attrs =
121-
List.fold_right (fun (attr : attr) (st, acc) ->
122-
match attr with
123-
| {txt = "bs.type" }, PTyp typ
124-
->
125-
Some typ, acc
126-
| _ ->
127-
st, attr::acc
128-
) attrs (None, [])
129-
130120

131121
type derive_attr = {
132122
explict_nonrec : bool;
@@ -217,11 +207,8 @@ let bs_this : attr
217207
let bs_method : attr
218208
= {txt = "bs.meth"; loc = Location.none}, Ast_payload.empty
219209

220-
let mk_bs_type ?(loc=Location.none) ty : attr =
221-
{ txt = Literals.bs_type; loc }, PTyp ty
222210

223211
let bs_obj pval_type : t
224212
=
225-
[{txt = "bs.obj" ; loc = Location.none}, Ast_payload.empty ;
226-
mk_bs_type pval_type
213+
[{txt = "bs.obj" ; loc = Location.none}, Ast_payload.empty
227214
]

jscomp/syntax/ast_attributes.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ val process_bs :
3939
t -> [ `Nothing | `Has] * t
4040

4141
val process_external : t -> bool
42-
val process_bs_type : t -> Parsetree.core_type option * t
42+
4343
type derive_attr = {
4444
explict_nonrec : bool;
4545
bs_deriving : [`Has_deriving of Ast_payload.action list | `Nothing ]
@@ -62,4 +62,4 @@ val bs : attr
6262
val bs_this : attr
6363
val bs_method : attr
6464

65-
val mk_bs_type : ?loc:Location.t -> Parsetree.core_type -> attr
65+

0 commit comments

Comments
 (0)