stage4/generate_c/generate_c_base.cc
changeset 928 fa7a6800503d
parent 927 39b596670e33
child 936 0f7bcc160568
equal deleted inserted replaced
927:39b596670e33 928:fa7a6800503d
   617   symbol->value->accept(*this);
   617   symbol->value->accept(*this);
   618   return NULL;
   618   return NULL;
   619 }
   619 }
   620 
   620 
   621 
   621 
   622   
   622 /*  identifier ':' array_spec_init */
       
   623 void *visit(array_type_declaration_c *symbol) {ERROR;/* Should never get called! */ return NULL;}
       
   624 
       
   625 /* array_specification [ASSIGN array_initialization] */
       
   626 /* array_initialization may be NULL ! */
       
   627 void *visit(array_spec_init_c *symbol) {
       
   628   int implicit_id_count = symbol->anotations_map.count("generate_c_annotaton__implicit_type_id");
       
   629   if (implicit_id_count != 1) ERROR;
       
   630   /* this is part of an implicitly declared datatype (i.e. inside a variable decaration), for which an equivalent C datatype
       
   631    * has already been defined. So, we simly print out the id of that C datatpe...
       
   632    */
       
   633   return symbol->anotations_map["generate_c_annotaton__implicit_type_id"]->accept(*this);
       
   634 }
       
   635 
       
   636 /* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */
       
   637 void *visit(array_specification_c *symbol) {
       
   638   int implicit_id_count = symbol->anotations_map.count("generate_c_annotaton__implicit_type_id");
       
   639   if (implicit_id_count != 1) ERROR;
       
   640   /* this is part of an implicitly declared datatype (i.e. inside a variable decaration), for which an equivalent C datatype
       
   641    * has already been defined. So, we simly print out the id of that C datatpe...
       
   642    */
       
   643   return symbol->anotations_map["generate_c_annotaton__implicit_type_id"]->accept(*this);
       
   644 }
       
   645 
       
   646 
       
   647 /* ref_spec:  REF_TO (non_generic_type_name | function_block_type_name) */
       
   648 void *visit(ref_spec_c *symbol) {
       
   649   int implicit_id_count = symbol->anotations_map.count("generate_c_annotaton__implicit_type_id");
       
   650   if (implicit_id_count != 1) ERROR;
       
   651   /* this is part of an implicitly declared datatype (i.e. inside a variable decaration), for which an equivalent C datatype
       
   652    * has already been defined. So, we simly print out the id of that C datatpe...
       
   653    */
       
   654   return symbol->anotations_map["generate_c_annotaton__implicit_type_id"]->accept(*this);
       
   655 }
       
   656 
       
   657 /* For the moment, we do not support initialising reference data types */
       
   658 /* ref_spec_init: ref_spec [ ASSIGN ref_initialization ] */ 
       
   659 /* NOTE: ref_initialization may be NULL!! */
       
   660 // SYM_REF2(ref_spec_init_c, ref_spec, ref_initialization)
       
   661 void *visit(ref_spec_init_c *symbol) {
       
   662   int implicit_id_count = symbol->anotations_map.count("generate_c_annotaton__implicit_type_id");
       
   663   if (implicit_id_count != 1) ERROR;
       
   664   /* this is part of an implicitly declared datatype (i.e. inside a variable decaration), for which an equivalent C datatype
       
   665    * has already been defined. So, we simly print out the id of that C datatpe...
       
   666    */
       
   667   return symbol->anotations_map["generate_c_annotaton__implicit_type_id"]->accept(*this);
       
   668 }
       
   669 
       
   670 /* ref_type_decl: identifier ':' ref_spec_init */
       
   671 void *visit(ref_type_decl_c *symbol) {ERROR;/* Should never get called! */ return NULL;}
       
   672 
       
   673 
       
   674 
       
   675 
       
   676 
   623 /* NOTE:     visit(subrange_spec_init_c *)
   677 /* NOTE:     visit(subrange_spec_init_c *)
   624  *      and  visit(subrange_specification_c *)
   678  *      and  visit(subrange_specification_c *)
   625  *      together simply print out the integer datatype
   679  *      together simply print out the integer datatype
   626  *      on which the subrange is based.
   680  *      on which the subrange is based.
   627  *
   681  *
   641   TRACE("subrange_specification_c");
   695   TRACE("subrange_specification_c");
   642   symbol->integer_type_name->accept(*this);
   696   symbol->integer_type_name->accept(*this);
   643   return NULL;
   697   return NULL;
   644 }
   698 }
   645   
   699   
   646   
   700 
       
   701 /* NOTE: Why is this here? This visit() method should not be here!!
       
   702  * TODO: Figure out who is dependent on this method, and move it to its correct location!
       
   703  */
   647 /* helper symbol for array_specification */
   704 /* helper symbol for array_specification */
   648 /* array_subrange_list ',' subrange */
   705 /* array_subrange_list ',' subrange */
   649 void *visit(array_subrange_list_c *symbol) {
   706 void *visit(array_subrange_list_c *symbol) {
   650   TRACE("array_subrange_list_c");
   707   TRACE("array_subrange_list_c");
   651   print_list(symbol);
   708   print_list(symbol);