Skip to content

Commit ef52c30

Browse files
committed
ASRUtils: Define is_const()
1 parent 0d2bdc5 commit ef52c30

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/libasr/asr_utils.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,6 +1965,18 @@ bool use_overloaded_file_read_write(std::string &read_write, Vec<ASR::expr_t*> a
19651965

19661966
void set_intrinsic(ASR::symbol_t* sym);
19671967

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+
19681980
static inline bool is_pointer(ASR::ttype_t *x) {
19691981
return ASR::is_a<ASR::Pointer_t>(*x);
19701982
}

0 commit comments

Comments
 (0)