@@ -102,6 +102,7 @@ class BaseCCPPVisitor : public ASR::BaseVisitor<Struct>
102
102
const ASR::Function_t *current_function = nullptr ;
103
103
std::map<uint64_t , SymbolInfo> sym_info;
104
104
std::map<uint64_t , std::string> const_var_names;
105
+ std::map<int32_t , std::string> gotoid2name;
105
106
106
107
// Output configuration:
107
108
// Use std::string or char*
@@ -331,6 +332,15 @@ R"(#include <stdio.h>
331
332
std::string indent (indentation_level*indentation_spaces, ' ' );
332
333
std::string open_paranthesis = indent + " {\n " ;
333
334
std::string close_paranthesis = indent + " }\n " ;
335
+ if (x.m_label != -1 ) {
336
+ std::string b_name;
337
+ if (gotoid2name.find (x.m_label ) != gotoid2name.end ()) {
338
+ b_name = gotoid2name[x.m_label ];
339
+ } else {
340
+ b_name = " __" +std::to_string (x.m_label );
341
+ }
342
+ open_paranthesis = indent + b_name + " : {\n " ;
343
+ }
334
344
indent += std::string (indentation_spaces, ' ' );
335
345
indentation_level += 1 ;
336
346
SymbolTable* current_scope_copy = current_scope;
@@ -1911,6 +1921,12 @@ R"(#include <stdio.h>
1911
1921
}
1912
1922
}
1913
1923
1924
+ void visit_GoTo (const ASR::GoTo_t &x) {
1925
+ std::string indent (indentation_level*indentation_spaces, ' ' );
1926
+ src = indent + " goto " + std::string (x.m_name ) + " ;\n " ;
1927
+ gotoid2name[x.m_target_id ] = std::string (x.m_name );
1928
+ }
1929
+
1914
1930
void visit_GoToTarget (const ASR::GoToTarget_t & /* x */ ) {
1915
1931
// Ignore for now
1916
1932
src = " " ;
0 commit comments