@@ -152,17 +152,6 @@ static inline const ASR::symbol_t *symbol_get_past_external(const ASR::symbol_t
152152 }
153153}
154154
155- static inline ASR::ttype_t *type_get_past_const (ASR::ttype_t *f)
156- {
157- if (ASR::is_a<ASR::Const_t>(*f)) {
158- ASR::Const_t *e = ASR::down_cast<ASR::Const_t>(f);
159- LCOMPILERS_ASSERT (!ASR::is_a<ASR::Const_t>(*e->m_type ));
160- return e->m_type ;
161- } else {
162- return f;
163- }
164- }
165-
166155static inline ASR::ttype_t *type_get_past_pointer (ASR::ttype_t *f)
167156{
168157 if (ASR::is_a<ASR::Pointer_t>(*f)) {
@@ -227,9 +216,6 @@ static inline int extract_kind_from_ttype_t(const ASR::ttype_t* type) {
227216 case ASR::ttypeType::Allocatable: {
228217 return extract_kind_from_ttype_t (ASR::down_cast<ASR::Allocatable_t>(type)->m_type );
229218 }
230- case ASR::ttypeType::Const: {
231- return extract_kind_from_ttype_t (ASR::down_cast<ASR::Const_t>(type)->m_type );
232- }
233219 default : {
234220 return -1 ;
235221 }
@@ -277,10 +263,6 @@ static inline void set_kind_to_ttype_t(ASR::ttype_t* type, int kind) {
277263 set_kind_to_ttype_t (ASR::down_cast<ASR::Allocatable_t>(type)->m_type , kind);
278264 break ;
279265 }
280- case ASR::ttypeType::Const: {
281- set_kind_to_ttype_t (ASR::down_cast<ASR::Const_t>(type)->m_type , kind);
282- break ;
283- }
284266 default : {
285267 return ;
286268 }
@@ -392,10 +374,6 @@ static inline ASR::ttype_t* get_contained_type(ASR::ttype_t* asr_type, int overl
392374 ASR::Allocatable_t* pointer_asr = ASR::down_cast<ASR::Allocatable_t>(asr_type);
393375 return pointer_asr->m_type ;
394376 }
395- case ASR::ttypeType::Const: {
396- ASR::Const_t* const_asr = ASR::down_cast<ASR::Const_t>(asr_type);
397- return const_asr->m_type ;
398- }
399377 default : {
400378 return asr_type;
401379 }
@@ -602,10 +580,6 @@ static inline std::string type_to_str(const ASR::ttype_t *t)
602580 encode_dimensions (array_t ->n_dims , res, false );
603581 return res;
604582 }
605- case ASR::ttypeType::Const: {
606- return type_to_str (ASRUtils::get_contained_type (
607- const_cast <ASR::ttype_t *>(t))) + " const" ;
608- }
609583 case ASR::ttypeType::TypeParameter: {
610584 ASR::TypeParameter_t* tp = ASR::down_cast<ASR::TypeParameter_t>(t);
611585 return tp->m_param ;
@@ -660,10 +634,6 @@ static inline std::string type_to_str_with_substitution(const ASR::ttype_t *t,
660634 encode_dimensions (array_t ->n_dims , res, false );
661635 return res;
662636 }
663- case ASR::ttypeType::Const: {
664- return type_to_str_with_substitution (ASRUtils::get_contained_type (
665- const_cast <ASR::ttype_t *>(t)), subs) + " const" ;
666- }
667637 case ASR::ttypeType::FunctionType: {
668638 ASR::FunctionType_t* ftp = ASR::down_cast<ASR::FunctionType_t>(t);
669639 std::string result = " (" ;
@@ -1552,15 +1522,6 @@ static inline std::string get_type_code(const ASR::ttype_t *t, bool use_undersco
15521522 return " Allocatable[" + get_type_code (p->m_type , use_underscore_sep,
15531523 encode_dimensions_, set_dimensional_hint) + " ]" ;
15541524 }
1555- case ASR::ttypeType::Const: {
1556- ASR::Const_t* p = ASR::down_cast<ASR::Const_t>(t);
1557- if ( use_underscore_sep ) {
1558- return " Const_" + get_type_code (p->m_type , use_underscore_sep,
1559- encode_dimensions_, set_dimensional_hint) + " _" ;
1560- }
1561- return " Const[" + get_type_code (p->m_type , use_underscore_sep,
1562- encode_dimensions_, set_dimensional_hint) + " ]" ;
1563- }
15641525 case ASR::ttypeType::SymbolicExpression: {
15651526 return " S" ;
15661527 }
@@ -1694,10 +1655,6 @@ static inline std::string type_to_str_python(const ASR::ttype_t *t,
16941655 ASR::Allocatable_t* p = ASR::down_cast<ASR::Allocatable_t>(t);
16951656 return " Allocatable[" + type_to_str_python (p->m_type ) + " ]" ;
16961657 }
1697- case ASR::ttypeType::Const: {
1698- ASR::Const_t* p = ASR::down_cast<ASR::Const_t>(t);
1699- return " Const[" + type_to_str_python (p->m_type ) + " ]" ;
1700- }
17011658 case ASR::ttypeType::TypeParameter: {
17021659 ASR::TypeParameter_t *p = ASR::down_cast<ASR::TypeParameter_t>(t);
17031660 return p->m_param ;
@@ -2008,6 +1965,18 @@ bool use_overloaded_file_read_write(std::string &read_write, Vec<ASR::expr_t*> a
20081965
20091966void set_intrinsic (ASR::symbol_t * sym);
20101967
1968+ static inline bool is_const (ASR::expr_t *x) {
1969+ if (ASR::is_a<ASR::Var_t>(*x)) {
1970+ ASR::Var_t* v = ASR::down_cast<ASR::Var_t>(x);
1971+ ASR::symbol_t * sym = ASRUtils::symbol_get_past_external (v->m_v );
1972+ if (sym && ASR::is_a<ASR::Variable_t>(*sym)) {
1973+ ASR::Variable_t* var = ASR::down_cast<ASR::Variable_t>(sym);
1974+ return var->m_storage == ASR::storage_typeType::Parameter;
1975+ }
1976+ }
1977+ return false ;
1978+ }
1979+
20111980static inline bool is_pointer (ASR::ttype_t *x) {
20121981 return ASR::is_a<ASR::Pointer_t>(*x);
20131982}
@@ -2020,10 +1989,9 @@ static inline bool is_integer(ASR::ttype_t &x) {
20201989 // type_get_past_pointer(
20211990 // type_get_past_const(&x))))));
20221991 return ASR::is_a<ASR::Integer_t>(
2023- *type_get_past_const (
2024- type_get_past_array (
1992+ *type_get_past_array (
20251993 type_get_past_allocatable (
2026- type_get_past_pointer (&x))))) ;
1994+ type_get_past_pointer (&x))));
20271995}
20281996
20291997static inline bool is_unsigned_integer (ASR::ttype_t &x) {
@@ -2174,10 +2142,6 @@ inline size_t extract_dimensions_from_ttype(ASR::ttype_t *x,
21742142 n_dims = extract_dimensions_from_ttype (ASR::down_cast<ASR::Allocatable_t>(x)->m_type , m_dims);
21752143 break ;
21762144 }
2177- case ASR::ttypeType::Const: {
2178- n_dims = extract_dimensions_from_ttype (ASR::down_cast<ASR::Const_t>(x)->m_type , m_dims);
2179- break ;
2180- }
21812145 case ASR::ttypeType::SymbolicExpression:
21822146 case ASR::ttypeType::Integer:
21832147 case ASR::ttypeType::UnsignedInteger:
@@ -2476,9 +2440,6 @@ inline bool is_array(ASR::ttype_t *x) {
24762440}
24772441
24782442static inline bool is_aggregate_type (ASR::ttype_t * asr_type) {
2479- if ( ASR::is_a<ASR::Const_t>(*asr_type) ) {
2480- asr_type = ASR::down_cast<ASR::Const_t>(asr_type)->m_type ;
2481- }
24822443 return ASRUtils::is_array (asr_type) ||
24832444 !(ASR::is_a<ASR::Integer_t>(*asr_type) ||
24842445 ASR::is_a<ASR::UnsignedInteger_t>(*asr_type) ||
@@ -2581,12 +2542,6 @@ static inline ASR::ttype_t* duplicate_type(Allocator& al, const ASR::ttype_t* t,
25812542 ASR::CPtr_t* ptr = ASR::down_cast<ASR::CPtr_t>(t);
25822543 return ASRUtils::TYPE (ASR::make_CPtr_t (al, ptr->base .base .loc ));
25832544 }
2584- case ASR::ttypeType::Const: {
2585- ASR::Const_t* c = ASR::down_cast<ASR::Const_t>(t);
2586- ASR::ttype_t * dup_type = duplicate_type (al, c->m_type , dims);
2587- return ASRUtils::TYPE (ASR::make_Const_t (al, c->base .base .loc ,
2588- dup_type));
2589- }
25902545 case ASR::ttypeType::List: {
25912546 ASR::List_t* l = ASR::down_cast<ASR::List_t>(t);
25922547 ASR::ttype_t * dup_type = duplicate_type (al, l->m_type );
@@ -3442,11 +3397,6 @@ inline bool check_equal_type(ASR::ttype_t* x, ASR::ttype_t* y, bool check_for_di
34423397 x = ASRUtils::type_get_past_allocatable (x);
34433398 y = ASRUtils::type_get_past_allocatable (y);
34443399 return check_equal_type (x, y);
3445- } else if (ASR::is_a<ASR::Const_t>(*x) ||
3446- ASR::is_a<ASR::Const_t>(*y)) {
3447- x = ASRUtils::get_contained_type (x);
3448- y = ASRUtils::get_contained_type (y);
3449- return check_equal_type (x, y);
34503400 } else if (ASR::is_a<ASR::List_t>(*x) && ASR::is_a<ASR::List_t>(*y)) {
34513401 x = ASR::down_cast<ASR::List_t>(x)->m_type ;
34523402 y = ASR::down_cast<ASR::List_t>(y)->m_type ;
@@ -5189,9 +5139,9 @@ static inline void Call_t_body(Allocator& al, ASR::symbol_t* a_name,
51895139 }
51905140 if ( ASRUtils::is_array (arg_type) && ASRUtils::is_array (orig_arg_type) ) {
51915141 ASR::Array_t* arg_array_t = ASR::down_cast<ASR::Array_t>(
5192- ASRUtils::type_get_past_pointer (ASRUtils::type_get_past_const ( arg_type) ));
5142+ ASRUtils::type_get_past_pointer (arg_type));
51935143 ASR::Array_t* orig_arg_array_t = ASR::down_cast<ASR::Array_t>(
5194- ASRUtils::type_get_past_pointer (ASRUtils::type_get_past_const ( orig_arg_type) ));
5144+ ASRUtils::type_get_past_pointer (orig_arg_type));
51955145 if ( (arg_array_t ->m_physical_type != orig_arg_array_t ->m_physical_type ) ||
51965146 (arg_array_t ->m_physical_type == ASR::array_physical_typeType::DescriptorArray &&
51975147 arg_array_t ->m_physical_type == orig_arg_array_t ->m_physical_type &&
0 commit comments