end
defp section_body(:export, binary) do
vec(&export/1).(binary)
end
defp export(binary) do
{name, rest} = name(binary)
{export_desc, rest} = exportdesc(rest)
{{name, export_desc}, rest}
end
defp name(binary) do
{nm, rest} = vec(&byte/1).(binary)
{List.to_string(nm), rest}
end
defp byte(<<b, rest::binary>>) do
{b, rest}
end
defp exportdesc(<<0x00, rest::binary>>) do
{fun, rest} = funcidx(rest)
{{:func, fun}, rest}
end
defp exportdesc(<<0x02, rest::binary>>) do
{mem, rest} = memidx(rest)
{{:mem, mem}, rest}
end
defp exportdesc(<<0x03, rest::binary>>) do
{glob, rest} = globalidx(rest)
{{:global, glob}, rest}