Skip to content

Commit

Permalink
Emit try_table instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
vouillon committed Sep 11, 2024
1 parent 88acffc commit a9799d5
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions compiler/lib/wasm/wa_wat_output.ml
Original file line number Diff line number Diff line change
Expand Up @@ -478,16 +478,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
Expand Down

0 comments on commit a9799d5

Please sign in to comment.