Add Bits.all and rename Bits.zero to Bits.none

This commit is contained in:
Ulf Norell 2019-01-25 14:12:23 +01:00
parent 9c77622c7c
commit 3e1290efaf
2 changed files with 5 additions and 2 deletions

View File

@ -168,7 +168,8 @@ global_env() ->
{["Bits", "intersection"], Fun([Bits, Bits], Bits)},
{["Bits", "union"], Fun([Bits, Bits], Bits)},
{["Bits", "difference"], Fun([Bits, Bits], Bits)},
{["Bits", "zero"], Bits},
{["Bits", "none"], Bits},
{["Bits", "all"], Bits},
%% Conversion
{["Int", "to_str"], Fun1(Int, String)},
{["Address", "to_str"], Fun1(Address, String)}

View File

@ -368,8 +368,10 @@ ast_body(?qid_app(["Bits", Fun], Args, _, _), Icode)
["intersection", A, B] -> And(A, B);
["difference", A, B] -> And(A, Neg(And(A, B)))
end;
ast_body({qid, _, ["Bits", "zero"]}, _Icode) ->
ast_body({qid, _, ["Bits", "none"]}, _Icode) ->
#integer{ value = 0 };
ast_body({qid, _, ["Bits", "all"]}, _Icode) ->
#integer{ value = -1 };
ast_body(?qid_app(["Bits", "sum"], [Bits], _, _), Icode) ->
builtin_call(popcount, [ast_body(Bits, Icode), #integer{ value = 0 }]);