Skip to content

Commit 3eeec5d

Browse files
committed
Merge pull request rescript-lang#92 from bloomberg/clean_up
clean up
2 parents 3069360 + 45798de commit 3eeec5d

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Note that you have to clone this project with `--recursive` option, as the core
8383
Assume that you have `ocamlopt.opt` in the `PATH`
8484
```sh
8585
cd ./jscomp
86-
ocamlopt.opt -g -linkall -I +compiler-libs -I bin ocamlcommon.cmxa ocamlbytecomp.cmxa bin/compiler.mli bin/compiler.ml -o bin/osc
86+
ocamlopt.opt -g -inline 100 -linkall -I +compiler-libs -I bin ocamlcommon.cmxa ocamlbytecomp.cmxa bin/compiler.mli bin/compiler.ml -o bin/osc
8787
```
8888

8989
Now you have a binary called `osc` under `jscomp/bin` directory,

jscomp/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ snapshotcmj:
4848

4949
releasebuild:
5050
@echo "Make release compiler"
51-
$(NATIVE) -g -linkall -I +compiler-libs -I bin ocamlcommon.cmxa ocamlbytecomp.cmxa bin/compiler.mli bin/compiler.ml -o bin/osc
51+
$(NATIVE) -g -inline 100 -linkall -I +compiler-libs -I bin ocamlcommon.cmxa ocamlbytecomp.cmxa bin/compiler.mli bin/compiler.ml -o bin/osc
5252

5353
stdlib:
5454
cd stdlib && ./build.sh

jscomp/lam_compile.ml

+23-23
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ and
442442
(* External function calll *)
443443
| Lapply(Lprim(Pfield n, [ Lprim(Pgetglobal id,[])]), args_lambda,_info) ->
444444

445-
get_exp_with_args cxt lam args_lambda(* args_code *) id n env (* args *)
445+
get_exp_with_args cxt lam args_lambda id n env
446446

447447

448448
| Lapply(fn,args_lambda, info) ->
@@ -451,31 +451,31 @@ and
451451
2. no need create names
452452
*)
453453
begin
454-
let [@warning "-8" (* non-exhaustive pattern*)] (args_code, fn_code::args) =
455-
(fn::args_lambda)
456-
|> List.map
457-
(
458-
fun (x : Lambda.lambda) ->
459-
match x with
460-
| Lprim (Pgetglobal ident, []) ->
461-
(* when module is passed as an argument - unpack to an array
462-
for the function, generative module or functor can be a function,
463-
however it can not be global -- global can only module
464-
*)
465-
[], Lam_compile_global.get_exp (ident, env,true)
466-
| _ ->
467-
begin
468-
match compile_lambda
469-
{cxt with st = NeedValue ; should_return = False} x with
470-
| {block = a; value = Some b} -> a,b
471-
| _ -> assert false
472-
end)
473-
|> List.split in
454+
let [@warning "-8" (* non-exhaustive pattern*)] (args_code, fn_code:: args) =
455+
List.fold_right (fun (x : Lambda.lambda) (args_code, fn_code )->
456+
match x with
457+
| Lprim (Pgetglobal ident, []) ->
458+
(* when module is passed as an argument - unpack to an array
459+
for the function, generative module or functor can be a function,
460+
however it can not be global -- global can only module
461+
*)
462+
args_code, Lam_compile_global.get_exp (ident, env,true) :: fn_code
463+
| _ ->
464+
begin
465+
match compile_lambda
466+
{cxt with st = NeedValue ; should_return = False} x with
467+
| {block = a; value = Some b} -> a @ args_code , b:: fn_code
468+
| _ -> assert false
469+
end
470+
) (fn::args_lambda) ([],[]) in
471+
472+
474473
begin
475474
match fn, should_return with
476475
| (Lvar id',
477476
True (Some ({id;label; params; _} as ret))) when Ident.same id id' ->
478477

478+
479479
(* Ext_log.err "@[ %s : %a tailcall @]@." cxt.meta.filename Ident.print id; *)
480480
ret.triggered <- true;
481481
(* Here we mark [finished] true, since the continuation
@@ -492,7 +492,7 @@ and
492492
493493
*)
494494
(* TODO: use [fold]*)
495-
let block = List.concat args_code @
495+
let block = args_code @
496496
(
497497
let (_,assigned_params,new_params) =
498498
List.fold_left2 (fun (i,assigns,new_params) param (arg : J.expression) ->
@@ -546,7 +546,7 @@ and
546546
(* (E.call fn_code args) *)
547547
| _ ->
548548

549-
Js_output.handle_block_return st should_return lam (List.concat args_code )
549+
Js_output.handle_block_return st should_return lam args_code
550550
(E.call ~info:(match fn, info with
551551
| _, { apply_status = Full} -> {arity = Full }
552552
| _, { apply_status = NA} -> {arity = NA} ) fn_code args)

0 commit comments

Comments
 (0)