Skip to content

Commit

Permalink
C_CPP: Return value instead of pointer in list_concat
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaikh-Ubaid committed Jul 30, 2023
1 parent 8fa1ef4 commit dec343f
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/libasr/codegen/asr_to_c_cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1308,11 +1308,7 @@ PyMODINIT_FUNC PyInit_lpython_module_)" + fn_name + R"((void) {
if( is_target_list && is_value_list ) {
ASR::List_t* list_target = ASR::down_cast<ASR::List_t>(ASRUtils::expr_type(x.m_target));
std::string list_dc_func = c_ds_api->get_list_deepcopy_func(list_target);
if (ASR::is_a<ASR::ListConcat_t>(*x.m_value)) {
src += indent + list_dc_func + "(" + value + ", &" + target + ");\n\n";
} else {
src += indent + list_dc_func + "(&" + value + ", &" + target + ");\n\n";
}
src += indent + list_dc_func + "(&" + value + ", &" + target + ");\n\n";
} else if ( is_target_tup && is_value_tup ) {
ASR::Tuple_t* tup_target = ASR::down_cast<ASR::Tuple_t>(ASRUtils::expr_type(x.m_target));
std::string dc_func = c_ds_api->get_tuple_deepcopy_func(tup_target);
Expand Down Expand Up @@ -1565,17 +1561,11 @@ PyMODINIT_FUNC PyInit_lpython_module_)" + fn_name + R"((void) {
bracket_open++;
self().visit_expr(*x.m_left);
std::string left = std::move(src);
if (!ASR::is_a<ASR::ListConcat_t>(*x.m_left)) {
left = "&" + left;
}
self().visit_expr(*x.m_right);
bracket_open--;
std::string rig = std::move(src);
if (!ASR::is_a<ASR::ListConcat_t>(*x.m_right)) {
rig = "&" + rig;
}
tmp_buffer_src.push_back(check_tmp_buffer());
src = list_concat_func + "(" + left + ", " + rig + ")";
src = "(*" + list_concat_func + "(&" + left + ", &" + rig + "))";
}

void visit_ListSection(const ASR::ListSection_t& x) {
Expand Down

0 comments on commit dec343f

Please sign in to comment.