stage4/generate_c/generate_c_typedecl.cc
changeset 916 e14cb81bc310
parent 913 1c74da17cb61
child 930 96f3928ebd96
equal deleted inserted replaced
915:ec3759689efe 916:e14cb81bc310
   627 
   627 
   628 
   628 
   629 /* ref_spec:  REF_TO (non_generic_type_name | function_block_type_name) */
   629 /* ref_spec:  REF_TO (non_generic_type_name | function_block_type_name) */
   630 // SYM_REF1(ref_spec_c, type_name)
   630 // SYM_REF1(ref_spec_c, type_name)
   631 void *visit(ref_spec_c *symbol) {
   631 void *visit(ref_spec_c *symbol) {
       
   632   int implicit_id_count = symbol->anotations_map.count("generate_c_annotaton__implicit_type_id");
       
   633   if (implicit_id_count  > 1) ERROR;
       
   634   if (implicit_id_count == 1) {
       
   635       /* this is part of an implicitly declared datatype (i.e. inside a variable decaration), for which an equivalent C datatype
       
   636        * has already been defined. So, we simly print out the id of that C datatpe...
       
   637        */
       
   638     symbol->anotations_map["generate_c_annotaton__implicit_type_id"]->accept(*basedecl);
       
   639     return NULL;
       
   640   }
   632   return symbol->type_name->accept(*this);
   641   return symbol->type_name->accept(*this);
   633 }
   642 }
   634 
   643 
   635 /* For the moment, we do not support initialising reference data types */
   644 /* For the moment, we do not support initialising reference data types */
   636 /* ref_spec_init: ref_spec [ ASSIGN ref_initialization ] */ 
   645 /* ref_spec_init: ref_spec [ ASSIGN ref_initialization ] */ 
   637 /* NOTE: ref_initialization may be NULL!! */
   646 /* NOTE: ref_initialization may be NULL!! */
   638 // SYM_REF2(ref_spec_init_c, ref_spec, ref_initialization)
   647 // SYM_REF2(ref_spec_init_c, ref_spec, ref_initialization)
   639 void *visit(ref_spec_init_c *symbol) {
   648 void *visit(ref_spec_init_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   if (implicit_id_count == 1) {
       
   652       /* this is part of an implicitly declared datatype (i.e. inside a variable decaration), for which an equivalent C datatype
       
   653        * has already been defined. So, we simly print out the id of that C datatpe...
       
   654        */
       
   655     symbol->anotations_map["generate_c_annotaton__implicit_type_id"]->accept(*basedecl);
       
   656     return NULL;
       
   657   }
   640   return symbol->ref_spec->accept(*this);
   658   return symbol->ref_spec->accept(*this);
   641 }
   659 }
   642 
   660 
   643 /* ref_type_decl: identifier ':' ref_spec_init */
   661 /* ref_type_decl: identifier ':' ref_spec_init */
   644 // SYM_REF2(ref_type_decl_c, ref_type_name, ref_spec_init)
   662 // SYM_REF2(ref_type_decl_c, ref_type_name, ref_spec_init)