PT-163478903 builtin bits type #508

Merged
zxq9 merged 5 commits from PT-163478903-builtin-bits-type into master 2019-01-28 18:05:10 +09:00
2 changed files with 5 additions and 2 deletions
Showing only changes of commit 3e1290efaf - Show all commits

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 }]);