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 Aug 20, 2024
1 parent dbda159 commit 6d2cafb
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 @@ -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
Expand Down

0 comments on commit 6d2cafb

Please sign in to comment.