@@ -207,11 +207,18 @@ let tc1_get_stmt side tc =
207207 tc_error_noXhl ~kinds: (hlkinds_Xhl_r `Stmt ) !! tc
208208
209209(* ------------------------------------------------------------------ *)
210- let tc1_process_codepos_range tc (side , cpr ) =
210+ let tc1_process_codepos_or_range tc (side , cpor ) =
211211 let me, _ = tc1_get_stmt side tc in
212212 let env = FApi. tc1_env tc in
213213 let env = EcEnv.Memory. push_active_ss me env in
214- EcTyping. trans_codepos_range env cpr
214+ EcTyping. trans_codepos_or_range env cpor
215+
216+ (* ------------------------------------------------------------------ *)
217+ let tc1_process_codegap_range tc (side , cgr ) =
218+ let me, _ = tc1_get_stmt side tc in
219+ let env = FApi. tc1_env tc in
220+ let env = EcEnv.Memory. push_active_ss me env in
221+ EcTyping. trans_codegap_range env cgr
215222
216223(* ------------------------------------------------------------------ *)
217224let tc1_process_codepos tc (side , cpos ) =
@@ -379,22 +386,37 @@ let logicS_post_read (env : env) (f : logicS) =
379386 add EcPV.PMVS. empty (es_po es).inv
380387
381388(* -------------------------------------------------------------------- *)
382- exception InvalidSplit of codepos1
389+ exception InvalidSplit of [ `Instr of codepos1 | `Gap of codegap1 ]
390+
383391
384392let s_split env i s =
385- let module Zpr = EcMatching. Zipper in
386- try Zpr. split_at_cpos1 env i s
387- with Zpr .InvalidCPos -> raise (InvalidSplit i )
393+ let module Pos = EcMatching. Position in
394+ try Pos. split_at_cgap1 env i s
395+ with Pos .InvalidCPos -> raise (InvalidSplit ( `Gap i) )
388396
389397let s_split_i env i s =
390- let module Zpr = EcMatching. Zipper in
391- try Zpr . find_by_cpos1 ~rev: false env i s
392- with Zpr .InvalidCPos -> raise (InvalidSplit i )
398+ let module Pos = EcMatching. Position in
399+ try Pos . find_by_cpos1 ~rev: false env i s
400+ with Pos .InvalidCPos -> raise (InvalidSplit ( `Instr i) )
393401
394402let o_split ?rev env i s =
395- let module Zpr = EcMatching. Zipper in
396- try Zpr. may_split_at_cpos1 ?rev env i s
397- with Zpr. InvalidCPos -> raise (InvalidSplit (oget i))
403+ let module Pos = EcMatching. Position in
404+ try Pos. may_split_at_cgap1 ?rev env i s
405+ with Pos. InvalidCPos -> raise (InvalidSplit (`Gap (oget i)))
406+
407+ (* -------------------------------------------------------------------- *)
408+ (* Gap processing functions *)
409+ let tc1_process_codegap1 tc (side , g ) =
410+ let me, _ = tc1_get_stmt side tc in
411+ let env = FApi. tc1_env tc in
412+ let env = EcEnv.Memory. push_active_ss me env in
413+ EcTyping. trans_codegap1 env g
414+
415+ let tc1_process_codegap tc (side , g ) =
416+ let me, _ = tc1_get_stmt side tc in
417+ let env = FApi. tc1_env tc in
418+ let env = EcEnv.Memory. push_active_ss me env in
419+ EcTyping. trans_codegap env g
398420
399421(* -------------------------------------------------------------------- *)
400422let t_hS_or_bhS_or_eS ?th ?teh ?tbh ?te tc =
@@ -740,14 +762,14 @@ let t_fold f (cenv : code_txenv) (cpos : codepos) (_ : form * form) (state, s) =
740762 let env = EcEnv.LDecl. toenv (snd cenv) in
741763 let (me, f) = Zpr. fold env cenv cpos (fun _ -> f) state s in
742764 ((me, f, [] ) : memenv * _ * form list )
743- with Zpr. InvalidCPos -> tc_error (fst cenv) " invalid code position"
765+ with InvalidCPos -> tc_error (fst cenv) " invalid code position"
744766
745767let t_zip f (cenv : code_txenv ) (cpos : codepos ) (prpo : form * form ) (state , s ) =
746768 try
747769 let env = EcEnv.LDecl. toenv (snd cenv) in
748770 let (me, zpr, gs) = f cenv prpo state (Zpr. zipper_of_cpos env cpos s) in
749771 ((me, Zpr. zip zpr, gs) : memenv * _ * form list )
750- with Zpr. InvalidCPos -> tc_error (fst cenv) " invalid code position"
772+ with InvalidCPos -> tc_error (fst cenv) " invalid code position"
751773
752774let t_code_transform (side : oside ) ?(bdhoare = false ) cpos tr tx tc =
753775 let pf = FApi. tc1_penv tc in
0 commit comments