Skip to content

Commit a3f654f

Browse files
authored
Merge pull request #450 from bloomberg/fix_remember_state
fix #448 -- test bsc -I ../stdlib -I ../runtime -dsource -i config1_…
2 parents d2ed027 + 74ddb98 commit a3f654f

File tree

3 files changed

+45
-31
lines changed

3 files changed

+45
-31
lines changed

jscomp/lam_compile_group.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ let compile ~filename output_prefix non_export env _sigs
191191
(* To make toplevel happy - reentrant for js-demo *)
192192
let () =
193193
Translmod.reset () ;
194-
Lam_compile_env.reset ()
194+
Lam_compile_env.reset () ;
195195
in
196196
let lam = Lam.convert lam in
197197
let _d = Lam_util.dump env in

jscomp/syntax/ppx_entry.ml

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ let obj_type_as_js_obj_type = ref false
7979
let uncurry_type = ref false
8080
let obj_type_auto_uncurry = ref false
8181
let non_export = ref false
82+
83+
let reset () =
84+
record_as_js_object := None ;
85+
obj_type_as_js_obj_type := false ;
86+
uncurry_type := false ;
87+
obj_type_auto_uncurry := false ;
88+
non_export := false
89+
90+
8291
let lift_js_type ~loc x = Typ.constr ~loc {txt = js_obj_type_id (); loc} [x]
8392
let lift_curry_type ~loc x = Typ.constr ~loc {txt = curry_type_id (); loc} [x]
8493

@@ -666,37 +675,40 @@ let make_call_back table ((x : Longident.t Asttypes.loc) , y) =
666675

667676
let rewrite_signature : (Parsetree.signature -> Parsetree.signature) ref =
668677
ref (fun x ->
669-
match (x : Parsetree.signature) with
670-
| {psig_desc = Psig_attribute ({txt = "bs.config"; loc}, payload); _} :: rest
671-
->
672-
begin
673-
Ast_payload.as_record_and_process loc payload
674-
(make_call_back signature_config_table) ;
675-
unsafe_mapper.signature unsafe_mapper rest
676-
end
677-
| _ ->
678-
unsafe_mapper.signature unsafe_mapper x
679-
)
678+
let result =
679+
match (x : Parsetree.signature) with
680+
| {psig_desc = Psig_attribute ({txt = "bs.config"; loc}, payload); _} :: rest
681+
->
682+
begin
683+
Ast_payload.as_record_and_process loc payload
684+
(make_call_back signature_config_table) ;
685+
unsafe_mapper.signature unsafe_mapper rest
686+
end
687+
| _ ->
688+
unsafe_mapper.signature unsafe_mapper x in
689+
reset (); result
690+
)
680691

681692
let rewrite_implementation : (Parsetree.structure -> Parsetree.structure) ref =
682693
ref (fun (x : Parsetree.structure) ->
683-
match x with
684-
| {pstr_desc = Pstr_attribute ({txt = "bs.config"; loc}, payload); _} :: rest
685-
->
686-
begin
687-
Ast_payload.as_record_and_process loc payload
688-
(make_call_back structural_config_table) ;
689-
let rest = unsafe_mapper.structure unsafe_mapper rest in
690-
if !non_export then
691-
[Str.include_ ~loc
692-
(Incl.mk ~loc
693-
(Mod.constraint_ ~loc
694-
(Mod.structure ~loc rest )
695-
(Mty.signature ~loc [])
696-
))]
697-
else rest
698-
699-
end
700-
| _ ->
701-
unsafe_mapper.structure unsafe_mapper x )
694+
let result =
695+
match x with
696+
| {pstr_desc = Pstr_attribute ({txt = "bs.config"; loc}, payload); _} :: rest
697+
->
698+
begin
699+
Ast_payload.as_record_and_process loc payload
700+
(make_call_back structural_config_table) ;
701+
let rest = unsafe_mapper.structure unsafe_mapper rest in
702+
if !non_export then
703+
[Str.include_ ~loc
704+
(Incl.mk ~loc
705+
(Mod.constraint_ ~loc
706+
(Mod.structure ~loc rest )
707+
(Mty.signature ~loc [])
708+
))]
709+
else rest
710+
end
711+
| _ ->
712+
unsafe_mapper.structure unsafe_mapper x in
713+
reset (); result )
702714

jscomp/syntax/ppx_entry.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

2525

26+
27+
2628
val rewrite_signature : (Parsetree.signature -> Parsetree.signature) ref
2729

2830
val rewrite_implementation : (Parsetree.structure -> Parsetree.structure) ref

0 commit comments

Comments
 (0)