@@ -628,6 +628,18 @@ end = struct
628628 output_byte ch 0x05 ;
629629 output_expression st ch e3;
630630 output_byte ch 0x0B
631+ | Try (typ , l , catches ) ->
632+ Feature. require exception_handling;
633+ output_byte ch 0x06 ;
634+ output_blocktype st.type_names ch typ;
635+ List. iter ~f: (fun i' -> output_instruction st ch i') l;
636+ List. iter
637+ ~f: (fun (tag , l , ty ) ->
638+ output_byte ch 0x07 ;
639+ output_uint ch (Hashtbl. find st.tag_names tag);
640+ output_instruction st ch (Br (l + 1 , Some (Pop ty))))
641+ catches;
642+ output_byte ch 0X0B
631643
632644 and output_instruction st ch i =
633645 match i with
@@ -688,23 +700,6 @@ end = struct
688700 output_uint ch (Hashtbl. find st.func_names f)
689701 | Nop -> ()
690702 | Push e -> output_expression st ch e
691- | Try (typ , l , catches , catchall ) ->
692- Feature. require exception_handling;
693- output_byte ch 0x06 ;
694- output_blocktype st.type_names ch typ;
695- List. iter ~f: (fun i' -> output_instruction st ch i') l;
696- List. iter
697- ~f: (fun (tag , l ) ->
698- output_byte ch 0x07 ;
699- output_uint ch (Hashtbl. find st.tag_names tag);
700- List. iter ~f: (fun i' -> output_instruction st ch i') l)
701- catches;
702- (match catchall with
703- | Some l ->
704- output_byte ch 0x05 ;
705- List. iter ~f: (fun i' -> output_instruction st ch i') l
706- | None -> () );
707- output_byte ch 0X0B
708703 | Throw (tag , e ) ->
709704 Feature. require exception_handling;
710705 output_expression st ch e;
@@ -881,6 +876,8 @@ end = struct
881876 ~f: (fun set i -> expr_function_references i set)
882877 ~init: (expr_function_references e' set)
883878 l
879+ | Try (_ , l , _ ) ->
880+ List. fold_left ~f: (fun set i -> instr_function_references i set) ~init: set l
884881
885882 and instr_function_references i set =
886883 match i with
@@ -905,24 +902,6 @@ end = struct
905902 | Br (_ , None ) | Return None | Nop | Rethrow _ -> set
906903 | CallInstr (_ , l ) ->
907904 List. fold_left ~f: (fun set i -> expr_function_references i set) ~init: set l
908- | Try (_ , l , catches , catchall ) ->
909- List. fold_left ~f: (fun set i -> instr_function_references i set) ~init: set l
910- |> (fun init ->
911- List. fold_left
912- ~f: (fun set (_ , l ) ->
913- List. fold_left
914- ~f: (fun set i -> instr_function_references i set)
915- ~init: set
916- l)
917- ~init
918- catches)
919- |> fun init ->
920- List. fold_left
921- ~f: (fun set i -> instr_function_references i set)
922- ~init
923- (match catchall with
924- | Some l -> l
925- | None -> [] )
926905 | ArraySet (_ , e1 , e2 , e3 ) ->
927906 set
928907 |> expr_function_references e1
0 commit comments