Skip to content

Commit 6d2cafb

Browse files
committed
Emit try_table instruction
1 parent dbda159 commit 6d2cafb

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

compiler/lib/wasm/wa_wat_output.ml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -480,16 +480,13 @@ let expression_or_instructions ctx st in_function =
480480
]
481481
| Try (ty, body, catches) ->
482482
[ List
483-
(Atom "try"
483+
(Atom "try_table"
484484
:: (block_type st ty
485-
@ List (Atom "do" :: instructions body)
486-
:: List.map
487-
~f:(fun (tag, i, ty) ->
488-
List
489-
(Atom "catch"
490-
:: index st.tag_names tag
491-
:: instruction (Wa_ast.Br (i + 1, Some (Pop ty)))))
492-
catches))
485+
@ List.map
486+
~f:(fun (tag, i, _ty) ->
487+
List [ Atom "catch"; index st.tag_names tag; Atom (string_of_int i) ])
488+
catches
489+
@ instructions body))
493490
]
494491
and instruction i =
495492
match i with

0 commit comments

Comments
 (0)