Skip to content

Commit 3d09f2b

Browse files
committed
Compiler: refactoring
1 parent 80b9f47 commit 3d09f2b

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

compiler/lib/driver.ml

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -355,36 +355,38 @@ let link ~export_runtime ~standalone ~linkall (js : Javascript.statement_list) :
355355
if export_runtime
356356
then
357357
let open Javascript in
358-
let all = Linker.all linkinfos in
359-
let all =
360-
List.map all ~f:(fun name ->
361-
let name = Utf8_string.of_string_exn name in
362-
Property (PNI name, EVar (ident name)))
363-
in
364-
(if standalone
365-
then
366-
( Expression_statement
367-
(EBin
368-
( Eq
369-
, dot
370-
(EVar (ident Constant.global_object_))
371-
(Utf8_string.of_string_exn "jsoo_runtime")
372-
, EObj all ))
373-
, N )
374-
else
375-
( Expression_statement
376-
(call
377-
(dot
378-
(EVar (ident (Utf8_string.of_string_exn "Object")))
379-
(Utf8_string.of_string_exn "assign"))
380-
[ dot
381-
(EVar (ident Constant.global_object_))
382-
(Utf8_string.of_string_exn "jsoo_runtime")
383-
; EObj all
384-
]
385-
N)
386-
, N ))
387-
:: js
358+
match Linker.all linkinfos with
359+
| [] -> js
360+
| all ->
361+
let all =
362+
List.map all ~f:(fun name ->
363+
let name = Utf8_string.of_string_exn name in
364+
Property (PNI name, EVar (ident name)))
365+
in
366+
(if standalone
367+
then
368+
( Expression_statement
369+
(EBin
370+
( Eq
371+
, dot
372+
(EVar (ident Constant.global_object_))
373+
(Utf8_string.of_string_exn "jsoo_runtime")
374+
, EObj all ))
375+
, N )
376+
else
377+
( Expression_statement
378+
(call
379+
(dot
380+
(EVar (ident (Utf8_string.of_string_exn "Object")))
381+
(Utf8_string.of_string_exn "assign"))
382+
[ dot
383+
(EVar (ident Constant.global_object_))
384+
(Utf8_string.of_string_exn "jsoo_runtime")
385+
; EObj all
386+
]
387+
N)
388+
, N ))
389+
:: js
388390
else js
389391
in
390392
let missing = Linker.missing linkinfos in

0 commit comments

Comments
 (0)