@@ -561,6 +561,7 @@ class ReplaceSymbolicVisitor : public PassUtils::PassVisitor<ReplaceSymbolicVisi
561561 if (ASR::is_a<ASR::Var_t>(*x.m_target )) {
562562 ASR::symbol_t *v = ASR::down_cast<ASR::Var_t>(x.m_target )->m_v ;
563563 if (ASR::is_a<ASR::Variable_t>(*v)) {
564+ // Step1: Add the placeholder for the list variable to the scope
564565 ASRUtils::ASRBuilder b (al, x.base .base .loc );
565566 ASR::ttype_t * CPtr_type = ASRUtils::TYPE (ASR::make_CPtr_t (al, x.base .base .loc ));
566567 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
594595 ASR::stmt_t * stmt1 = ASRUtils::STMT (ASR::make_Assignment_t (al, x.base .base .loc , placeholder_target, temp_list_const1, nullptr ));
595596 pass_result.push_back (al, stmt1);
596597
598+ // Step2: Add the empty list variable
597599 ASR::expr_t * temp_list_const2 = ASRUtils::EXPR (ASR::make_ListConstant_t (al, x.base .base .loc , temp_list2.p ,
598600 temp_list2.size (), list_type));
599601 ASR::stmt_t * stmt2 = ASRUtils::STMT (ASR::make_Assignment_t (al, x.base .base .loc , x.m_target , temp_list_const2, nullptr ));
600602 pass_result.push_back (al, stmt2);
601603
604+ // Step3: Add the list index to the function scope
602605 std::string symbolic_list_index = current_scope->get_unique_name (" symbolic_list_index" );
603606 ASR::ttype_t * int32_type = ASRUtils::TYPE (ASR::make_Integer_t (al, x.base .base .loc , 4 ));
604607 ASR::symbol_t * index_sym = ASR::down_cast<ASR::symbol_t >(
@@ -611,6 +614,7 @@ class ReplaceSymbolicVisitor : public PassUtils::PassVisitor<ReplaceSymbolicVisi
611614 ASRUtils::EXPR (ASR::make_IntegerConstant_t (al, x.base .base .loc , 0 , int32_type)), nullptr ));
612615 pass_result.push_back (al, stmt3);
613616
617+ // Step4: Add the DoLoop for appending elements into the list
614618 std::string block_name = current_scope->get_unique_name (" block" );
615619 SymbolTable* block_symtab = al.make_new <SymbolTable>(current_scope);
616620 char *tmp_var_name = s2c (al, " tmp" );
0 commit comments