Skip to content

Commit 051f2c9

Browse files
author
Hongbo Zhang
committed
bump version
1 parent 0459c2b commit 051f2c9

File tree

362 files changed

+509
-439
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

362 files changed

+509
-439
lines changed

jscomp/bin/compiler.ml

+81-80
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(** Bundled by ocaml_pack 06/21-10:50 *)
1+
(** Bundled by ocaml_pack 06/21-15:00 *)
22
module String_map : sig
33
#1 "string_map.mli"
44
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -1466,7 +1466,7 @@ let gc = "Caml_gc"
14661466
let int32 = "Caml_int32"
14671467
let block = "Block"
14681468
let js_primitive = "Js_primitive"
1469-
let version = "0.5.5"
1469+
let version = "0.6.0"
14701470
let runtime_set =
14711471
[
14721472
js_primitive;
@@ -7639,7 +7639,12 @@ val make_unused : unit -> Ident.t
76397639

76407640
val is_unused_ident : Ident.t -> bool
76417641

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+
76437648
val undefined : Ident.t
76447649
val is_js_or_global : Ident.t -> bool
76457650
val nil : Ident.t
@@ -7751,7 +7756,7 @@ let reserved_words =
77517756
"debugger";"default";"delete";"do";
77527757
"else";
77537758
"finally";"for";"function";
7754-
"if"; "in";"instanceof";
7759+
"if"; "then"; "in";"instanceof";
77557760
"new";
77567761
"return";
77577762
"switch";
@@ -7842,50 +7847,57 @@ let reserved_map =
78427847
List.fold_left (fun acc x -> String_set.add x acc) String_set.empty
78437848
reserved_words
78447849

7850+
7851+
7852+
7853+
78457854
(* TODO:
78467855
check name conflicts with javascript conventions
78477856
{[
78487857
Ext_ident.convert "^";;
78497858
- : string = "$caret"
78507859
]}
78517860
*)
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
78567863
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
78897901

78907902
(* It is currently made a persistent ident to avoid fresh ids
78917903
which would result in different signature files
@@ -13166,7 +13178,7 @@ let str_of_ident (cxt : Ext_pp_scope.t) (id : Ident.t) =
1316613178
[Printf.sprintf "%s$%d" name id.stamp] which is
1316713179
not relevant to the context
1316813180
*)
13169-
let name = Ext_ident.convert id.name in
13181+
let name = Ext_ident.convert true id.name in
1317013182
let i,new_cxt = Ext_pp_scope.add_ident id cxt in
1317113183
(* Attention:
1317213184
$$Array.length, due to the fact that global module is
@@ -13255,6 +13267,11 @@ let pp_string f ?(quote='"') ?(utf=false) s =
1325513267
P.string f quote_s
1325613268
;;
1325713269

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
1325813275

1325913276
(* TODO: check utf's correct semantics *)
1326013277
let pp_quote_string f s =
@@ -13463,7 +13480,7 @@ and vident cxt f (v : J.vident) =
1346313480
| Qualified (id,_, Some name) ->
1346413481
let cxt = ident cxt f id in
1346513482
P.string f L.dot;
13466-
P.string f (Ext_ident.convert name);
13483+
P.string f (Ext_ident.convert true name);
1346713484
cxt
1346813485
end
1346913486

@@ -13537,17 +13554,6 @@ and
1353713554
(Call ({expression_desc = Dot(a,L.bind, true); comment = None }, [b],
1353813555
{arity = Full; call_info = Call_na}))
1353913556
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 )) *)
1355113557

1355213558
| FlatCall(e,el) ->
1355313559
P.group f 1 (fun _ ->
@@ -13952,30 +13958,25 @@ and
1395213958
cxt in
1395313959
if l > 15 then P.paren_group f 1 action else action ()
1395413960

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
1396013966
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 ()
1397913980

1398013981
| New (e, el) ->
1398113982
let action () =
@@ -14032,7 +14033,7 @@ and property_name cxt f (s : J.property_name) : unit =
1403214033
| Tag -> P.string f L.tag
1403314034
| Length -> P.string f L.length
1403414035
| Key s ->
14035-
pp_string f ~utf:true ~quote:(best_string_quote s) s
14036+
property_string f s
1403614037
| Int_key i -> P.string f (string_of_int i)
1403714038

1403814039
and property_name_and_value_list cxt f l : Ext_pp_scope.t =
@@ -14508,7 +14509,7 @@ and block cxt f b =
1450814509
let exports cxt f (idents : Ident.t list) =
1450914510
let outer_cxt, reversed_list, margin =
1451014511
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
1451214513
let str,cxt = str_of_ident cxt id in
1451314514
cxt, ( (s,str) :: acc ) , max len (String.length s) )
1451414515
(cxt, [], 0) idents in
@@ -23758,7 +23759,7 @@ let pp = Format.fprintf
2375823759
let meaningless_names = ["*opt*"; "param";]
2375923760

2376023761
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
2376223763

2376323764
and dump_arity fmt (arity : Lam_stats.function_arities) =
2376423765
match arity with
@@ -23775,7 +23776,7 @@ and dump_arity fmt (arity : Lam_stats.function_arities) =
2377523776
Format.pp_print_space fmt ();
2377623777
)
2377723778
(fun fmt ident -> pp fmt "@[%s@ :@ any@]"
23778-
(Ext_ident.convert @@ Ident.name ident))
23779+
(Ext_ident.convert true @@ Ident.name ident))
2377923780
) args
2378023781

2378123782

jscomp/common/js_config.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ let gc = "Caml_gc"
213213
let int32 = "Caml_int32"
214214
let block = "Block"
215215
let js_primitive = "Js_primitive"
216-
let version = "0.5.5"
216+
let version = "0.6.0"
217217
let runtime_set =
218218
[
219219
js_primitive;

jscomp/test/promise.ml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
type t
3+
4+
external catch : t -> 'a -> 'b = "catch" [@@bs.send]
5+
6+
let f p =
7+
catch p 3
8+
9+
class type promise =
10+
object
11+
method then_ : 'a -> 'b
12+
method catch : 'a -> 'b
13+
end [@uncurry]
14+
15+
external new_promise : unit -> promise Js.t =
16+
"Promise" [@@bs.new] [@@bs.module "sys-bluebird"]
17+
18+
let () =
19+
let p = new_promise() in
20+
(p##then_(fun x -> x + 3))##catch_(fun reason -> reason)
21+
22+
23+
let u =
24+
{ then_ = 3 ;
25+
catch = 32
26+
} [@bs.obj]
27+
28+
29+
let uu = {
30+
_'x_ = 3
31+
} [@bs.obj]
32+
33+
34+
let hh = uu##_'x_

lib/js/arg.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.5.5 , PLEASE EDIT WITH CARE
1+
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.6.0 , PLEASE EDIT WITH CARE
22
'use strict';
33

44
var Caml_obj = require("./caml_obj");

lib/js/array.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.5.5 , PLEASE EDIT WITH CARE
1+
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.6.0 , PLEASE EDIT WITH CARE
22
'use strict';
33

44
var Caml_builtin_exceptions = require("./caml_builtin_exceptions");

lib/js/arrayLabels.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.5.5 , PLEASE EDIT WITH CARE
1+
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.6.0 , PLEASE EDIT WITH CARE
22
'use strict';
33

44
var $$Array = require("./array");

lib/js/bigarray.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.5.5 , PLEASE EDIT WITH CARE
1+
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.6.0 , PLEASE EDIT WITH CARE
22
'use strict';
33

44
var Caml_builtin_exceptions = require("./caml_builtin_exceptions");

lib/js/block.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.5.5 , PLEASE EDIT WITH CARE
1+
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.6.0 , PLEASE EDIT WITH CARE
22
'use strict';
33

44

lib/js/buffer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.5.5 , PLEASE EDIT WITH CARE
1+
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.6.0 , PLEASE EDIT WITH CARE
22
'use strict';
33

44
var Bytes = require("./bytes");

lib/js/bytes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.5.5 , PLEASE EDIT WITH CARE
1+
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.6.0 , PLEASE EDIT WITH CARE
22
'use strict';
33

44
var Caml_builtin_exceptions = require("./caml_builtin_exceptions");

lib/js/bytesLabels.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.5.5 , PLEASE EDIT WITH CARE
1+
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.6.0 , PLEASE EDIT WITH CARE
22
'use strict';
33

44
var Bytes = require("./bytes");

lib/js/callback.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.5.5 , PLEASE EDIT WITH CARE
1+
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.6.0 , PLEASE EDIT WITH CARE
22
'use strict';
33

44
var Obj = require("./obj");

lib/js/caml_array.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.5.5 , PLEASE EDIT WITH CARE
1+
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.6.0 , PLEASE EDIT WITH CARE
22
'use strict';
33

44

lib/js/caml_backtrace.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.5.5 , PLEASE EDIT WITH CARE
1+
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.6.0 , PLEASE EDIT WITH CARE
22
'use strict';
33

44
var Caml_builtin_exceptions = require("./caml_builtin_exceptions");

lib/js/caml_basic.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.5.5 , PLEASE EDIT WITH CARE
1+
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.6.0 , PLEASE EDIT WITH CARE
22
'use strict';
33

44

lib/js/caml_builtin_exceptions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.5.5 , PLEASE EDIT WITH CARE
1+
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.6.0 , PLEASE EDIT WITH CARE
22
'use strict';
33

44

lib/js/caml_exceptions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.5.5 , PLEASE EDIT WITH CARE
1+
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.6.0 , PLEASE EDIT WITH CARE
22
'use strict';
33

44

lib/js/caml_float.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.5.5 , PLEASE EDIT WITH CARE
1+
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.6.0 , PLEASE EDIT WITH CARE
22
'use strict';
33

44

0 commit comments

Comments
 (0)