@@ -160,15 +160,15 @@ module Generate (Target : Wa_target_sig.S) = struct
160160 let rec index_rec context pc i =
161161 match context with
162162 | `Block pc' :: _ when pc = pc' -> i
163- | (`Block _ | `Skip | `Catch _ ) :: rem -> index_rec rem pc (i + 1 )
163+ | (`Block _ | `Skip | `Catch ) :: rem -> index_rec rem pc (i + 1 )
164164 | [] -> assert false
165165 in
166166 index_rec context pc 0
167167
168168 let catch_index context =
169169 let rec index_rec context i =
170170 match context with
171- | `Catch x :: _ -> Some (x, i)
171+ | `Catch :: _ -> Some i
172172 | (`Block _ | `Skip | `Return ) :: rem -> index_rec rem (i + 1 )
173173 | [] -> None
174174 in
@@ -759,7 +759,7 @@ module Generate (Target : Wa_target_sig.S) = struct
759759
760760 let extend_context fall_through context =
761761 match fall_through with
762- | (`Block _ | `Catch _ ) as b -> b :: context
762+ | (`Block _ | `Catch | `Skip ) as b -> b :: context
763763 | `Return -> `Skip :: context
764764
765765 let needed_handlers (p : program ) pc =
@@ -911,7 +911,7 @@ module Generate (Target : Wa_target_sig.S) = struct
911911 let * e = load x in
912912 match fall_through with
913913 | `Return -> instr (Push e)
914- | `Block _ | `Catch _ -> instr (Return (Some e)))
914+ | `Block _ | `Catch | `Skip -> instr (Return (Some e)))
915915 | Cond (x , cont1 , cont2 ) ->
916916 let context' = extend_context fall_through context in
917917 if_
@@ -923,7 +923,7 @@ module Generate (Target : Wa_target_sig.S) = struct
923923 let * e = Value. unit in
924924 match fall_through with
925925 | `Return -> instr (Push e)
926- | `Block _ | `Catch _ -> instr (Return (Some e)))
926+ | `Block _ | `Catch | `Skip -> instr (Return (Some e)))
927927 | Switch (x , a ) ->
928928 let len = Array. length a in
929929 let l = Array. to_list (Array. sub a ~pos: 0 ~len: (len - 1 )) in
@@ -937,12 +937,10 @@ module Generate (Target : Wa_target_sig.S) = struct
937937 let * e = load x in
938938 let * tag = register_import ~name: exception_name (Tag Value. value) in
939939 match fall_through with
940- | `Catch x -> store ~always: true x (return e)
941- | `Block _ | `Return -> (
940+ | `Catch -> instr ( Push e)
941+ | `Block _ | `Return | `Skip -> (
942942 match catch_index context with
943- | Some (x , i ) ->
944- let * () = store ~always: true x (return e) in
945- instr (Br (i, None ))
943+ | Some i -> instr (Br (i, Some e))
946944 | None -> instr (Throw (tag, e))))
947945 | Pushtrap (cont , x , cont' ) ->
948946 handle_exceptions
0 commit comments