absyntax_utils/search_constant_type.cc
changeset 625 c0bda77b37a0
parent 596 4efb11e44065
equal deleted inserted replaced
412:aad38592bdde 625:c0bda77b37a0
    42 
    42 
    43 
    43 
    44 #include "../util/symtable.hh"
    44 #include "../util/symtable.hh"
    45 #include "search_constant_type.hh"
    45 #include "search_constant_type.hh"
    46 #include "absyntax_utils.hh"
    46 #include "absyntax_utils.hh"
       
    47 #include "../main.hh" // required for ERROR() and ERROR_MSG() macros.
    47 
    48 
    48 
    49 
    49 #define ERROR error_exit(__FILE__,__LINE__)
       
    50 /* function defined in main.cc */
       
    51 extern void error_exit(const char *file_name, int line_no);
       
    52 
    50 
    53 symbol_c *search_constant_type_c::get_type(symbol_c *constant) {
    51 symbol_c *search_constant_type_c::get_type(symbol_c *constant) {
    54   return (symbol_c *)constant->accept(*this);
    52   return (symbol_c *)constant->accept(*this);
    55 }
    53 }
    56 
    54 
   103 /* B 1.2.3.1 - Duration */
   101 /* B 1.2.3.1 - Duration */
   104 /************************/
   102 /************************/
   105 void *search_constant_type_c::visit(neg_time_c *symbol) {ERROR; return NULL;}  /* this member function should never be called. */
   103 void *search_constant_type_c::visit(neg_time_c *symbol) {ERROR; return NULL;}  /* this member function should never be called. */
   106 void *search_constant_type_c::visit(duration_c *symbol) {return (void *)(symbol->type_name);}
   104 void *search_constant_type_c::visit(duration_c *symbol) {return (void *)(symbol->type_name);}
   107 void *search_constant_type_c::visit(fixed_point_c *symbol) {ERROR; return NULL;}  /* this member function should never be called. */
   105 void *search_constant_type_c::visit(fixed_point_c *symbol) {ERROR; return NULL;}  /* this member function should never be called. */
   108 void *search_constant_type_c::visit(days_c *symbol) {ERROR; return NULL;}  /* this member function should never be called. */
   106 void *search_constant_type_c::visit(interval_c *symbol) {ERROR; return NULL;}  /* this member function should never be called. */
   109 void *search_constant_type_c::visit(hours_c *symbol) {ERROR; return NULL;}  /* this member function should never be called. */
       
   110 void *search_constant_type_c::visit(minutes_c *symbol) {ERROR; return NULL;}  /* this member function should never be called. */
       
   111 void *search_constant_type_c::visit(seconds_c *symbol) {ERROR; return NULL;}  /* this member function should never be called. */
       
   112 void *search_constant_type_c::visit(milliseconds_c *symbol) {ERROR; return NULL;}  /* this member function should never be called. */
       
   113 
   107 
   114 /************************************/
   108 /************************************/
   115 /* B 1.2.3.2 - Time of day and Date */
   109 /* B 1.2.3.2 - Time of day and Date */
   116 /************************************/
   110 /************************************/
   117 void *search_constant_type_c::visit(time_of_day_c *symbol) {return (void *)(symbol->type_name);}
   111 void *search_constant_type_c::visit(time_of_day_c *symbol) {return (void *)(symbol->type_name);}
   131   if (value_type == enumerated_value_symtable.end_value())
   125   if (value_type == enumerated_value_symtable.end_value())
   132     return NULL;
   126     return NULL;
   133   return (void *)value_type;
   127   return (void *)value_type;
   134 }
   128 }
   135 
   129 
       
   130 
       
   131 
       
   132 
       
   133 invalid_type_name_c  search_constant_type_c::invalid_type_name;
       
   134 
       
   135 
   136 real_type_name_c     search_constant_type_c::real_type_name;
   136 real_type_name_c     search_constant_type_c::real_type_name;
   137 sint_type_name_c     search_constant_type_c::sint_type_name;
   137 sint_type_name_c     search_constant_type_c::sint_type_name;
   138 lint_type_name_c     search_constant_type_c::lint_type_name;
   138 lint_type_name_c     search_constant_type_c::lint_type_name;
   139 dint_type_name_c     search_constant_type_c::dint_type_name;
   139 dint_type_name_c     search_constant_type_c::dint_type_name;
   140 date_type_name_c     search_constant_type_c::date_type_name;
   140 date_type_name_c     search_constant_type_c::date_type_name;
   153 ulint_type_name_c    search_constant_type_c::ulint_type_name;
   153 ulint_type_name_c    search_constant_type_c::ulint_type_name;
   154 bool_type_name_c     search_constant_type_c::bool_type_name;
   154 bool_type_name_c     search_constant_type_c::bool_type_name;
   155 time_type_name_c     search_constant_type_c::time_type_name;
   155 time_type_name_c     search_constant_type_c::time_type_name;
   156 int_type_name_c      search_constant_type_c::int_type_name;
   156 int_type_name_c      search_constant_type_c::int_type_name;
   157 
   157 
   158 // safebool_type_name_c    search_constant_type_c::safebool_type_name;
       
   159   /* The following is required because the expression (TOD_var - TOD_var) will result in a data type
       
   160    *  (in this case, TIME) that is neither of the expression elements...
       
   161    */
       
   162 safetime_type_name_c     search_constant_type_c::safetime_type_name;
   158 safetime_type_name_c     search_constant_type_c::safetime_type_name;
   163 safetod_type_name_c      search_constant_type_c::safetod_type_name;
   159 safetod_type_name_c      search_constant_type_c::safetod_type_name;
   164 safedt_type_name_c       search_constant_type_c::safedt_type_name;
   160 safedt_type_name_c       search_constant_type_c::safedt_type_name;
       
   161 safedate_type_name_c     search_constant_type_c::safedate_type_name;
       
   162 safereal_type_name_c     search_constant_type_c::safereal_type_name;
       
   163 safesint_type_name_c     search_constant_type_c::safesint_type_name;
       
   164 safelint_type_name_c     search_constant_type_c::safelint_type_name;
       
   165 safedint_type_name_c     search_constant_type_c::safedint_type_name;
       
   166 safedword_type_name_c    search_constant_type_c::safedword_type_name;
       
   167 safeudint_type_name_c    search_constant_type_c::safeudint_type_name;
       
   168 safeword_type_name_c     search_constant_type_c::safeword_type_name;
       
   169 safewstring_type_name_c  search_constant_type_c::safewstring_type_name;
       
   170 safestring_type_name_c   search_constant_type_c::safestring_type_name;
       
   171 safelword_type_name_c    search_constant_type_c::safelword_type_name;
       
   172 safeuint_type_name_c     search_constant_type_c::safeuint_type_name;
       
   173 safelreal_type_name_c    search_constant_type_c::safelreal_type_name;
       
   174 safebyte_type_name_c     search_constant_type_c::safebyte_type_name;
       
   175 safeusint_type_name_c    search_constant_type_c::safeusint_type_name;
       
   176 safeulint_type_name_c    search_constant_type_c::safeulint_type_name;
       
   177 safebool_type_name_c     search_constant_type_c::safebool_type_name;
       
   178 safeint_type_name_c      search_constant_type_c::safeint_type_name;
   165 
   179 
   166 
   180 
   167 
       
   168 /* temporarily here until we remove the st_code_gen.c and il_code_gen.c files... */
       
   169 /* It should then move to search_expression_type_c                               */
       
   170 integer_c search_constant_type_c::integer("1");
       
   171 real_c search_constant_type_c::real("1.0");