@@ -647,9 +647,10 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
647
647
}
648
648
649
649
using namespace wasm ;
650
- int kind = ASRUtils::extract_kind_from_ttype_t (v->m_type );
651
650
uint32_t global_var_idx = UINT_MAX;
652
- ASR::ttype_t * v_m_type = ASRUtils::type_get_past_array (v->m_type );
651
+ ASR::ttype_t * ttype = ASRUtils::type_get_past_const (v->m_type );
652
+ ASR::ttype_t * v_m_type = ASRUtils::type_get_past_array (ttype);
653
+ int kind = ASRUtils::extract_kind_from_ttype_t (ttype);
653
654
switch (v_m_type->type ){
654
655
case ASR::ttypeType::Integer: {
655
656
uint64_t init_val = 0 ;
@@ -877,9 +878,11 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
877
878
throw CodeGenAbort ();
878
879
}
879
880
} else {
880
- if (ASRUtils::is_integer (*v->m_type )) {
881
+ ASR::ttype_t * ttype = v->m_type ;
882
+ ttype = ASRUtils::type_get_past_const (ttype);
883
+ if (ASRUtils::is_integer (*ttype)) {
881
884
ASR::Integer_t *v_int =
882
- ASR::down_cast<ASR::Integer_t>(ASRUtils::type_get_past_array (v-> m_type ));
885
+ ASR::down_cast<ASR::Integer_t>(ASRUtils::type_get_past_array (ttype ));
883
886
if (is_array) {
884
887
type_vec.push_back (i32);
885
888
} else {
@@ -892,9 +895,9 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
892
895
" Integers of kind 4 and 8 only supported" );
893
896
}
894
897
}
895
- } else if (ASRUtils::is_real (*v-> m_type )) {
898
+ } else if (ASRUtils::is_real (*ttype )) {
896
899
ASR::Real_t *v_float = ASR::down_cast<ASR::Real_t>(
897
- ASRUtils::type_get_past_array (v-> m_type ));
900
+ ASRUtils::type_get_past_array (ttype ));
898
901
899
902
if (is_array) {
900
903
type_vec.push_back (i32);
@@ -908,10 +911,10 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
908
911
" Floating Points of kind 4 and 8 only supported" );
909
912
}
910
913
}
911
- } else if (ASRUtils::is_logical (*v-> m_type )) {
914
+ } else if (ASRUtils::is_logical (*ttype )) {
912
915
ASR::Logical_t *v_logical =
913
916
ASR::down_cast<ASR::Logical_t>(
914
- ASRUtils::type_get_past_array (v-> m_type ));
917
+ ASRUtils::type_get_past_array (ttype ));
915
918
916
919
if (is_array) {
917
920
type_vec.push_back (i32);
@@ -923,10 +926,10 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
923
926
throw CodeGenError (" Logicals of kind 4 only supported" );
924
927
}
925
928
}
926
- } else if (ASRUtils::is_character (*v-> m_type )) {
929
+ } else if (ASRUtils::is_character (*ttype )) {
927
930
ASR::Character_t *v_int =
928
931
ASR::down_cast<ASR::Character_t>(
929
- ASRUtils::type_get_past_array (v-> m_type ));
932
+ ASRUtils::type_get_past_array (ttype ));
930
933
931
934
if (is_array) {
932
935
type_vec.push_back (i32);
@@ -941,10 +944,10 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
941
944
" Characters of kind 1 only supported" );
942
945
}
943
946
}
944
- } else if (ASRUtils::is_complex (*v-> m_type )) {
947
+ } else if (ASRUtils::is_complex (*ttype )) {
945
948
ASR::Complex_t *v_comp =
946
949
ASR::down_cast<ASR::Complex_t>(
947
- ASRUtils::type_get_past_array (v-> m_type ));
950
+ ASRUtils::type_get_past_array (ttype ));
948
951
949
952
if (is_array) {
950
953
type_vec.push_back (i32);
@@ -2132,7 +2135,9 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
2132
2135
void visit_Var (const ASR::Var_t &x) {
2133
2136
const ASR::symbol_t *s = ASRUtils::symbol_get_past_external (x.m_v );
2134
2137
auto v = ASR::down_cast<ASR::Variable_t>(s);
2135
- switch (ASRUtils::type_get_past_array (v->m_type )->type ) {
2138
+ ASR::ttype_t * ttype = ASRUtils::type_get_past_array (v->m_type );
2139
+ ttype = ASRUtils::type_get_past_const (ttype);
2140
+ switch (ttype->type ) {
2136
2141
case ASR::ttypeType::Integer:
2137
2142
case ASR::ttypeType::Logical:
2138
2143
case ASR::ttypeType::Real:
@@ -2263,7 +2268,7 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
2263
2268
2264
2269
void visit_IntegerConstant (const ASR::IntegerConstant_t &x) {
2265
2270
int64_t val = x.m_n ;
2266
- int a_kind = ((ASR::Integer_t *)(&( x.m_type -> base )))-> m_kind ;
2271
+ int a_kind = ASRUtils::extract_kind_from_ttype_t ( x.m_type ) ;
2267
2272
switch (a_kind) {
2268
2273
case 4 : {
2269
2274
m_wa.emit_i32_const (val);
@@ -2940,6 +2945,7 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
2940
2945
}
2941
2946
ASR::expr_t *v = x.m_values [i];
2942
2947
ASR::ttype_t *t = ASRUtils::expr_type (v);
2948
+ t = ASRUtils::type_get_past_const (t);
2943
2949
int a_kind = ASRUtils::extract_kind_from_ttype_t (t);
2944
2950
2945
2951
if (ASRUtils::is_integer (*t) || ASRUtils::is_logical (*t)) {
0 commit comments