absyntax_utils/search_constant_type.cc
changeset 202 da1a8186f86f
parent 194 e18690830555
child 257 90782e241346
equal deleted inserted replaced
201:e657008f43d0 202:da1a8186f86f
    49 /*********************/
    49 /*********************/
    50 
    50 
    51 /******************************/
    51 /******************************/
    52 /* B 1.2.1 - Numeric Literals */
    52 /* B 1.2.1 - Numeric Literals */
    53 /******************************/
    53 /******************************/
    54 void *search_constant_type_c::visit(real_c *symbol) {return (void *)&constant_real_type_name;}
    54 /* Numeric literals without any explicit type cast have unknown data type, 
    55 void *search_constant_type_c::visit(integer_c *symbol) {return (void *)&constant_int_type_name;}
    55   * so we continue considering them as their own basic data types until
    56 void *search_constant_type_c::visit(binary_integer_c *symbol) {return (void *)&constant_int_type_name;}
    56   * they can be resolved (for example, when using '30+x' where 'x' is a LINT variable, the
    57 void *search_constant_type_c::visit(octal_integer_c *symbol) {return (void *)&constant_int_type_name;}
    57   * numeric literal '30' must then be considered a LINT so the ADD function may be called
    58 void *search_constant_type_c::visit(hex_integer_c *symbol) {return (void *)&constant_int_type_name;}
    58   * with all inputs of the same data type.
       
    59   * If 'x' were a SINT, then the '30' would have to be a SINT too!
       
    60   */
       
    61 void *search_constant_type_c::visit(real_c *symbol)           {return (void *)symbol;}
       
    62 void *search_constant_type_c::visit(integer_c *symbol)        {return (void *)symbol;}
       
    63 void *search_constant_type_c::visit(binary_integer_c *symbol) {return (void *)symbol;}
       
    64 void *search_constant_type_c::visit(octal_integer_c *symbol)  {return (void *)symbol;}
       
    65 void *search_constant_type_c::visit(hex_integer_c *symbol)    {return (void *)symbol;}
    59 
    66 
    60 void *search_constant_type_c::visit(numeric_literal_c *symbol)
       
    61   {return (void *)((symbol->type!=NULL)?symbol->type:symbol->value->accept(*this));}
       
    62 void *search_constant_type_c::visit(integer_literal_c *symbol)
    67 void *search_constant_type_c::visit(integer_literal_c *symbol)
    63   {return (void *)((symbol->type!=NULL)?symbol->type:symbol->value->accept(*this));}
    68   {return (void *)((symbol->type!=NULL)?symbol->type:symbol->value->accept(*this));}
    64 void *search_constant_type_c::visit(real_literal_c *symbol)
    69 void *search_constant_type_c::visit(real_literal_c *symbol)
    65   {return (void *)((symbol->type!=NULL)?symbol->type:symbol->value->accept(*this));}
    70   {return (void *)((symbol->type!=NULL)?symbol->type:symbol->value->accept(*this));}
    66 void *search_constant_type_c::visit(bit_string_literal_c *symbol)
    71 void *search_constant_type_c::visit(bit_string_literal_c *symbol)
    67   {return (void *)((symbol->type!=NULL)?symbol->type:symbol->value->accept(*this));}
    72   {return (void *)((symbol->type!=NULL)?symbol->type:symbol->value->accept(*this));}
    68 void *search_constant_type_c::visit(boolean_literal_c *symbol)
    73 void *search_constant_type_c::visit(boolean_literal_c *symbol)
    69   {return (void *)((symbol->type!=NULL)?symbol->type:symbol->value->accept(*this));}
    74   {return (void *)((symbol->type!=NULL)?symbol->type:symbol->value->accept(*this));}
       
    75 
       
    76 void *search_constant_type_c::visit(boolean_true_c *symbol)   {return (void *)symbol;}
       
    77 void *search_constant_type_c::visit(boolean_false_c *symbol)  {return (void *)symbol;}
       
    78 
    70 
    79 
    71 /*******************************/
    80 /*******************************/
    72 /* B.1.2.2   Character Strings */
    81 /* B.1.2.2   Character Strings */
    73 /*******************************/
    82 /*******************************/
    74 void *search_constant_type_c::visit(double_byte_character_string_c *symbol) {return (void *)&wstring_type_name;}
    83 void *search_constant_type_c::visit(double_byte_character_string_c *symbol) {return (void *)&wstring_type_name;}
   101 real_type_name_c     search_constant_type_c::real_type_name;
   110 real_type_name_c     search_constant_type_c::real_type_name;
   102 sint_type_name_c     search_constant_type_c::sint_type_name;
   111 sint_type_name_c     search_constant_type_c::sint_type_name;
   103 lint_type_name_c     search_constant_type_c::lint_type_name;
   112 lint_type_name_c     search_constant_type_c::lint_type_name;
   104 dint_type_name_c     search_constant_type_c::dint_type_name;
   113 dint_type_name_c     search_constant_type_c::dint_type_name;
   105 date_type_name_c     search_constant_type_c::date_type_name;
   114 date_type_name_c     search_constant_type_c::date_type_name;
   106 dword_type_name_c     search_constant_type_c::dword_type_name;
   115 dword_type_name_c    search_constant_type_c::dword_type_name;
   107 dt_type_name_c     search_constant_type_c::dt_type_name;
   116 dt_type_name_c       search_constant_type_c::dt_type_name;
   108 tod_type_name_c     search_constant_type_c::tod_type_name;
   117 tod_type_name_c      search_constant_type_c::tod_type_name;
   109 udint_type_name_c     search_constant_type_c::udint_type_name;
   118 udint_type_name_c    search_constant_type_c::udint_type_name;
   110 word_type_name_c     search_constant_type_c::word_type_name;
   119 word_type_name_c     search_constant_type_c::word_type_name;
   111 wstring_type_name_c     search_constant_type_c::wstring_type_name;
   120 wstring_type_name_c  search_constant_type_c::wstring_type_name;
   112 string_type_name_c     search_constant_type_c::string_type_name;
   121 string_type_name_c   search_constant_type_c::string_type_name;
   113 lword_type_name_c     search_constant_type_c::lword_type_name;
   122 lword_type_name_c    search_constant_type_c::lword_type_name;
   114 uint_type_name_c     search_constant_type_c::uint_type_name;
   123 uint_type_name_c     search_constant_type_c::uint_type_name;
   115 lreal_type_name_c     search_constant_type_c::lreal_type_name;
   124 lreal_type_name_c    search_constant_type_c::lreal_type_name;
   116 byte_type_name_c     search_constant_type_c::byte_type_name;
   125 byte_type_name_c     search_constant_type_c::byte_type_name;
   117 usint_type_name_c     search_constant_type_c::usint_type_name;
   126 usint_type_name_c    search_constant_type_c::usint_type_name;
   118 ulint_type_name_c     search_constant_type_c::ulint_type_name;
   127 ulint_type_name_c    search_constant_type_c::ulint_type_name;
   119 bool_type_name_c     search_constant_type_c::bool_type_name;
   128 bool_type_name_c     search_constant_type_c::bool_type_name;
   120 time_type_name_c     search_constant_type_c::time_type_name;
   129 time_type_name_c     search_constant_type_c::time_type_name;
   121 int_type_name_c     search_constant_type_c::int_type_name;
   130 int_type_name_c      search_constant_type_c::int_type_name;
   122 
   131 
       
   132 /*
   123 constant_real_type_name_c     search_constant_type_c::constant_real_type_name;
   133 constant_real_type_name_c     search_constant_type_c::constant_real_type_name;
   124 constant_int_type_name_c      search_constant_type_c::constant_int_type_name;
   134 constant_int_type_name_c      search_constant_type_c::constant_int_type_name;
       
   135 */
       
   136 /* temporarily here until we remove the st_code_gen.c and il_code_gen.c files... */
       
   137 /* It should then move to search_expression_type_c                               */
       
   138 integer_c search_constant_type_c::integer("1");