absyntax_utils/get_datatype_info.cc
changeset 986 2064a22cc1f2
parent 958 7474d2cd1d6e
child 987 562b67922966
equal deleted inserted replaced
985:837c6532a9b8 986:2064a22cc1f2
   675   // comparison of each subrange start and end elements
   675   // comparison of each subrange start and end elements
   676   for (int i = 0; i < subrange_list_1->n; i++) {
   676   for (int i = 0; i < subrange_list_1->n; i++) {
   677     subrange_c *subrange_1 = dynamic_cast<subrange_c *>(subrange_list_1->elements[i]);
   677     subrange_c *subrange_1 = dynamic_cast<subrange_c *>(subrange_list_1->elements[i]);
   678     subrange_c *subrange_2 = dynamic_cast<subrange_c *>(subrange_list_2->elements[i]);
   678     subrange_c *subrange_2 = dynamic_cast<subrange_c *>(subrange_list_2->elements[i]);
   679     if ((NULL == subrange_1) || (NULL == subrange_2)) ERROR;
   679     if ((NULL == subrange_1) || (NULL == subrange_2)) ERROR;
   680     #if 0
   680     
   681     /* An alternative method of checking whether the subranges have the same values, using the result of the constant folding agorithm.
   681     /* check whether the subranges have the same values, using the result of the constant folding agorithm.
   682      * This method has the drawback that it inserts a dependency on having to run the constant folding algorithm before
   682      * This method has the drawback that it inserts a dependency on having to run the constant folding algorithm before
   683      *  the get_datatype_info_c::is_type_equal() method is called.
   683      *  the get_datatype_info_c::is_type_equal() method is called.
   684      * The probably slower alternative of comparing the strings themselves is therefor used.
   684      *  This is why we implement an alternative method in case the subrange limits have not yet been reduced to a cvalue!
   685      */
   685      */
   686     if (!constant_folding_c::is_equal_cvalue(subrange_1->lower_limit, subrange_2->lower_limit)) return false;
   686     if (    (subrange_1->lower_limit->const_value._int64.is_valid() || subrange_1->lower_limit->const_value._uint64.is_valid())
   687     if (!constant_folding_c::is_equal_cvalue(subrange_1->upper_limit, subrange_2->upper_limit)) return false;
   687          && (subrange_2->lower_limit->const_value._int64.is_valid() || subrange_2->lower_limit->const_value._uint64.is_valid())
   688     #endif
   688          && (subrange_1->upper_limit->const_value._int64.is_valid() || subrange_1->upper_limit->const_value._uint64.is_valid())
   689     if (normalize_integer(subrange_1->lower_limit) != normalize_integer(subrange_2->lower_limit)) return false;
   689          && (subrange_2->upper_limit->const_value._int64.is_valid() || subrange_2->upper_limit->const_value._uint64.is_valid())
   690     if (normalize_integer(subrange_1->upper_limit) != normalize_integer(subrange_2->upper_limit)) return false;
   690        ) {
       
   691       if (! (subrange_1->lower_limit->const_value == subrange_2->lower_limit->const_value)) return false;
       
   692       if (! (subrange_1->upper_limit->const_value == subrange_2->upper_limit->const_value)) return false;
       
   693     } else {
       
   694       if (normalize_integer(subrange_1->lower_limit) != normalize_integer(subrange_2->lower_limit)) return false;
       
   695       if (normalize_integer(subrange_1->upper_limit) != normalize_integer(subrange_2->upper_limit)) return false;
       
   696     }
   691   }
   697   }
   692 
   698 
   693   return is_type_equal(search_base_type_c::get_basetype_decl(array_1->non_generic_type_name),
   699   return is_type_equal(search_base_type_c::get_basetype_decl(array_1->non_generic_type_name),
   694                        search_base_type_c::get_basetype_decl(array_2->non_generic_type_name));
   700                        search_base_type_c::get_basetype_decl(array_2->non_generic_type_name));
   695 }
   701 }