@@ -561,6 +561,7 @@ class ReplaceSymbolicVisitor : public PassUtils::PassVisitor<ReplaceSymbolicVisi
561
561
if (ASR::is_a<ASR::Var_t>(*x.m_target )) {
562
562
ASR::symbol_t *v = ASR::down_cast<ASR::Var_t>(x.m_target )->m_v ;
563
563
if (ASR::is_a<ASR::Variable_t>(*v)) {
564
+ // Step1: Add the placeholder for the list variable to the scope
564
565
ASRUtils::ASRBuilder b (al, x.base .base .loc );
565
566
ASR::ttype_t * CPtr_type = ASRUtils::TYPE (ASR::make_CPtr_t (al, x.base .base .loc ));
566
567
ASR::ttype_t * list_type = ASRUtils::TYPE (ASR::make_List_t (al, x.base .base .loc , CPtr_type));
@@ -594,11 +595,13 @@ class ReplaceSymbolicVisitor : public PassUtils::PassVisitor<ReplaceSymbolicVisi
594
595
ASR::stmt_t * stmt1 = ASRUtils::STMT (ASR::make_Assignment_t (al, x.base .base .loc , placeholder_target, temp_list_const1, nullptr ));
595
596
pass_result.push_back (al, stmt1);
596
597
598
+ // Step2: Add the empty list variable
597
599
ASR::expr_t * temp_list_const2 = ASRUtils::EXPR (ASR::make_ListConstant_t (al, x.base .base .loc , temp_list2.p ,
598
600
temp_list2.size (), list_type));
599
601
ASR::stmt_t * stmt2 = ASRUtils::STMT (ASR::make_Assignment_t (al, x.base .base .loc , x.m_target , temp_list_const2, nullptr ));
600
602
pass_result.push_back (al, stmt2);
601
603
604
+ // Step3: Add the list index to the function scope
602
605
std::string symbolic_list_index = current_scope->get_unique_name (" symbolic_list_index" );
603
606
ASR::ttype_t * int32_type = ASRUtils::TYPE (ASR::make_Integer_t (al, x.base .base .loc , 4 ));
604
607
ASR::symbol_t * index_sym = ASR::down_cast<ASR::symbol_t >(
@@ -611,6 +614,7 @@ class ReplaceSymbolicVisitor : public PassUtils::PassVisitor<ReplaceSymbolicVisi
611
614
ASRUtils::EXPR (ASR::make_IntegerConstant_t (al, x.base .base .loc , 0 , int32_type)), nullptr ));
612
615
pass_result.push_back (al, stmt3);
613
616
617
+ // Step4: Add the DoLoop for appending elements into the list
614
618
std::string block_name = current_scope->get_unique_name (" block" );
615
619
SymbolTable* block_symtab = al.make_new <SymbolTable>(current_scope);
616
620
char *tmp_var_name = s2c (al, " tmp" );
0 commit comments