@@ -7473,6 +7473,26 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
74737473 ASR::ttype_t *type = ASRUtils::TYPE (ASR::make_Pointer_t (al, x.base .base .loc , type_));
74747474 tmp = ASR::make_GetPointer_t (al, x.base .base .loc , args[0 ].m_value , type, nullptr );
74757475 return ;
7476+ } else if ( call_name.substr (0 , 6 ) == " bitnot" ) {
7477+ parse_args (x, args);
7478+ if (args.size () != 1 ) {
7479+ throw SemanticError (call_name + " () expects one argument, provided " + std::to_string (args.size ()), x.base .base .loc );
7480+ }
7481+ ASR::expr_t * operand = args[0 ].m_value ;
7482+ ASR::ttype_t *operand_type = ASRUtils::expr_type (operand);
7483+ ASR::expr_t * value = nullptr ;
7484+ if (!ASR::is_a<ASR::UnsignedInteger_t>(*operand_type)) {
7485+ throw SemanticError (call_name + " () expects unsigned integer, provided" + ASRUtils::type_to_str_python (operand_type), x.base .base .loc );
7486+ }
7487+ if (ASRUtils::expr_value (operand) != nullptr ) {
7488+ int64_t op_value = ASR::down_cast<ASR::UnsignedIntegerConstant_t>(
7489+ ASRUtils::expr_value (operand))->m_n ;
7490+ uint64_t val = ~uint64_t (op_value);
7491+ value = ASR::down_cast<ASR::expr_t >(ASR::make_UnsignedIntegerConstant_t (
7492+ al, x.base .base .loc , val, operand_type));
7493+ }
7494+ tmp = ASR::make_UnsignedIntegerBitNot_t (al, x.base .base .loc , operand, operand_type, value);
7495+ return ;
74767496 } else if ( call_name == " array" ) {
74777497 parse_args (x, args);
74787498 if ( args.size () != 1 ) {
0 commit comments