@@ -2843,7 +2843,7 @@ class SymbolTableVisitor : public CommonVisitor<SymbolTableVisitor> {
28432843 bool current_procedure_interface = false ;
28442844 bool overload = false ;
28452845 bool vectorize = false , is_inline = false , is_static = false ;
2846-
2846+ bool is_goto = false ;
28472847 Vec<ASR ::ttype_t *> tps;
28482848 tps.reserve (al, x.m_args .n_args );
28492849 bool is_restriction = false ;
@@ -2866,6 +2866,8 @@ class SymbolTableVisitor : public CommonVisitor<SymbolTableVisitor> {
28662866 vectorize = true ;
28672867 } else if (name == " restriction" ) {
28682868 is_restriction = true ;
2869+ } else if (name == " with_goto" ) {
2870+ is_goto = true ;
28692871 } else if (name == " inline" ) {
28702872 is_inline = true ;
28712873 } else if (name == " static" ) {
@@ -3985,40 +3987,19 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
39853987 if (AST ::is_a<AST ::Name_t>(*x.m_value )) {
39863988 std::string value = AST ::down_cast<AST ::Name_t>(x.m_value )->m_id ;
39873989 if ( value == " label" ) {
3988- // Label name has to be converted into an ID
3989- // Now each label must be mapped to a unique ID
3990- // because ASR doesn't care about the label names
3991- // it just cares about IDs. Now if we don't map
3992- // label names to unique IDs then we won't be able
3993- // to create backend code correctly.
3994- // How to generate IDs? We have a generator for that.
39953990 std::string labelname = std::string (x.m_attr );
3996- // std::cout << "ATTRIB NAME = " + labelname <<std::endl;
39973991 ASRUtils::LabelGenerator* label_generator = ASRUtils::LabelGenerator::get_instance ();
39983992 int id = label_generator->get_id_by_label (labelname);
3999- std::cout << " ID IS =" << id << std::endl;
4000- // tmp = ASR::make_GoToTarget_t(al, x.base.base.loc, id); ??
4001- tmp = ASR::make_GoTo_t (al, x.base .base .loc , id); // #looks like i want to create goto label .
3993+ tmp = ASR::make_GoTo_t (al, x.base .base .loc , id, labelname);
40023994 return ;
40033995 }
40043996
40053997 if (value == " goto" ){
40063998 std::string labelname = std::string (x.m_attr );
4007- // std::cout << "ATTRIB NAME = " + std::string(x.m_attr) <<std::endl;
3999+
40084000 ASRUtils::LabelGenerator* label_generator =ASRUtils::LabelGenerator::get_instance ();
40094001 int id = label_generator->get_id_by_label (labelname);
4010- // int id = label_generator->get_unique_id();
4011- // std::string labelname = std::string(x.m_attr);
4012- // std::cout << "INSiDE NAME = " + labelname <<std::endl;
4013- // label_generator->add_node_with_unique_label(labelname, id);
4014-
4015- // why empty block ? Ondrej advise GoTo_target
4016-
4017-
4018- // set_empty_block(current_scope, x.base.base.loc);
4019- // tmp = ASR::make_BlockCall_t(al, x.base.base.loc, id, empty_block);
4020-
4021- tmp = ASR::make_GoToTarget_t (al, x.base .base .loc , id);
4002+ tmp = ASR::make_GoToTarget_t (al, x.base .base .loc , id, labelname);
40224003 return ;
40234004 }
40244005
0 commit comments