156 /***********************************************************************/ |
156 /***********************************************************************/ |
157 /***********************************************************************/ |
157 /***********************************************************************/ |
158 /***********************************************************************/ |
158 /***********************************************************************/ |
159 /***********************************************************************/ |
159 /***********************************************************************/ |
160 |
160 |
|
161 |
|
162 #include "generate_c.hh" |
|
163 |
|
164 |
|
165 /***********************************************************************/ |
|
166 /***********************************************************************/ |
|
167 /***********************************************************************/ |
|
168 /***********************************************************************/ |
|
169 |
|
170 /* A helper class that prints out the identifiers for function calls to overloaded functions */ |
|
171 /* Given a function declaration of the function being called, it |
|
172 * will simply print out the returned data type, |
|
173 * followed by the data types of all input, output, and in_out parameters. |
|
174 * for e.g.; |
|
175 * SIN( REAL) : REAL -> prints out -> REAL__REAL |
|
176 * LEN( STRING) : INT -> prints out -> INT__STRING |
|
177 * MUL(TIME, INT) : TIME -> prints out -> TIME__TIME__INT |
|
178 */ |
|
179 class print_function_parameter_data_types_c: public generate_c_base_c { |
|
180 private: |
|
181 symbol_c *current_type; |
|
182 bool_type_name_c tmp_bool; |
|
183 |
|
184 void print_list(symbol_c *var_list, symbol_c *data_type) { |
|
185 if (data_type != NULL) { |
|
186 /* print out the data type once for every variable! */ |
|
187 list_c *list = dynamic_cast<list_c *>(var_list); |
|
188 if (list == NULL) ERROR; |
|
189 for (int i=0; i < list->n; i++) { |
|
190 s4o.print("__"); |
|
191 data_type->accept(*this); |
|
192 } |
|
193 } |
|
194 } |
|
195 |
|
196 public: |
|
197 print_function_parameter_data_types_c(stage4out_c *s4o_ptr): |
|
198 generate_c_base_c(s4o_ptr) |
|
199 {current_type = NULL;} |
|
200 |
|
201 /**************************************/ |
|
202 /* B.1.5 - Program organization units */ |
|
203 /**************************************/ |
|
204 /***********************/ |
|
205 /* B 1.5.1 - Functions */ |
|
206 /***********************/ |
|
207 /* FUNCTION derived_function_name ':' elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */ |
|
208 /* | FUNCTION derived_function_name ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */ |
|
209 void *visit(function_declaration_c *symbol) { |
|
210 symbol->type_name->accept(*this); /* return type */ |
|
211 symbol->var_declarations_list->accept(*this); |
|
212 return NULL; |
|
213 } |
|
214 |
|
215 /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */ |
|
216 //void *visit(var_declarations_list_c *symbol) {// iterate through list} |
|
217 |
|
218 /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */ |
|
219 //void *visit(input_declarations_c *symbol) {// iterate through list} |
|
220 |
|
221 /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */ |
|
222 //void *visit(input_declaration_list_c *symbol) {// iterate through list} |
|
223 |
|
224 void *visit(edge_declaration_c *symbol) { |
|
225 current_type = &tmp_bool; |
|
226 symbol->var1_list->accept(*this); |
|
227 current_type = NULL; |
|
228 return NULL; |
|
229 } |
|
230 |
|
231 /* We do NOT print out EN and ENO parameters! */ |
|
232 void *visit(en_param_declaration_c *symbol) {return NULL;} |
|
233 |
|
234 /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */ |
|
235 //void *visit(output_declarations_c *symbol) {// iterate through list} |
|
236 |
|
237 /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */ |
|
238 //void *visit(var_init_decl_list_c *symbol) {// iterate through list} |
|
239 |
|
240 void *visit(simple_spec_init_c *symbol) { |
|
241 /* return the data type */ |
|
242 return symbol->simple_specification; |
|
243 } |
|
244 |
|
245 /* currently we do not support data types defined in the declaration itself */ |
|
246 /* For now, sugest the user define a TYPE .. END_TYPE */ |
|
247 /* NOTE: although this class may also sometimes point to a previously_declared_subrange_type_name |
|
248 * we don't need this for now, so it is easier to just skip it allocation |
|
249 */ |
|
250 void *visit(subrange_spec_init_c *symbol) {return NULL;} |
|
251 |
|
252 /* currently we do not support data types defined in the declaration itself */ |
|
253 /* For now, sugest the user define a TYPE .. END_TYPE */ |
|
254 /* NOTE: although this class may also sometimes point to a previously_declared_enumerated_type_name |
|
255 * we don't need this for now, so it is easier to just skip it allocation |
|
256 */ |
|
257 void *visit(enumerated_spec_init_c *symbol) {return NULL;} |
|
258 |
|
259 /* currently we do not support data types defined in the declaration itself */ |
|
260 /* For now, sugest the user define a TYPE .. END_TYPE */ |
|
261 /* NOTE: although this class may also sometimes point to a previously_declared_array_type_name |
|
262 * we don't need this for now, so it is easier to just skip it allocation |
|
263 */ |
|
264 void *visit(array_var_init_decl_c *symbol) {return NULL;} |
|
265 |
|
266 /* currently we do not support data types defined in the declaration itself */ |
|
267 /* For now, sugest the user define a TYPE .. END_TYPE */ |
|
268 /* NOTE: although this class may also sometimes point to a previously_declared_structured_type_name |
|
269 * we don't need this for now, so it is easier to just skip it allocation |
|
270 */ |
|
271 void *visit(structured_var_init_decl_c *symbol) {return NULL;} |
|
272 |
|
273 /* We do NOT print out EN and ENO parameters! */ |
|
274 void *visit(eno_param_declaration_c *symbol) {return NULL;} |
|
275 |
|
276 /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */ |
|
277 //void *visit(input_output_declarations_c *symbol) {// iterate through list} |
|
278 |
|
279 /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */ |
|
280 //void *visit(var_declaration_list_c *symbol) {iterate through list} |
|
281 |
|
282 void *visit(fb_name_decl_c *symbol) { |
|
283 print_list(symbol->fb_name_list, symbol->function_block_type_name); |
|
284 return NULL; |
|
285 } |
|
286 |
|
287 void *visit(var1_init_decl_c *symbol) { |
|
288 print_list(symbol->var1_list, (symbol_c *)symbol->spec_init->accept(*this)); |
|
289 return NULL; |
|
290 } |
|
291 |
|
292 /* currently we do not support data types defined in the declaration itself */ |
|
293 /* For now, sugest the user define a TYPE .. END_TYPE */ |
|
294 void *visit(array_var_declaration_c *symbol) {return NULL;} |
|
295 |
|
296 void *visit(structured_var_declaration_c *symbol) { |
|
297 current_type = symbol->structure_type_name; |
|
298 symbol->var1_list->accept(*this); |
|
299 current_type = NULL; |
|
300 return NULL; |
|
301 } |
|
302 |
|
303 /* currently we do not support data types defined in the declaration itself */ |
|
304 /* For now, sugest the user define a TYPE .. END_TYPE */ |
|
305 /* Note that this class is used for fixed length strings... |
|
306 * STRING [ 42 ] |
|
307 */ |
|
308 void *visit(single_byte_string_var_declaration_c *symbol) {return NULL;} |
|
309 |
|
310 /* currently we do not support data types defined in the declaration itself */ |
|
311 /* For now, sugest the user define a TYPE .. END_TYPE */ |
|
312 /* Note that this class is used for fixed length strings... |
|
313 * WSTRING [ 42 ] |
|
314 */ |
|
315 void *visit(double_byte_string_var_declaration_c *symbol) {return NULL;} |
|
316 }; |
|
317 |
|
318 |
|
319 /***********************************************************************/ |
|
320 /***********************************************************************/ |
|
321 /***********************************************************************/ |
|
322 /***********************************************************************/ |
|
323 |
|
324 |
161 #include "generate_c_st.cc" |
325 #include "generate_c_st.cc" |
162 #include "generate_c_il.cc" |
326 #include "generate_c_il.cc" |
163 #include "generate_c_inlinefcall.cc" |
327 #include "generate_c_inlinefcall.cc" |
164 |
|
165 #include "generate_c.hh" |
|
166 |
328 |
167 /***********************************************************************/ |
329 /***********************************************************************/ |
168 /***********************************************************************/ |
330 /***********************************************************************/ |
169 /***********************************************************************/ |
331 /***********************************************************************/ |
170 /***********************************************************************/ |
332 /***********************************************************************/ |