@@ -34,15 +34,16 @@ let should_unfold cfg should_reify fv qninfo : should_unfold_res =
3434 | None -> []
3535 | Some quals -> quals
3636 in
37- (* unfold or not, fully or not, reified or not *)
38- let yes = true , false , false in
39- let no = false , false , false in
40- let fully = true , true , false in
41- let reif = true , false , true in
37+ (* unfold or not, fully or not, reified or not, only once or not *)
38+ let yes = true , false , false , false in
39+ let no = false , false , false , false in
40+ let fully = true , true , false , false in
41+ let reif = true , false , true , false in
42+ let once = true , false , false , true in
4243
4344 let yesno b = if b then yes else no in
4445 let fullyno b = if b then fully else no in
45- let comb_or l = List. fold_right ( fun ( a , b , c ) ( x , y , z ) -> ( a || x , b || y , c || z )) l ( false , false , false ) in
46+ let comb_or l = List. fold_right ( fun ( a , b , c , d ) ( x , y , z , w ) -> ( a || x , b || y , c || z , d || w )) l ( false , false , false , false ) in
4647
4748 let default_unfolding () =
4849 log_unfolding cfg ( fun () -> BU. print3 " should_unfold: Reached a %s with delta_depth = %s\n >> Our delta_level is %s\n "
@@ -57,12 +58,13 @@ let should_unfold cfg should_reify fv qninfo : should_unfold_res =
5758 in
5859 let selective_unfold =
5960 Some ? cfg . steps . unfold_only ||
61+ Some ? cfg . steps . unfold_once ||
6062 Some ? cfg . steps . unfold_fully ||
6163 Some ? cfg . steps . unfold_attr ||
6264 Some ? cfg . steps . unfold_qual ||
6365 Some ? cfg . steps . unfold_namespace
6466 in
65- let res : bool & bool & bool =
67+ let res : bool & bool & bool & bool =
6668 match qninfo , selective_unfold with
6769 // We unfold dm4f actions if and only if we are reifying
6870 | _ when Env. qninfo_is_action qninfo ->
@@ -83,6 +85,11 @@ let should_unfold cfg should_reify fv qninfo : should_unfold_res =
8385 log_unfolding cfg ( fun () -> BU. print_string " >> HasMaskedEffect, not unfolding\n " );
8486 no
8587
88+ // Unfoldonce. NB: this is before the zeta case, so we unfold even if zeta is off
89+ | _ , true when Some ? cfg . steps . unfold_once && BU. for_some ( fv_eq_lid fv ) ( Some ?. v cfg . steps . unfold_once ) ->
90+ log_unfolding cfg ( fun () -> BU. print_string " >> UnfoldOnce\n " );
91+ once
92+
8693 // Recursive lets may only be unfolded when Zeta is on
8794 | Some ( Inr ({ sigquals = qs ; sigel = Sig_let { lbs =( is_rec , _ )}}, _ ), _ ), _ when
8895 is_rec && not cfg . steps . zeta && not cfg . steps . zeta_full ->
@@ -160,10 +167,11 @@ let should_unfold cfg should_reify fv qninfo : should_unfold_res =
160167 );
161168 let r =
162169 match res with
163- | false , _ , _ -> Should_unfold_no
164- | true , false , false -> Should_unfold_yes
165- | true , true , false -> Should_unfold_fully
166- | true , false , true -> Should_unfold_reify
170+ | false , _ , _ , _ -> Should_unfold_no
171+ | true , false , false , false -> Should_unfold_yes
172+ | true , false , false , true -> Should_unfold_once
173+ | true , true , false , false -> Should_unfold_fully
174+ | true , false , true , false -> Should_unfold_reify
167175 | _ ->
168176 failwith <| BU. format1 " Unexpected unfolding result: %s" ( show res )
169177 in
0 commit comments