Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
vouillon committed Aug 20, 2024
1 parent fc651d6 commit d7a52fa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
17 changes: 11 additions & 6 deletions compiler/lib/wasm/wa_gc_target.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1702,13 +1702,18 @@ let handle_exceptions ~result_typ ~fall_through ~context body x exn_handler =
(block_expr
{ params = []; result = [ Value.value ] }
(let* exn =
try_expr
block_expr
{ params = []; result = [ externref ] }
(body
~result_typ:[ externref ]
~fall_through:(`Block (-1))
~context:(`Skip :: `Skip :: context))
[ ocaml_tag, 1, Value.value; js_tag, 0, externref ]
(let* e =
try_expr
{ params = []; result = [ externref ] }
(body
~result_typ:[ externref ]
~fall_through:(`Block (-1))
~context:(`Skip :: `Skip :: `Skip :: context))
[ ocaml_tag, 1, Value.value; js_tag, 0, externref ]
in
instr (W.Push e))
in
instr (W.CallInstr (f, [ exn ]))))
in
Expand Down
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, 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 d7a52fa

Please sign in to comment.