@@ -842,6 +842,11 @@ static inline bool extract_value(ASR::expr_t* value_expr, T& value) {
842842 value = (T) const_int->m_n ;
843843 break ;
844844 }
845+ case ASR::exprType::UnsignedIntegerConstant: {
846+ ASR::UnsignedIntegerConstant_t* const_int = ASR::down_cast<ASR::UnsignedIntegerConstant_t>(value_expr);
847+ value = (T) const_int->m_n ;
848+ break ;
849+ }
845850 case ASR::exprType::RealConstant: {
846851 ASR::RealConstant_t* const_real = ASR::down_cast<ASR::RealConstant_t>(value_expr);
847852 value = (T) const_real->m_r ;
@@ -924,6 +929,16 @@ static inline std::string get_type_code(const ASR::ttype_t *t, bool use_undersco
924929 is_dimensional = integer->n_dims > 0 ;
925930 break ;
926931 }
932+ case ASR::ttypeType::UnsignedInteger: {
933+ ASR::UnsignedInteger_t *integer = ASR::down_cast<ASR::UnsignedInteger_t>(t);
934+ res = " u" + std::to_string (integer->m_kind * 8 );
935+ if ( encode_dimensions_ ) {
936+ encode_dimensions (integer->n_dims , res, use_underscore_sep);
937+ return res;
938+ }
939+ is_dimensional = integer->n_dims > 0 ;
940+ break ;
941+ }
927942 case ASR::ttypeType::Real: {
928943 ASR::Real_t *real = ASR::down_cast<ASR::Real_t>(t);
929944 res = " r" + std::to_string (real->m_kind * 8 );
@@ -1090,7 +1105,7 @@ static inline std::string type_to_str_python(const ASR::ttype_t *t,
10901105{
10911106 switch (t->type ) {
10921107 case ASR::ttypeType::Integer: {
1093- ASR::Integer_t *i = ( ASR::Integer_t*)t ;
1108+ ASR::Integer_t *i = ASR::down_cast<ASR:: Integer_t>(t) ;
10941109 std::string res = " " ;
10951110 switch (i->m_kind ) {
10961111 case 1 : { res = " i8" ; break ; }
@@ -1104,6 +1119,21 @@ static inline std::string type_to_str_python(const ASR::ttype_t *t,
11041119 }
11051120 return res;
11061121 }
1122+ case ASR::ttypeType::UnsignedInteger: {
1123+ ASR::UnsignedInteger_t *i = ASR::down_cast<ASR::UnsignedInteger_t>(t);
1124+ std::string res = " " ;
1125+ switch (i->m_kind ) {
1126+ case 1 : { res = " u8" ; break ; }
1127+ case 2 : { res = " u16" ; break ; }
1128+ case 4 : { res = " u32" ; break ; }
1129+ case 8 : { res = " u64" ; break ; }
1130+ default : { throw LCompilersException (" UnsignedInteger kind not supported" ); }
1131+ }
1132+ if (i->n_dims == 1 && for_error_message) {
1133+ res = type_python_1dim_helper (res, i->m_dims );
1134+ }
1135+ return res;
1136+ }
11071137 case ASR::ttypeType::Real: {
11081138 ASR::Real_t *r = (ASR::Real_t*)t;
11091139 std::string res = " " ;
@@ -1374,6 +1404,9 @@ static inline int extract_kind_from_ttype_t(const ASR::ttype_t* type) {
13741404 case ASR::ttypeType::Integer : {
13751405 return ASR::down_cast<ASR::Integer_t>(type)->m_kind ;
13761406 }
1407+ case ASR::ttypeType::UnsignedInteger : {
1408+ return ASR::down_cast<ASR::UnsignedInteger_t>(type)->m_kind ;
1409+ }
13771410 case ASR::ttypeType::Real : {
13781411 return ASR::down_cast<ASR::Real_t>(type)->m_kind ;
13791412 }
@@ -1406,6 +1439,10 @@ static inline bool is_integer(ASR::ttype_t &x) {
14061439 return ASR::is_a<ASR::Integer_t>(*type_get_past_pointer (&x));
14071440}
14081441
1442+ static inline bool is_unsigned_integer (ASR::ttype_t &x) {
1443+ return ASR::is_a<ASR::UnsignedInteger_t>(*type_get_past_pointer (&x));
1444+ }
1445+
14091446static inline bool is_real (ASR::ttype_t &x) {
14101447 return ASR::is_a<ASR::Real_t>(*type_get_past_pointer (&x));
14111448}
@@ -1485,6 +1522,12 @@ inline int extract_dimensions_from_ttype(ASR::ttype_t *x,
14851522 m_dims = Integer_type->m_dims ;
14861523 break ;
14871524 }
1525+ case ASR::ttypeType::UnsignedInteger: {
1526+ ASR::UnsignedInteger_t* Integer_type = ASR::down_cast<ASR::UnsignedInteger_t>(x);
1527+ n_dims = Integer_type->n_dims ;
1528+ m_dims = Integer_type->m_dims ;
1529+ break ;
1530+ }
14881531 case ASR::ttypeType::Real: {
14891532 ASR::Real_t* Real_type = ASR::down_cast<ASR::Real_t>(x);
14901533 n_dims = Real_type->n_dims ;
@@ -2122,6 +2165,22 @@ inline bool types_equal(ASR::ttype_t *a, ASR::ttype_t *b,
21222165 }
21232166 break ;
21242167 }
2168+ case (ASR::ttypeType::UnsignedInteger) : {
2169+ ASR::UnsignedInteger_t *a2 = ASR::down_cast<ASR::UnsignedInteger_t>(a);
2170+ ASR::UnsignedInteger_t *b2 = ASR::down_cast<ASR::UnsignedInteger_t>(b);
2171+ if (a2->m_kind == b2->m_kind ) {
2172+ if ( check_for_dimensions ) {
2173+ return ASRUtils::dimensions_equal (
2174+ a2->m_dims , a2->n_dims ,
2175+ b2->m_dims , b2->n_dims );
2176+ } else {
2177+ return true ;
2178+ }
2179+ } else {
2180+ return false ;
2181+ }
2182+ break ;
2183+ }
21252184 case ASR::ttypeType::CPtr: {
21262185 return true ;
21272186 }
0 commit comments