320 */ |
317 */ |
321 |
318 |
322 /* identifier ':' array_spec_init */ |
319 /* identifier ':' array_spec_init */ |
323 void *visit(array_type_declaration_c *symbol) { |
320 void *visit(array_type_declaration_c *symbol) { |
324 TRACE("array_type_declaration_c"); |
321 TRACE("array_type_declaration_c"); |
325 |
|
326 current_typedefinition = array_td; |
322 current_typedefinition = array_td; |
327 current_type_name = symbol->identifier; |
323 current_type_name = symbol->identifier; |
328 |
324 |
329 array_is_derived = false; |
325 int implicit_id_count = symbol->array_spec_init->anotations_map.count("generate_c_annotaton__implicit_type_id"); |
330 current_basetypedeclaration = arrayderiveddeclaration_bd; |
326 if (implicit_id_count > 1) ERROR; |
331 symbol->array_spec_init->accept(*this); |
327 if (implicit_id_count == 1) |
332 current_basetypedeclaration = none_bd; |
|
333 |
|
334 if (array_is_derived) |
|
335 s4o_incl.print("__DECLARE_DERIVED_TYPE("); |
328 s4o_incl.print("__DECLARE_DERIVED_TYPE("); |
336 else |
329 else |
337 s4o_incl.print("__DECLARE_ARRAY_TYPE("); |
330 s4o_incl.print("__DECLARE_ARRAY_TYPE("); |
338 current_type_name->accept(*basedecl); |
331 current_type_name->accept(*basedecl); |
339 s4o_incl.print(","); |
332 s4o_incl.print(","); |
340 current_basetypedeclaration = arraybasetypeincl_bd; |
|
341 symbol->array_spec_init->accept(*this); |
333 symbol->array_spec_init->accept(*this); |
342 current_basetypedeclaration = none_bd; |
|
343 if (!array_is_derived) { |
|
344 s4o_incl.print(","); |
|
345 current_basetypedeclaration = arraysubrange_bd; |
|
346 symbol->array_spec_init->accept(*this); |
|
347 current_basetypedeclaration = none_bd; |
|
348 } |
|
349 s4o_incl.print(")\n"); |
334 s4o_incl.print(")\n"); |
350 |
335 |
351 current_type_name = NULL; |
336 current_type_name = NULL; |
352 current_typedefinition = none_td; |
337 current_typedefinition = none_td; |
353 |
338 return NULL; |
354 return NULL; |
339 } |
355 } |
340 |
|
341 |
356 |
342 |
357 /* array_specification [ASSIGN array_initialization] */ |
343 /* array_specification [ASSIGN array_initialization] */ |
358 /* array_initialization may be NULL ! */ |
344 /* array_initialization may be NULL ! */ |
359 void *visit(array_spec_init_c *symbol) { |
345 void *visit(array_spec_init_c *symbol) { |
360 TRACE("array_spec_init_c"); |
346 TRACE("array_spec_init_c"); |
361 |
347 int implicit_id_count = symbol->anotations_map.count("generate_c_annotaton__implicit_type_id"); |
362 if (current_typedefinition == array_td) { |
348 if (implicit_id_count > 1) ERROR; |
363 switch (current_basetypedeclaration) { |
349 if (implicit_id_count == 1) { |
364 case arrayderiveddeclaration_bd: |
350 /* this is part of an implicitly declared datatype (i.e. inside a variable decaration), for which an equivalent C datatype |
365 array_is_derived = dynamic_cast<identifier_c *>(symbol->array_specification) != NULL; |
351 * has already been defined. So, we simly print out the id of that C datatpe... |
366 break; |
352 */ |
367 default: |
353 symbol->anotations_map["generate_c_annotaton__implicit_type_id"]->accept(*basedecl); |
368 if (array_is_derived) |
354 return NULL; |
369 symbol->array_specification->accept(*basedecl); |
|
370 else |
|
371 symbol->array_specification->accept(*this); |
|
372 break; |
|
373 } |
|
374 } |
355 } |
375 else { |
356 // if (current_typedefinition != array_td) {debug_c::print(symbol); ERROR;} |
376 symbol->array_specification->accept(*basedecl); |
357 symbol->array_specification->accept(*this); |
377 } |
|
378 return NULL; |
358 return NULL; |
379 } |
359 } |
380 |
360 |
381 /* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */ |
361 /* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */ |
382 void *visit(array_specification_c *symbol) { |
362 void *visit(array_specification_c *symbol) { |
383 TRACE("array_specification_c"); |
363 TRACE("array_specification_c"); |
384 switch (current_basetypedeclaration) { |
364 int implicit_id_count = symbol->anotations_map.count("generate_c_annotaton__implicit_type_id"); |
385 case arraybasetype_bd: |
365 if (implicit_id_count > 1) ERROR; |
386 symbol->non_generic_type_name->accept(*this); |
366 if (implicit_id_count == 1) { |
387 break; |
367 /* this is part of an implicitly declared datatype (i.e. inside a variable decaration), for which an equivalent C datatype |
388 case arraybasetypeincl_bd: |
368 * has already been defined. So, we simly print out the id of that C datatpe... |
389 symbol->non_generic_type_name->accept(*basedecl); |
369 */ |
390 break; |
370 symbol->anotations_map["generate_c_annotaton__implicit_type_id"]->accept(*basedecl); |
391 case arraysubrange_bd: |
371 return NULL; |
392 symbol->array_subrange_list->accept(*this); |
|
393 break; |
|
394 default: |
|
395 break; |
|
396 } |
372 } |
|
373 // The 2nd and 3rd argument of a call to the __DECLARE_ARRAY_TYPE macro! |
|
374 symbol->non_generic_type_name->accept(*this); |
|
375 s4o_incl.print(","); |
|
376 current_basetypedeclaration = arraysubrange_bd; |
|
377 symbol->array_subrange_list->accept(*this); |
|
378 current_basetypedeclaration = none_bd; |
397 return NULL; |
379 return NULL; |
398 } |
380 } |
399 |
381 |
400 |
382 |
401 /* TYPE type_declaration_list END_TYPE */ |
383 /* TYPE type_declaration_list END_TYPE */ |