29 stage4out_c &s4o_incl; |
29 stage4out_c &s4o_incl; |
30 |
30 |
31 private: |
31 private: |
32 symbol_c* current_type_name; |
32 symbol_c* current_type_name; |
33 bool array_is_derived; |
33 bool array_is_derived; |
34 |
|
35 generate_c_base_c *basedecl; |
34 generate_c_base_c *basedecl; |
36 |
35 |
37 public: |
36 public: |
38 generate_c_typedecl_c(stage4out_c *s4o_ptr, stage4out_c *s4o_incl_ptr): generate_c_base_c(s4o_ptr), s4o_incl(*s4o_incl_ptr) { |
|
39 current_typedefinition = none_td; |
|
40 current_basetypedeclaration = none_bd; |
|
41 current_type_name = NULL; |
|
42 basedecl = new generate_c_base_c(&s4o_incl); |
|
43 } |
|
44 generate_c_typedecl_c(stage4out_c *s4o_ptr): generate_c_base_c(s4o_ptr), s4o_incl(*s4o_ptr) { |
37 generate_c_typedecl_c(stage4out_c *s4o_ptr): generate_c_base_c(s4o_ptr), s4o_incl(*s4o_ptr) { |
45 current_typedefinition = none_td; |
38 current_typedefinition = none_td; |
46 current_basetypedeclaration = none_bd; |
39 current_basetypedeclaration = none_bd; |
47 current_type_name = NULL; |
40 current_type_name = NULL; |
48 basedecl = new generate_c_base_c(&s4o_incl); |
41 basedecl = new generate_c_base_c(&s4o_incl); |
322 print_list_incl(symbol, s4o_incl.indent_spaces, ",\n"+s4o_incl.indent_spaces, "\n"); |
313 print_list_incl(symbol, s4o_incl.indent_spaces, ",\n"+s4o_incl.indent_spaces, "\n"); |
323 return NULL; |
314 return NULL; |
324 } |
315 } |
325 |
316 |
326 /* enumerated_type_name '#' identifier */ |
317 /* enumerated_type_name '#' identifier */ |
327 void *visit(enumerated_value_c *symbol) { |
318 /* Handled by generate_c_base_c class!! |
328 TRACE("enumerated_value_c"); |
319 void *visit(enumerated_value_c *symbol) {} |
329 if (current_typedefinition == enumerated_td) |
320 */ |
330 current_type_name->accept(*basedecl); |
|
331 else { |
|
332 if (NULL == symbol->datatype) { |
|
333 debug_c::print(symbol); |
|
334 ERROR; |
|
335 } |
|
336 symbol_c *type_name = get_datatype_info_c::get_id(symbol->datatype); |
|
337 if (NULL == type_name) { |
|
338 // ERROR_MSG("generate_c does not support anonymous enumerated data types."); |
|
339 } else |
|
340 type_name->accept(*basedecl); |
|
341 } |
|
342 s4o_incl.print("__"); |
|
343 symbol->value->accept(*basedecl); |
|
344 return NULL; |
|
345 } |
|
346 |
321 |
347 /* identifier ':' array_spec_init */ |
322 /* identifier ':' array_spec_init */ |
348 void *visit(array_type_declaration_c *symbol) { |
323 void *visit(array_type_declaration_c *symbol) { |
349 TRACE("array_type_declaration_c"); |
324 TRACE("array_type_declaration_c"); |
350 |
325 |
420 break; |
395 break; |
421 } |
396 } |
422 return NULL; |
397 return NULL; |
423 } |
398 } |
424 |
399 |
425 /* helper symbol for array_specification */ |
|
426 /* array_subrange_list ',' subrange */ |
|
427 void *visit(array_subrange_list_c *symbol) { |
|
428 TRACE("array_subrange_list_c"); |
|
429 print_list(symbol); |
|
430 return NULL; |
|
431 } |
|
432 |
400 |
433 /* TYPE type_declaration_list END_TYPE */ |
401 /* TYPE type_declaration_list END_TYPE */ |
434 void *visit(data_type_declaration_c *symbol) { |
402 void *visit(data_type_declaration_c *symbol) { |
435 TRACE("data_type_declaration_c"); |
403 TRACE("data_type_declaration_c"); |
436 symbol->type_declaration_list->accept(*this); |
404 symbol->type_declaration_list->accept(*this); |