Handle encoding/decoding bits

Fixes GH-174
This commit is contained in:
Ulf Norell
2019-11-18 11:35:08 +01:00
parent 422baa5b65
commit baf527b5fa
4 changed files with 75 additions and 17 deletions
+12
View File
@@ -261,6 +261,18 @@ term_to_fate({tuple, As}) ->
term_to_fate({con, Ar, I, As}) ->
FateAs = [ term_to_fate(A) || A <- As ],
aeb_fate_data:make_variant(Ar, I, list_to_tuple(FateAs));
term_to_fate({builtin, bits_all, []}) ->
aeb_fate_data:make_bits(-1);
term_to_fate({builtin, bits_none, []}) ->
aeb_fate_data:make_bits(0);
term_to_fate({op, bits_set, [B, I]}) ->
{bits, N} = term_to_fate(B),
J = term_to_fate(I),
{bits, N bor (1 bsl J)};
term_to_fate({op, bits_clear, [B, I]}) ->
{bits, N} = term_to_fate(B),
J = term_to_fate(I),
{bits, N band bnot (1 bsl J)};
term_to_fate({builtin, map_empty, []}) ->
aeb_fate_data:make_map(#{});
term_to_fate({'let', _, {builtin, map_empty, []}, Set}) ->