80 public: |
80 public: |
81 next_var_c(std::string s1, std::string s2) { |
81 next_var_c(std::string s1, std::string s2) { |
82 str1 = s1; |
82 str1 = s1; |
83 str2 = s2; |
83 str2 = s2; |
84 print_flag = false; |
84 print_flag = false; |
85 embedded_scope = NULL; |
85 embedded_scope = NULL; |
86 } |
86 } |
87 |
87 |
88 std::string get(void) { |
88 std::string get(void) { |
89 if (NULL != embedded_scope) |
89 if (NULL != embedded_scope) |
90 return embedded_scope->get(); |
90 return embedded_scope->get(); |
91 |
91 |
92 bool old_print_flag = print_flag; |
92 bool old_print_flag = print_flag; |
93 print_flag = true; |
93 print_flag = true; |
94 if (!old_print_flag) |
94 if (!old_print_flag) |
95 return str1; |
95 return str1; |
96 else |
96 else |
97 return str2; |
97 return str2; |
98 } |
98 } |
101 * From now on, every call to get() will return the |
101 * From now on, every call to get() will return the |
102 * inner-most scope...! |
102 * inner-most scope...! |
103 */ |
103 */ |
104 void push(std::string s1, std::string s2) { |
104 void push(std::string s1, std::string s2) { |
105 if (NULL != embedded_scope) |
105 if (NULL != embedded_scope) |
106 return embedded_scope->push(s1, s2); |
106 return embedded_scope->push(s1, s2); |
107 |
107 |
108 embedded_scope = new next_var_c(s1, s2); |
108 embedded_scope = new next_var_c(s1, s2); |
109 if (NULL == embedded_scope) |
109 if (NULL == embedded_scope) |
110 ERROR; |
110 ERROR; |
111 return; |
111 return; |
112 } |
112 } |
113 |
113 |
114 /* Remove the inner-most scope... */ |
114 /* Remove the inner-most scope... */ |
115 void pop(void) { |
115 void pop(void) { |
116 if (NULL != embedded_scope) |
116 if (NULL != embedded_scope) |
117 return embedded_scope->pop(); |
117 return embedded_scope->pop(); |
118 |
118 |
119 delete embedded_scope; |
119 delete embedded_scope; |
120 embedded_scope = NULL; |
120 embedded_scope = NULL; |
121 } |
121 } |
122 }; |
122 }; |
123 |
123 |
124 private: |
124 private: |
125 /* used to generate the ',' separating the parameters in a function call */ |
125 /* used to generate the ',' separating the parameters in a function call */ |
283 (wanted_varformat == init_vf) || |
283 (wanted_varformat == init_vf) || |
284 (wanted_varformat == localinit_vf)) { |
284 (wanted_varformat == localinit_vf)) { |
285 for(int i = 0; i < list->n; i++) { |
285 for(int i = 0; i < list->n; i++) { |
286 s4o.print(s4o.indent_spaces); |
286 s4o.print(s4o.indent_spaces); |
287 if (wanted_varformat != init_vf) { |
287 if (wanted_varformat != init_vf) { |
288 this->current_var_type_symbol->accept(*this); |
288 this->current_var_type_symbol->accept(*this); |
289 s4o.print(" "); |
289 s4o.print(" "); |
290 } |
290 } |
291 this->print_variable_prefix(); |
291 this->print_variable_prefix(); |
292 list->elements[i]->accept(*this); |
292 list->elements[i]->accept(*this); |
293 if (wanted_varformat != local_vf) { |
293 if (wanted_varformat != local_vf) { |
294 if (this->current_var_init_symbol != NULL) { |
294 if (this->current_var_init_symbol != NULL) { |
295 s4o.print(" = "); |
295 s4o.print(" = "); |
296 this->current_var_init_symbol->accept(*this); |
296 this->current_var_init_symbol->accept(*this); |
297 } |
297 } |
298 } |
298 } |
299 s4o.print(";\n"); |
299 s4o.print(";\n"); |
300 } |
300 } |
301 } |
301 } |
302 |
302 |
364 switch (wanted_varformat) { |
364 switch (wanted_varformat) { |
365 case constructorinit_vf: nv = new next_var_c(": ", ", "); break; |
365 case constructorinit_vf: nv = new next_var_c(": ", ", "); break; |
366 case finterface_vf: /* fall through... */ |
366 case finterface_vf: /* fall through... */ |
367 case localinit_vf: /* fall through... */ |
367 case localinit_vf: /* fall through... */ |
368 case local_vf: nv = new next_var_c("", ", "); break; |
368 case local_vf: nv = new next_var_c("", ", "); break; |
369 default: nv = NULL; |
369 default: nv = NULL; |
370 } /* switch() */ |
370 } /* switch() */ |
371 |
371 |
372 symbol->accept(*this); |
372 symbol->accept(*this); |
373 |
373 |
374 /* special case... */ |
374 /* special case... */ |