Skip to content

Commit

Permalink
Encode multiple result types
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyalIcing committed Jul 29, 2024
1 parent 7c8be06 commit fdefecf
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/orb/to_wasm.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ defmodule Orb.ToWasm.Helpers do
def to_wasm_type(:f64), do: 0x7C
def to_wasm_type(:v128), do: 0x7B

def to_wasm_type(tuple) when is_tuple(tuple) do
[
0x7B,
leb128_u(tuple_size(tuple)),
tuple
|> Tuple.to_list()
|> Enum.map(&to_wasm_type/1)
]
end

def to_wasm_type(custom_type) when is_atom(custom_type) do
Orb.Ops.to_primitive_type(custom_type) |> to_wasm_type()
end
Expand Down

0 comments on commit fdefecf

Please sign in to comment.