Skip to content

Commit ed2cd45

Browse files
committedJun 9, 2017
1 parent fcc4831 commit ed2cd45

File tree

257 files changed

+42818
-42786
lines changed

Some content is hidden

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

257 files changed

+42818
-42786
lines changed
 

‎jscomp/bin/whole_compiler.ml

+22-15
Original file line numberDiff line numberDiff line change
@@ -85253,7 +85253,7 @@ let pp_string f (* ?(utf=false)*) s =
8525385253
P.string f (Array.unsafe_get array_conv (c land 0xf))
8525485254
| '\"' -> P.string f "\\\"" (* quote*)
8525585255
| _ ->
85256-
P.string f (Array.unsafe_get array_str1 (Char.code c))
85256+
P.string f (Array.unsafe_get array_str1 (Char.code c))
8525785257
done
8525885258
in
8525985259
P.string f "\"";
@@ -85362,13 +85362,13 @@ type name =
8536285362
*)
8536385363
let rec
8536485364

85365-
try_optimize_curry cxt f len function_ =
85365+
try_optimize_curry cxt f len function_id =
8536685366
begin
8536785367
P.string f Js_config.curry;
8536885368
P.string f L.dot;
8536985369
P.string f "__";
8537085370
P.string f (Printf.sprintf "%d" len);
85371-
P.paren_group f 1 (fun _ -> expression 1 cxt f function_ )
85371+
P.paren_group f 1 (fun _ -> expression 1 cxt f function_id )
8537285372
end
8537385373

8537485374
and pp_function method_
@@ -85378,21 +85378,25 @@ and pp_function method_
8537885378
| [ {statement_desc =
8537985379
Return {return_value =
8538085380
{expression_desc =
85381-
Call(({expression_desc = Var v ; _} as function_),
85381+
Call(({expression_desc = Var v ; _} as function_id),
8538285382
ls ,
8538385383
{arity = ( Full | NA as arity(* see #234*));
8538485384
(* TODO: need a case to justify it*)
8538585385
call_info =
8538685386
(Call_builtin_runtime | Call_ml )})}}}],
8538785387
((_, false) | (No_name, true))
85388-
when
85388+
when
85389+
(* match such case:
85390+
{[ function(x,y){ return u(x,y) } ]}
85391+
it can be optimized in to either [u] or [Curry.__n(u)]
85392+
*)
8538985393
not method_ &&
85390-
Ext_list.for_all2_no_exn (fun a b ->
85391-
match b.J.expression_desc with
85394+
Ext_list.for_all2_no_exn (fun a (b : J.expression) ->
85395+
match b.expression_desc with
8539285396
| Var (Id i) -> Ident.same a i
8539385397
| _ -> false) l ls ->
8539485398
let optimize len p cxt f v =
85395-
if p then try_optimize_curry cxt f len function_
85399+
if p then try_optimize_curry cxt f len function_id
8539685400
else
8539785401
vident cxt f v
8539885402
in
@@ -85412,9 +85416,10 @@ and pp_function method_
8541285416
if return then
8541385417
begin
8541485418
P.string f L.return ;
85415-
P.space f;
85419+
P.space f
8541685420
end;
8541785421
optimize len (arity = NA && len <=8) cxt f v
85422+
8541885423
end
8541985424
| _, _ ->
8542085425

@@ -85475,7 +85480,7 @@ and pp_function method_
8547585480
ignore @@ P.brace_vgroup f 1 (fun _ -> statement_list false cxt f b );
8547685481
end
8547785482
in
85478-
let lexical = Js_fun_env.get_lexical_scope env in
85483+
let lexical : Ident_set.t = Js_fun_env.get_lexical_scope env in
8547985484
let enclose lexical return =
8548085485
let handle lexical =
8548185486
if Ident_set.is_empty lexical
@@ -85489,10 +85494,12 @@ and pp_function method_
8548985494

8549085495
begin match name with
8549185496
| No_name ->
85492-
P.string f L.function_;
85493-
P.space f ;
85494-
param_body ();
85495-
(* semi f ; *)
85497+
(* see # 1692, add a paren for annoymous function for safety *)
85498+
P.paren_group f 1 begin fun _ ->
85499+
P.string f L.function_;
85500+
P.space f ;
85501+
param_body ()
85502+
end
8549685503
| Name_non_top x ->
8549785504
P.string f L.var ;
8549885505
P.space f ;
@@ -86757,7 +86764,7 @@ let imports cxt f (modules : (Ident.t * string) list ) =
8675786764
(cxt, [], 0) modules in
8675886765
P.force_newline f ;
8675986766
Ext_list.rev_iter (fun (s,file) ->
86760-
86767+
8676186768
P.string f L.import;
8676286769
P.space f ;
8676386770
P.string f L.star ;

‎jscomp/core/js_dump.ml

+22-15
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ let pp_string f (* ?(utf=false)*) s =
230230
P.string f (Array.unsafe_get array_conv (c land 0xf))
231231
| '\"' -> P.string f "\\\"" (* quote*)
232232
| _ ->
233-
P.string f (Array.unsafe_get array_str1 (Char.code c))
233+
P.string f (Array.unsafe_get array_str1 (Char.code c))
234234
done
235235
in
236236
P.string f "\"";
@@ -339,13 +339,13 @@ type name =
339339
*)
340340
let rec
341341

342-
try_optimize_curry cxt f len function_ =
342+
try_optimize_curry cxt f len function_id =
343343
begin
344344
P.string f Js_config.curry;
345345
P.string f L.dot;
346346
P.string f "__";
347347
P.string f (Printf.sprintf "%d" len);
348-
P.paren_group f 1 (fun _ -> expression 1 cxt f function_ )
348+
P.paren_group f 1 (fun _ -> expression 1 cxt f function_id )
349349
end
350350

351351
and pp_function method_
@@ -355,21 +355,25 @@ and pp_function method_
355355
| [ {statement_desc =
356356
Return {return_value =
357357
{expression_desc =
358-
Call(({expression_desc = Var v ; _} as function_),
358+
Call(({expression_desc = Var v ; _} as function_id),
359359
ls ,
360360
{arity = ( Full | NA as arity(* see #234*));
361361
(* TODO: need a case to justify it*)
362362
call_info =
363363
(Call_builtin_runtime | Call_ml )})}}}],
364364
((_, false) | (No_name, true))
365-
when
365+
when
366+
(* match such case:
367+
{[ function(x,y){ return u(x,y) } ]}
368+
it can be optimized in to either [u] or [Curry.__n(u)]
369+
*)
366370
not method_ &&
367-
Ext_list.for_all2_no_exn (fun a b ->
368-
match b.J.expression_desc with
371+
Ext_list.for_all2_no_exn (fun a (b : J.expression) ->
372+
match b.expression_desc with
369373
| Var (Id i) -> Ident.same a i
370374
| _ -> false) l ls ->
371375
let optimize len p cxt f v =
372-
if p then try_optimize_curry cxt f len function_
376+
if p then try_optimize_curry cxt f len function_id
373377
else
374378
vident cxt f v
375379
in
@@ -389,9 +393,10 @@ and pp_function method_
389393
if return then
390394
begin
391395
P.string f L.return ;
392-
P.space f;
396+
P.space f
393397
end;
394398
optimize len (arity = NA && len <=8) cxt f v
399+
395400
end
396401
| _, _ ->
397402

@@ -452,7 +457,7 @@ and pp_function method_
452457
ignore @@ P.brace_vgroup f 1 (fun _ -> statement_list false cxt f b );
453458
end
454459
in
455-
let lexical = Js_fun_env.get_lexical_scope env in
460+
let lexical : Ident_set.t = Js_fun_env.get_lexical_scope env in
456461
let enclose lexical return =
457462
let handle lexical =
458463
if Ident_set.is_empty lexical
@@ -466,10 +471,12 @@ and pp_function method_
466471

467472
begin match name with
468473
| No_name ->
469-
P.string f L.function_;
470-
P.space f ;
471-
param_body ();
472-
(* semi f ; *)
474+
(* see # 1692, add a paren for annoymous function for safety *)
475+
P.paren_group f 1 begin fun _ ->
476+
P.string f L.function_;
477+
P.space f ;
478+
param_body ()
479+
end
473480
| Name_non_top x ->
474481
P.string f L.var ;
475482
P.space f ;
@@ -1734,7 +1741,7 @@ let imports cxt f (modules : (Ident.t * string) list ) =
17341741
(cxt, [], 0) modules in
17351742
P.force_newline f ;
17361743
Ext_list.rev_iter (fun (s,file) ->
1737-
1744+
17381745
P.string f L.import;
17391746
P.space f ;
17401747
P.string f L.star ;

0 commit comments

Comments
 (0)
Please sign in to comment.