From 3e1290efafc9f37869fdac9292b4e638b000fd8b Mon Sep 17 00:00:00 2001 From: Ulf Norell Date: Fri, 25 Jan 2019 14:12:23 +0100 Subject: [PATCH] Add Bits.all and rename Bits.zero to Bits.none --- src/aeso_ast_infer_types.erl | 3 ++- src/aeso_ast_to_icode.erl | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index 154e617..76e8d62 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -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)} diff --git a/src/aeso_ast_to_icode.erl b/src/aeso_ast_to_icode.erl index b9fb28f..a3a55aa 100644 --- a/src/aeso_ast_to_icode.erl +++ b/src/aeso_ast_to_icode.erl @@ -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 }]);