Skip to content

Commit c73a309

Browse files
Smit-createczgdp1807
authored andcommitted
Use c_utils get_deepcopy
1 parent 5fe5db1 commit c73a309

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

src/libasr/codegen/asr_to_c_cpp.h

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ class BaseCCPPVisitor : public ASR::BaseVisitor<Struct>
9494
template_number{0}, c_ds_api{std::make_unique<CCPPDSUtils>()},
9595
const_name{"constname"},
9696
const_list_count{0}, is_string_concat_present{false} {
97-
if( is_c ) {
98-
c_ds_api->set_deepcopy_function(&CUtils::deepcopy);
99-
} else {
100-
c_ds_api->set_deepcopy_function(&CPPUtils::deepcopy);
101-
}
10297
}
10398

10499
void visit_TranslationUnit(const ASR::TranslationUnit_t &x) {
@@ -706,9 +701,9 @@ R"(#include <stdio.h>
706701
alloc = indent + target + " = " + "(char *) malloc((strlen(" +
707702
value + ") + 1 ) * sizeof(char));\n";
708703
}
709-
src += alloc + indent + CUtils::deepcopy(target, value, m_target_type) + "\n";
704+
src += alloc + indent + c_ds_api->get_deepcopy(m_target_type, value, target) + "\n";
710705
} else {
711-
src += indent + CPPUtils::deepcopy(target, value, m_target_type) + "\n";
706+
src += indent + c_ds_api->get_deepcopy(m_target_type, value, target) + "\n";
712707
}
713708
}
714709
from_std_vector_helper.clear();
@@ -779,11 +774,8 @@ R"(#include <stdio.h>
779774
if( ASR::is_a<ASR::Character_t>(*t->m_type) ) {
780775
src_tmp += const_name + ".data[" + std::to_string(i) +"] = (char*) malloc(40 * sizeof(char));\n";
781776
}
782-
if( is_c ) {
783-
src_tmp += indent + CUtils::deepcopy(const_name + ".data[" + std::to_string(i) +"]", src, t->m_type) + "\n";
784-
} else {
785-
src_tmp += indent + CPPUtils::deepcopy(const_name + ".data[" + std::to_string(i) +"]", src, t->m_type) + "\n";
786-
}
777+
src_tmp += indent + c_ds_api->get_deepcopy(t->m_type, src,
778+
const_name + ".data[" + std::to_string(i) +"]") + "\n";
787779
}
788780
src_tmp += indent + const_name + ".current_end_point = " + std::to_string(x.n_args) + ";\n";
789781
src = src_tmp;
@@ -805,11 +797,7 @@ R"(#include <stdio.h>
805797
if (ASR::is_a<ASR::Character_t>(*t->m_type[i])) {
806798
src_tmp += indent + const_name + ele + " = (char*) malloc(40 * sizeof(char));\n";
807799
}
808-
if (is_c) {
809-
src_tmp += indent + CUtils::deepcopy(const_name + ele , src, t->m_type[i]) + "\n";
810-
} else {
811-
src_tmp += indent + CPPUtils::deepcopy(const_name + ele, src, t->m_type[i]) + "\n";
812-
}
800+
src_tmp += indent + c_ds_api->get_deepcopy(t->m_type[i], src, const_name + ele) + "\n";
813801
}
814802
src_tmp += indent + const_name + ".length" + " = " + std::to_string(x.n_elements) + ";\n";
815803
src = src_tmp;

0 commit comments

Comments
 (0)