ZNFKFYBFLWN753DAGZODAGH4BN4OTKL275FUK372VY55XB6KC3WAC
L35LWKCNCAZIBB5JQXZJHGAM2PHAA3243FAEFB3QNNMHKIGMTE4QC
3BE42RZGZGKB6BMNUTRK3M64P6FZF6FBPK2S64DCQXYIY7VHNWCQC
2JXKNG3VODYXLJ3TINRQH3H7OG3XFV3HYWDTNJTIZNFOVIV6FGKAC
O2DTNJ3ZOJJKDHGPNE2DZSZF7CFU4G5D65RIDOYZHYYBH3JZAAIAC
AQQ7DH2OU4OKCVRQECS427ICA4OAT5NLQBE4TLKFBJ3TAUMQHXKAC
ZR7U7TRCUHXMBXQFA3XXNGJPPYFACMOWPQKGUH7E22KGFM35HSNAC
ISDVVVJ4Q47MFFMWYC3XP3KZXLAKRA2VGRQ56MSD44475UNYBWDAC
Q62EXKAKNM5FMIW3UZBUAJFKOZLE2O2VIRTJAVDOTTSWX5JSMX4QC
O4ZYFC2AQIWA75Q45T6USQPSR5HZDGFD45HO6IDZZRUJYS5VIQHQC
FVAVNSGB7J3BNE4ON22YS6DHW3B3XHCRBDB53LJSRCKFTELCVNAQC
BEUUKQVQ6TPUDVH74NCKA43MMPHOI5X5MF5UNR7WTCAST2HCMBJAC
SOZ4WS56EILALC6ZEAGGWVR3WM2T6NSD24T2KLWLWWV63FRWYLAQC
F7J2TR37FEVHXRP522LY6Q3PNL42H4I77QFPAK6ZLSCX7I2X4L7QC
EFKQM5UNVCK623Y6L2OBSBD4W3E6DHMDPMXORFLCSJGOXHKPAFHQC
F2TD63MB77RLDLPHPNCOYEMW7QSWV6BXXR27SC2Y2OY42CGUQIKAC
FJZWJHLW5B2JGYHKSHIYBRG2IVTLCPKT3SR2PWKDPCLRATYEXEQQC
defp get_section_type(0), do: :custom
defp get_section_type(1), do: :type
defp get_section_type(3), do: :function
defp get_section_type(4), do: :table
defp get_section_type(5), do: :memory
defp get_section_type(6), do: :global
defp get_section_type(7), do: :export
defp get_section_type(10), do: :code
def stream(data) do
Stream.resource(
fn -> {data, &parse/1} end,
fn
{"", _} = acc ->
{:halt, acc}
{data, parser} ->
case parser.(data) do
{:ok, {result, rest, next}} when is_list(result) ->
{result, {rest, next}}
{:ok, {result, rest, next}} ->
{[result], {rest, next}}
end
end,
fn _ -> nil end
)
vec(&valtype/1).(binary)
end
defp valtype(<<0x7F, rest::binary>>), do: {:i32, rest}
defp typeidx(binary) do
Atomic.u32(binary)
end
defp memidx(binary) do
Atomic.u32(binary)
end
defp globalidx(binary) do
Atomic.u32(binary)
end
defp funcidx(binary) do
Atomic.u32(binary)
end
defp localidx(binary) do
Atomic.u32(binary)
end
def stream(data) do
Stream.resource(
fn -> {data, &parse/1} end,
fn
{"", _} = acc ->
{:halt, acc}
{data, parser} ->
case parser.(data) do
{:ok, {result, rest, next}} when is_list(result) ->
{result, {rest, next}}
{:ok, {result, rest, next}} ->
{[result], {rest, next}}
end
end,
fn _ -> nil end
)