From 6d2cafb9727721615886ce5cfbcc47fc7ba1bd96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Tue, 20 Aug 2024 23:17:13 +0200 Subject: [PATCH] Emit try_table instruction --- compiler/lib/wasm/wa_wat_output.ml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/compiler/lib/wasm/wa_wat_output.ml b/compiler/lib/wasm/wa_wat_output.ml index c3f935459..123da0488 100644 --- a/compiler/lib/wasm/wa_wat_output.ml +++ b/compiler/lib/wasm/wa_wat_output.ml @@ -480,16 +480,13 @@ let expression_or_instructions ctx st in_function = ] | Try (ty, body, catches) -> [ List - (Atom "try" + (Atom "try_table" :: (block_type st ty - @ List (Atom "do" :: instructions body) - :: List.map - ~f:(fun (tag, i, ty) -> - List - (Atom "catch" - :: index st.tag_names tag - :: instruction (Wa_ast.Br (i + 1, Some (Pop ty))))) - catches)) + @ List.map + ~f:(fun (tag, i, _ty) -> + List [ Atom "catch"; index st.tag_names tag; Atom (string_of_int i) ]) + catches + @ instructions body)) ] and instruction i = match i with