1
- (** Bundled by ocaml_pack 06/21-10:50 *)
1
+ (** Bundled by ocaml_pack 06/21-15:00 *)
2
2
module String_map : sig
3
3
#1 "string_map.mli"
4
4
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -1466,7 +1466,7 @@ let gc = "Caml_gc"
1466
1466
let int32 = "Caml_int32"
1467
1467
let block = "Block"
1468
1468
let js_primitive = "Js_primitive"
1469
- let version = "0.5.5 "
1469
+ let version = "0.6.0 "
1470
1470
let runtime_set =
1471
1471
[
1472
1472
js_primitive;
@@ -7639,7 +7639,12 @@ val make_unused : unit -> Ident.t
7639
7639
7640
7640
val is_unused_ident : Ident.t -> bool
7641
7641
7642
- val convert : string -> string
7642
+ (**
7643
+ if name is not converted, the reference should be equal
7644
+ *)
7645
+ val convert : bool -> string -> string
7646
+ val property_no_need_convert : string -> bool
7647
+
7643
7648
val undefined : Ident.t
7644
7649
val is_js_or_global : Ident.t -> bool
7645
7650
val nil : Ident.t
@@ -7751,7 +7756,7 @@ let reserved_words =
7751
7756
"debugger";"default";"delete";"do";
7752
7757
"else";
7753
7758
"finally";"for";"function";
7754
- "if"; "in";"instanceof";
7759
+ "if"; "then"; " in";"instanceof";
7755
7760
"new";
7756
7761
"return";
7757
7762
"switch";
@@ -7842,50 +7847,57 @@ let reserved_map =
7842
7847
List.fold_left (fun acc x -> String_set.add x acc) String_set.empty
7843
7848
reserved_words
7844
7849
7850
+
7851
+
7852
+
7853
+
7845
7854
(* TODO:
7846
7855
check name conflicts with javascript conventions
7847
7856
{[
7848
7857
Ext_ident.convert "^";;
7849
7858
- : string = "$caret"
7850
7859
]}
7851
7860
*)
7852
- let convert (name : string) =
7853
- let module E = struct exception Not_normal_letter of int end in
7854
- let len = String.length name in
7855
- if String_set.mem name reserved_map then "$$" ^ name
7861
+ let convert keyword (name : string) =
7862
+ if keyword && String_set.mem name reserved_map then "$$" ^ name
7856
7863
else
7857
- try
7858
- for i = 0 to len - 1 do
7859
- let c = String.unsafe_get name i in
7860
- if not ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c = '_' || c = '$' ) then
7861
- raise (E.Not_normal_letter i)
7862
- else ()
7863
- done;
7864
- name
7865
- with E.Not_normal_letter i ->
7866
- String.sub name 0 i ^
7867
- (let buffer = Buffer.create len in
7868
- for j = i to len - 1 do
7869
- let c = String.unsafe_get name j in
7870
- match c with
7871
- | '*' -> Buffer.add_string buffer "$star"
7872
- | '\'' -> Buffer.add_string buffer "$prime"
7873
- | '!' -> Buffer.add_string buffer "$bang"
7874
- | '>' -> Buffer.add_string buffer "$great"
7875
- | '<' -> Buffer.add_string buffer "$less"
7876
- | '=' -> Buffer.add_string buffer "$eq"
7877
- | '+' -> Buffer.add_string buffer "$plus"
7878
- | '-' -> Buffer.add_string buffer "$neg"
7879
- | '@' -> Buffer.add_string buffer "$at"
7880
- | '^' -> Buffer.add_string buffer "$caret"
7881
- | '/' -> Buffer.add_string buffer "$slash"
7882
- | '|' -> Buffer.add_string buffer "$pipe"
7883
- | '.' -> Buffer.add_string buffer "$dot"
7884
- | '%' -> Buffer.add_string buffer "$percent"
7885
- | '~' -> Buffer.add_string buffer "$tilde"
7886
- | 'a'..'z' | 'A'..'Z'| '_'|'$' |'0'..'9'-> Buffer.add_char buffer c
7887
- | _ -> Buffer.add_string buffer "$unknown"
7888
- done; Buffer.contents buffer)
7864
+ let module E = struct exception Not_normal_letter of int end in
7865
+ let len = String.length name in
7866
+ try
7867
+ for i = 0 to len - 1 do
7868
+ match String.unsafe_get name i with
7869
+ | 'a' .. 'z' | 'A' .. 'Z'
7870
+ | '0' .. '9' | '_' | '$' -> ()
7871
+ | _ -> raise (E.Not_normal_letter i)
7872
+ done;
7873
+ name
7874
+ with E.Not_normal_letter i ->
7875
+ String.sub name 0 i ^
7876
+ (let buffer = Buffer.create len in
7877
+ for j = i to len - 1 do
7878
+ let c = String.unsafe_get name j in
7879
+ match c with
7880
+ | '*' -> Buffer.add_string buffer "$star"
7881
+ | '\'' -> Buffer.add_string buffer "$prime"
7882
+ | '!' -> Buffer.add_string buffer "$bang"
7883
+ | '>' -> Buffer.add_string buffer "$great"
7884
+ | '<' -> Buffer.add_string buffer "$less"
7885
+ | '=' -> Buffer.add_string buffer "$eq"
7886
+ | '+' -> Buffer.add_string buffer "$plus"
7887
+ | '-' -> Buffer.add_string buffer "$neg"
7888
+ | '@' -> Buffer.add_string buffer "$at"
7889
+ | '^' -> Buffer.add_string buffer "$caret"
7890
+ | '/' -> Buffer.add_string buffer "$slash"
7891
+ | '|' -> Buffer.add_string buffer "$pipe"
7892
+ | '.' -> Buffer.add_string buffer "$dot"
7893
+ | '%' -> Buffer.add_string buffer "$percent"
7894
+ | '~' -> Buffer.add_string buffer "$tilde"
7895
+ | 'a'..'z' | 'A'..'Z'| '_'|'$' |'0'..'9'-> Buffer.add_char buffer c
7896
+ | _ -> Buffer.add_string buffer "$unknown"
7897
+ done; Buffer.contents buffer)
7898
+
7899
+ let property_no_need_convert s =
7900
+ s == convert false s
7889
7901
7890
7902
(* It is currently made a persistent ident to avoid fresh ids
7891
7903
which would result in different signature files
@@ -13166,7 +13178,7 @@ let str_of_ident (cxt : Ext_pp_scope.t) (id : Ident.t) =
13166
13178
[Printf.sprintf "%s$%d" name id.stamp] which is
13167
13179
not relevant to the context
13168
13180
*)
13169
- let name = Ext_ident.convert id.name in
13181
+ let name = Ext_ident.convert true id.name in
13170
13182
let i,new_cxt = Ext_pp_scope.add_ident id cxt in
13171
13183
(* Attention:
13172
13184
$$Array.length, due to the fact that global module is
@@ -13255,6 +13267,11 @@ let pp_string f ?(quote='"') ?(utf=false) s =
13255
13267
P.string f quote_s
13256
13268
;;
13257
13269
13270
+ let property_string f s =
13271
+ if Ext_ident.property_no_need_convert s then
13272
+ P.string f s
13273
+ else
13274
+ pp_string f ~utf:true ~quote:(best_string_quote s) s
13258
13275
13259
13276
(* TODO: check utf's correct semantics *)
13260
13277
let pp_quote_string f s =
@@ -13463,7 +13480,7 @@ and vident cxt f (v : J.vident) =
13463
13480
| Qualified (id,_, Some name) ->
13464
13481
let cxt = ident cxt f id in
13465
13482
P.string f L.dot;
13466
- P.string f (Ext_ident.convert name);
13483
+ P.string f (Ext_ident.convert true name);
13467
13484
cxt
13468
13485
end
13469
13486
@@ -13537,17 +13554,6 @@ and
13537
13554
(Call ({expression_desc = Dot(a,L.bind, true); comment = None }, [b],
13538
13555
{arity = Full; call_info = Call_na}))
13539
13556
end
13540
- (* | Tag_ml_obj e -> *)
13541
- (* P.group f 1 (fun _ -> *)
13542
- (* P.string f "Object.defineProperty"; *)
13543
- (* P.paren_group f 1 (fun _ -> *)
13544
- (* let cxt = expression 1 cxt f e in *)
13545
- (* P.string f L.comma; *)
13546
- (* P.space f ; *)
13547
- (* P.string f {|"##ml"|}; *)
13548
- (* P.string f L.comma; *)
13549
- (* P.string f {|{"value" : true, "writable" : false}|} ; *)
13550
- (* cxt )) *)
13551
13557
13552
13558
| FlatCall(e,el) ->
13553
13559
P.group f 1 (fun _ ->
@@ -13952,30 +13958,25 @@ and
13952
13958
cxt in
13953
13959
if l > 15 then P.paren_group f 1 action else action ()
13954
13960
13955
- | Dot (e, nm ,normal) ->
13956
- if normal then
13957
- begin
13958
- let action () =
13959
- let cxt = expression 15 cxt f e in
13961
+ | Dot (e, s ,normal) ->
13962
+ let action () =
13963
+ let cxt = expression 15 cxt f e in
13964
+ if Ext_ident.property_no_need_convert s then
13965
+ begin
13960
13966
P.string f L.dot;
13961
- P.string f (Ext_ident.convert nm);
13962
- (* See [Js_program_loader.obj_of_exports]
13963
- maybe in the ast level we should have
13964
- refer and export
13965
- *)
13966
- cxt in
13967
- if l > 15 then P.paren_group f 1 action else action ()
13968
- end
13969
- else begin
13970
- let action () =
13971
- P.group f 1 @@ fun _ ->
13972
- let cxt = expression 15 cxt f e in
13973
- (P.bracket_group f 1 @@ fun _ ->
13974
- pp_string f (* ~utf:(kind = `Utf8) *) ~quote:( best_string_quote nm) nm);
13975
- cxt
13976
- in
13977
- if l > 15 then P.paren_group f 1 action else action ()
13978
- end
13967
+ P.string f s;
13968
+ end
13969
+ else
13970
+ begin
13971
+ P.bracket_group f 1 @@ fun _ ->
13972
+ pp_string f (* ~utf:(kind = `Utf8) *) ~quote:( best_string_quote s) s
13973
+ end;
13974
+ (* See [Js_program_loader.obj_of_exports]
13975
+ maybe in the ast level we should have
13976
+ refer and export
13977
+ *)
13978
+ cxt in
13979
+ if l > 15 then P.paren_group f 1 action else action ()
13979
13980
13980
13981
| New (e, el) ->
13981
13982
let action () =
@@ -14032,7 +14033,7 @@ and property_name cxt f (s : J.property_name) : unit =
14032
14033
| Tag -> P.string f L.tag
14033
14034
| Length -> P.string f L.length
14034
14035
| Key s ->
14035
- pp_string f ~utf:true ~quote:(best_string_quote s) s
14036
+ property_string f s
14036
14037
| Int_key i -> P.string f (string_of_int i)
14037
14038
14038
14039
and property_name_and_value_list cxt f l : Ext_pp_scope.t =
@@ -14508,7 +14509,7 @@ and block cxt f b =
14508
14509
let exports cxt f (idents : Ident.t list) =
14509
14510
let outer_cxt, reversed_list, margin =
14510
14511
List.fold_left (fun (cxt, acc, len ) (id : Ident.t) ->
14511
- let s = Ext_ident.convert id.name in
14512
+ let s = Ext_ident.convert true id.name in
14512
14513
let str,cxt = str_of_ident cxt id in
14513
14514
cxt, ( (s,str) :: acc ) , max len (String.length s) )
14514
14515
(cxt, [], 0) idents in
@@ -23758,7 +23759,7 @@ let pp = Format.fprintf
23758
23759
let meaningless_names = ["*opt*"; "param";]
23759
23760
23760
23761
let rec dump_ident fmt (id : Ident.t) (arity : Lam_stats.function_arities) =
23761
- pp fmt "@[<2>export var %s:@ %a@ ;@]" (Ext_ident.convert id.name ) dump_arity arity
23762
+ pp fmt "@[<2>export var %s:@ %a@ ;@]" (Ext_ident.convert true id.name ) dump_arity arity
23762
23763
23763
23764
and dump_arity fmt (arity : Lam_stats.function_arities) =
23764
23765
match arity with
@@ -23775,7 +23776,7 @@ and dump_arity fmt (arity : Lam_stats.function_arities) =
23775
23776
Format.pp_print_space fmt ();
23776
23777
)
23777
23778
(fun fmt ident -> pp fmt "@[%s@ :@ any@]"
23778
- (Ext_ident.convert @@ Ident.name ident))
23779
+ (Ext_ident.convert true @@ Ident.name ident))
23779
23780
) args
23780
23781
23781
23782
0 commit comments