@@ -60,7 +60,50 @@ class Helper {
6060
6161
6262
63-
63+ // loop end and start
64+ std::string current_loop_end;
65+ std::string current_loop_update;
66+ std::string current_loop_start;
67+ std::vector<std::string> loop_end;
68+ std::vector<std::string> loop_update;
69+ std::vector<std::string> loop_start;
70+
71+ void new_loop (std::string new_loop_start, std::string new_loop_end, std::string new_loop_update = " None" ){
72+ loop_start.push_back (new_loop_start);
73+ loop_update.push_back (new_loop_update);
74+ loop_end.push_back (new_loop_end);
75+ current_loop_start = new_loop_start;
76+ current_loop_update = new_loop_update;
77+ current_loop_end = new_loop_end;
78+ }
79+ void exit_loop (){
80+ if (!loop_start.empty ()){
81+ current_loop_start = loop_start.back ();
82+ current_loop_update = loop_update.back ();
83+ current_loop_end = loop_end.back ();
84+ loop_start.pop_back ();
85+ loop_update.pop_back ();
86+ loop_end.pop_back ();
87+ }
88+ else {
89+ std::cerr << " Tried to break or continue in a scope of no loops" << std::endl;
90+ exit (1 );
91+ }
92+ }
93+ std::string get_loop_labels (std::string where){
94+ if (where == " Start" ){
95+ return current_loop_start;
96+ }
97+ else if (where == " End" ){
98+ return current_loop_end;
99+ }
100+ else if (where == " Update" ){
101+ return current_loop_update;
102+ }
103+ else {
104+ return " invalid location to jump" ;
105+ }
106+ }
64107
65108
66109 // Creates Labels for function jumps
0 commit comments