@@ -85,6 +85,8 @@ module L = struct
8585 let stringify = " stringify"
8686 let console = " console"
8787 let define = " define"
88+ let break = " break"
89+ let strict_directive = " 'use strict';"
8890end
8991let return_indent = (String. length L. return / Ext_pp. indent_length)
9092
@@ -267,7 +269,10 @@ let rec pp_function
267269 (* pp_comment f (Some (Js_fun_env.to_string env))) ; *)
268270 let action return =
269271
270- (if return then P. string f " return " else () );
272+ (if return then begin
273+ P. string f L. return ;
274+ P. space f
275+ end else () );
271276 P. string f L. function_;
272277 P. space f ;
273278 (match name with None -> () | Some x -> ignore (ident inner_cxt f x));
@@ -289,7 +294,9 @@ let rec pp_function
289294 P. string f L. return ;
290295 P. space f
291296 end else () );
292- P. string f " (function(" ;
297+ P. string f " (" ;
298+ P. string f L. function_;
299+ P. string f " (" ;
293300 ignore @@ aux inner_cxt f lexical;
294301 P. string f " )" ;
295302 P. brace_vgroup f 0 (fun _ -> action true );
@@ -331,7 +338,7 @@ and output_one : 'a .
331338 (if break then
332339 begin
333340 P. newline f ;
334- P. string f " break" ;
341+ P. string f L. break;
335342 semi f;
336343 end ) ;
337344 cxt
@@ -355,7 +362,7 @@ and vident cxt f (v : J.vident) =
355362 ident cxt f v
356363 | Qualified (id ,_ , Some name ) ->
357364 let cxt = ident cxt f id in
358- P. string f " . " ;
365+ P. string f L. dot ;
359366 P. string f (Ext_ident. convert name);
360367 cxt
361368 end
@@ -1366,7 +1373,7 @@ let amd_program f ({modules; block = b ; exports = exp ; side_effect } : J.prog
13661373 let cxt = aux cxt f modules in
13671374 P. string f " )" ;
13681375 P. brace_vgroup f 1 @@ (fun _ ->
1369- let () = P. string f " 'use strict'; " in
1376+ let () = P. string f L. strict_directive in
13701377 let () = P. newline f in
13711378 let cxt = statement_list true cxt f b in
13721379 (* FIXME AMD : use {[ function xx ]} or {[ var x = function ..]} *)
@@ -1404,7 +1411,7 @@ let pp_program (program : J.program) (f : Ext_pp.t) =
14041411 begin
14051412 P. string f " // Generated CODE, PLEASE EDIT WITH CARE" ;
14061413 P. newline f;
1407- P. string f " \" use strict \" ; " ; (* TODO: use single quote in another commit *)
1414+ P. string f L. strict_directive;
14081415 P. newline f ;
14091416 (match Js_config. get_env () with
14101417 | Browser ->
0 commit comments