@@ -628,9 +628,9 @@ R"(#include <stdio.h>
628
628
ASR::TupleConstant_t *tup_c = ASR::down_cast<ASR::TupleConstant_t>(x.m_target );
629
629
std::string src_tmp = " " , val_name = " " ;
630
630
if (ASR::is_a<ASR::TupleConstant_t>(*x.m_value )) {
631
+ val_name = const_name + std::to_string (const_list_count);
631
632
self ().visit_TupleConstant (*ASR::down_cast<ASR::TupleConstant_t>(x.m_value ));
632
633
src_tmp += src;
633
- val_name = const_name;
634
634
} else if (ASR::is_a<ASR::FunctionCall_t>(*x.m_value )) {
635
635
self ().visit_FunctionCall (*ASR::down_cast<ASR::FunctionCall_t>(x.m_value ));
636
636
ASR::Tuple_t* t = ASR::down_cast<ASR::Tuple_t>(tup_c->m_type );
@@ -645,8 +645,10 @@ R"(#include <stdio.h>
645
645
val_name = src;
646
646
}
647
647
for (size_t i=0 ; i<tup_c->n_elements ; i++) {
648
- visit_Var (*ASR::down_cast<ASR::Var_t>(tup_c->m_elements [i]));
649
- src_tmp += indent + src + " = " + val_name + " .element_" + std::to_string (i) + " ;\n " ;
648
+ self ().visit_expr (*tup_c->m_elements [i]);
649
+ ASR::ttype_t *t = ASRUtils::expr_type (tup_c->m_elements [i]);
650
+ src_tmp += indent + c_ds_api->get_deepcopy (t,
651
+ val_name + " .element_" + std::to_string (i), src) + " \n " ;
650
652
}
651
653
src = src_tmp;
652
654
return ;
@@ -794,6 +796,7 @@ R"(#include <stdio.h>
794
796
const_name += std::to_string (const_list_count);
795
797
const_list_count += 1 ;
796
798
const_name = current_scope->get_unique_name (const_name);
799
+ std::string var_name = const_name;
797
800
ASR::Tuple_t* t = ASR::down_cast<ASR::Tuple_t>(x.m_type );
798
801
std::string tuple_type_c = c_ds_api->get_tuple_type (t);
799
802
std::string src_tmp = " " ;
@@ -802,11 +805,11 @@ R"(#include <stdio.h>
802
805
self ().visit_expr (*x.m_elements [i]);
803
806
std::string ele = " .element_" + std::to_string (i);
804
807
if (ASR::is_a<ASR::Character_t>(*t->m_type [i])) {
805
- src_tmp += indent + const_name + ele + " = (char*) malloc(40 * sizeof(char));\n " ;
808
+ src_tmp += indent + var_name + ele + " = (char*) malloc(40 * sizeof(char));\n " ;
806
809
}
807
- src_tmp += indent + c_ds_api->get_deepcopy (t->m_type [i], src, const_name + ele) + " \n " ;
810
+ src_tmp += indent + c_ds_api->get_deepcopy (t->m_type [i], src, var_name + ele) + " \n " ;
808
811
}
809
- src_tmp += indent + const_name + " .length" + " = " + std::to_string (x.n_elements ) + " ;\n " ;
812
+ src_tmp += indent + var_name + " .length" + " = " + std::to_string (x.n_elements ) + " ;\n " ;
810
813
src = src_tmp;
811
814
}
812
815
0 commit comments