stage4/generate_c/generate_c_vardecl.cc
changeset 971 8aee27d46208
parent 958 7474d2cd1d6e
child 997 7518955c875a
child 998 694127983aa4
equal deleted inserted replaced
970:0ede7ca157e2 971:8aee27d46208
   142 
   142 
   143       s4o.print("}}");
   143       s4o.print("}}");
   144     }
   144     }
   145     
   145     
   146     void *visit(identifier_c *type_name) {
   146     void *visit(identifier_c *type_name) {
   147       symbol_c *type_decl;
   147       type_symtable_t::iterator iter = type_symtable.end();
   148       switch (current_mode) {
   148       switch (current_mode) {
   149         case arraysize_am:
   149         case arraysize_am:
   150           /* look up the type declaration... */
   150           /* look up the type declaration... */
   151           type_decl = type_symtable.find_value(type_name);
   151           iter = type_symtable.find(type_name);
   152           if (type_decl == type_symtable.end_value())   ERROR;  // Type declaration not found!!
   152           if (iter == type_symtable.end())   ERROR;  // Type declaration not found!!
   153           type_decl->accept(*this);
   153           iter->second->accept(*this);  // iter->second is a type_decl
   154           break;
   154           break;
   155         default:
   155         default:
   156           print_token(type_name);
   156           print_token(type_name);
   157           break;
   157           break;
   158       }
   158       }
   555       current_mode = initializationvalue_sm;
   555       current_mode = initializationvalue_sm;
   556       structure_initialization->accept(*this);
   556       structure_initialization->accept(*this);
   557     }
   557     }
   558 
   558 
   559     void *visit(identifier_c *type_name) {
   559     void *visit(identifier_c *type_name) {
   560       symbol_c *type_decl;
   560       type_symtable_t::iterator iter = type_symtable.end();
   561       switch (current_mode) {
   561       switch (current_mode) {
   562         case initdefault_sm:
   562         case initdefault_sm:
   563           /* look up the type declaration... */
   563           /* look up the type declaration... */
   564           type_decl = type_symtable.find_value(type_name);
   564           iter = type_symtable.find(type_name);
   565           if (type_decl == type_symtable.end_value())
   565           if (iter == type_symtable.end())
   566             /* Type declaration not found!! */
   566             ERROR; // Type declaration not found!!
   567             ERROR;
   567           iter->second->accept(*this); // iter->second is a type_decl
   568           type_decl->accept(*this);
       
   569           break;
   568           break;
   570         default:
   569         default:
   571           print_token(type_name);
   570           print_token(type_name);
   572           break;
   571           break;
   573       }
   572       }
   574       return NULL;
   573       return NULL;
   575     }
   574     }
   576     
   575     
   577     void *visit(derived_datatype_identifier_c *type_name) {
   576     void *visit(derived_datatype_identifier_c *type_name) {
   578       symbol_c *type_decl;
   577       type_symtable_t::iterator iter = type_symtable.end();
   579       switch (current_mode) {
   578       switch (current_mode) {
   580         case initdefault_sm:
   579         case initdefault_sm:
   581           /* look up the type declaration... */
   580           /* look up the type declaration... */
   582           type_decl = type_symtable.find_value(type_name);
   581           iter = type_symtable.find(type_name);
   583           if (type_decl == type_symtable.end_value())
   582           if (iter == type_symtable.end())
   584             /* Type declaration not found!! */
   583             ERROR; // Type declaration not found!!
   585             ERROR;
   584           iter->second->accept(*this); // iter->second is a type_decl
   586           type_decl->accept(*this);
       
   587           break;
   585           break;
   588         default:
   586         default:
   589           print_token(type_name);
   587           print_token(type_name);
   590           break;
   588           break;
   591       }
   589       }
  2521 /*  PROGRAM [RETAIN | NON_RETAIN] program_name [WITH task_name] ':' program_type_name ['(' prog_conf_elements ')'] */
  2519 /*  PROGRAM [RETAIN | NON_RETAIN] program_name [WITH task_name] ':' program_type_name ['(' prog_conf_elements ')'] */
  2522 // SYM_REF6(program_configuration_c, retain_option, program_name, task_name, program_type_name, prog_conf_elements, unused)
  2520 // SYM_REF6(program_configuration_c, retain_option, program_name, task_name, program_type_name, prog_conf_elements, unused)
  2523 private:
  2521 private:
  2524   /* a helper function to the program_configuration_c visitor... */
  2522   /* a helper function to the program_configuration_c visitor... */
  2525   void program_constructor_call(program_configuration_c *symbol) {
  2523   void program_constructor_call(program_configuration_c *symbol) {
  2526   program_declaration_c *p_decl = program_type_symtable.find_value(symbol->program_type_name);
  2524   program_type_symtable_t::iterator iter = program_type_symtable.find(symbol->program_type_name);
  2527 
  2525   if (iter == program_type_symtable.end()) ERROR; // The program being called MUST be in the symtable.
  2528   if (p_decl == program_type_symtable.end_value())
  2526   program_declaration_c *p_decl = iter->second;
  2529     /* should never occur. The program being called MUST be in the symtable... */
       
  2530     ERROR;
       
  2531 
  2527 
  2532   symbol->program_name->accept(*this);
  2528   symbol->program_name->accept(*this);
  2533   s4o.print("(");
  2529   s4o.print("(");
  2534 
  2530 
  2535   /* loop through each function parameter, find the value we should pass
  2531   /* loop through each function parameter, find the value we should pass