stage4/generate_c/generate_c_typedecl.cc
changeset 178 1622dc05c6ca
parent 174 f648065fb66e
child 221 c6aed7e5f070
equal deleted inserted replaced
177:697562a5da7c 178:1622dc05c6ca
   192 /* B 1.3.3 - Derived data types */
   192 /* B 1.3.3 - Derived data types */
   193 /********************************/
   193 /********************************/
   194 /*  subrange_type_name ':' subrange_spec_init */
   194 /*  subrange_type_name ':' subrange_spec_init */
   195 void *visit(subrange_type_declaration_c *symbol) {
   195 void *visit(subrange_type_declaration_c *symbol) {
   196   TRACE("subrange_type_declaration_c");  
   196   TRACE("subrange_type_declaration_c");  
   197   /* add this type declaration to the type symbol table... */
       
   198   type_symtable.insert(symbol->subrange_type_name, symbol->subrange_spec_init);
       
   199   
   197   
   200   s4o_incl.print("typedef ");
   198   s4o_incl.print("typedef ");
   201   current_basetypedeclaration = subrangebasetype_bd;
   199   current_basetypedeclaration = subrangebasetype_bd;
   202   symbol->subrange_spec_init->accept(*this);
   200   symbol->subrange_spec_init->accept(*this);
   203   current_basetypedeclaration = none_bd;
   201   current_basetypedeclaration = none_bd;
   306 }
   304 }
   307 
   305 
   308 /*  enumerated_type_name ':' enumerated_spec_init */
   306 /*  enumerated_type_name ':' enumerated_spec_init */
   309 void *visit(enumerated_type_declaration_c *symbol) {
   307 void *visit(enumerated_type_declaration_c *symbol) {
   310   TRACE("enumerated_type_declaration_c");
   308   TRACE("enumerated_type_declaration_c");
   311   /* add this type declaration to the type symbol table... */
       
   312   type_symtable.insert(symbol->enumerated_type_name, symbol->enumerated_spec_init);
       
   313   
   309   
   314   s4o_incl.print("typedef enum {\n");
   310   s4o_incl.print("typedef enum {\n");
   315   s4o_incl.indent_right();
   311   s4o_incl.indent_right();
   316   symbol->enumerated_spec_init->accept(*this);
   312   symbol->enumerated_spec_init->accept(*this);
   317   s4o_incl.indent_left();
   313   s4o_incl.indent_left();
   341 }
   337 }
   342 
   338 
   343 /*  identifier ':' array_spec_init */
   339 /*  identifier ':' array_spec_init */
   344 void *visit(array_type_declaration_c *symbol) {
   340 void *visit(array_type_declaration_c *symbol) {
   345   TRACE("array_type_declaration_c");
   341   TRACE("array_type_declaration_c");
   346   /* add this type declaration to the type symbol table... */
       
   347   type_symtable.insert(symbol->identifier, symbol->array_spec_init);
       
   348   
   342   
   349   s4o_incl.print("typedef ");
   343   s4o_incl.print("typedef ");
   350   current_basetypedeclaration = arraybasetypeincl_bd;
   344   current_basetypedeclaration = arraybasetypeincl_bd;
   351   symbol->array_spec_init->accept(*this);
   345   symbol->array_spec_init->accept(*this);
   352   current_basetypedeclaration = none_bd;
   346   current_basetypedeclaration = none_bd;
   446 }
   440 }
   447 
   441 
   448 /*  simple_type_name ':' simple_spec_init */
   442 /*  simple_type_name ':' simple_spec_init */
   449 void *visit(simple_type_declaration_c *symbol) {
   443 void *visit(simple_type_declaration_c *symbol) {
   450   TRACE("simple_type_declaration_c");
   444   TRACE("simple_type_declaration_c");
   451   /* add this type declaration to the type symbol table... */
       
   452   type_symtable.insert(symbol->simple_type_name, symbol->simple_spec_init);
       
   453 
   445 
   454   s4o_incl.print("typedef ");
   446   s4o_incl.print("typedef ");
   455   symbol->simple_spec_init->accept(*this);
   447   symbol->simple_spec_init->accept(*this);
   456   s4o_incl.print(" ");
   448   s4o_incl.print(" ");
   457   symbol->simple_type_name->accept(*basedecl);
   449   symbol->simple_type_name->accept(*basedecl);
   520 
   512 
   521 /*  structure_type_name ':' structure_specification */
   513 /*  structure_type_name ':' structure_specification */
   522 //SYM_REF2(structure_type_declaration_c, structure_type_name, structure_specification)
   514 //SYM_REF2(structure_type_declaration_c, structure_type_name, structure_specification)
   523 void *visit(structure_type_declaration_c *symbol) {
   515 void *visit(structure_type_declaration_c *symbol) {
   524   TRACE("structure_type_declaration_c");
   516   TRACE("structure_type_declaration_c");
   525   /* add this type declaration to the type symbol table... */
       
   526   type_symtable.insert(symbol->structure_type_name, symbol->structure_specification);
       
   527 
   517 
   528   s4o_incl.print("typedef ");
   518   s4o_incl.print("typedef ");
   529   symbol->structure_specification->accept(*this);
   519   symbol->structure_specification->accept(*this);
   530   s4o_incl.print(" ");
   520   s4o_incl.print(" ");
   531   symbol->structure_type_name->accept(*basedecl);
   521   symbol->structure_type_name->accept(*basedecl);