Пример #1
0
/**
 * osl_scop_equal function:
 * this function returns true if the two scops are the same, false
 * otherwise (the usr field is not tested).
 * \param s1 The first scop.
 * \param s2 The second scop.
 * \return 1 if s1 and s2 are the same (content-wise), 0 otherwise.
 */
int osl_scop_equal(osl_scop_p s1, osl_scop_p s2) {

  while ((s1 != NULL) && (s2 != NULL)) {
    if (s1 == s2)
      return 1;

    if (s1->version != s2->version) {
      OSL_info("versions are not the same"); 
      return 0;
    }

    if (strcmp(s1->language, s2->language) != 0) {
      OSL_info("languages are not the same"); 
      return 0;
    }

    if (!osl_relation_equal(s1->context, s2->context)) {
      OSL_info("contexts are not the same"); 
      return 0;
    }

    if (!osl_generic_equal(s1->parameters, s2->parameters)) {
      OSL_info("parameters are not the same"); 
      return 0;
    }

    if (!osl_statement_equal(s1->statement, s2->statement)) {
      OSL_info("statements are not the same"); 
      return 0;
    }

    if (!osl_interface_equal(s1->registry, s2->registry)) {
      OSL_info("registries are not the same"); 
      return 0;
    }

    if (!osl_generic_equal(s1->extension, s2->extension)) {
      OSL_info("extensions are not the same"); 
      return 0;
    }

    s1 = s1->next;
    s2 = s2->next;
  }
  
  if (((s1 == NULL) && (s2 != NULL)) || ((s1 != NULL) && (s2 == NULL)))
    return 0;

  return 1;
}
Пример #2
0
/**
 * @brief Aggregate two osl_generic together (cloning the necessary structures).
 * The parameters are not modified. If two generics are found, only one is kept (like a union).
 *
 * @param gen1 A pointer to the first osl_generic.
 * @param gen2 A pointer to the first osl_generic.
 *
 * @return The aggregation of two osl_generic.
 */
struct osl_generic * substrate_osl_generic_fusion(
        struct osl_generic * gen1,
        struct osl_generic * gen2)
{
    struct osl_generic * res = NULL, *tmp1 = NULL, *tmp2 = NULL;
    struct osl_generic * new_generic = NULL;

    tmp1 = gen1;
    while(tmp1 != NULL)
    {
        tmp2 = substrate_osl_generic_lookup(gen2, tmp1->interface->URI);
        if(tmp2 == NULL)
        {
            osl_generic_add(&res, substrate_osl_generic_nclone(tmp1,1));
        }
        else if(osl_generic_equal(tmp1, tmp2))
        {
            if(strcmp(tmp1->interface->URI,"body") == 0)
            {
                new_generic = osl_generic_malloc();
                new_generic->interface = osl_body_interface();
                new_generic->next = NULL;
                new_generic->data = substrate_osl_body_fusion(tmp1->data,tmp2->data);

                osl_generic_add(&res, new_generic);
            }
            else
            {
                osl_generic_add(&res, substrate_osl_generic_nclone(tmp1,1));
            }
        }
        else
        {
            if(strcmp(tmp1->interface->URI,"body") == 0)
            {
                new_generic = osl_generic_malloc();
                new_generic->interface = osl_body_interface();
                new_generic->next = NULL;
                new_generic->data = substrate_osl_body_fusion(tmp1->data,tmp2->data);

                osl_generic_add(&res, new_generic);
            }
            else
            {
                OSL_warning("Can't fusion the generic structures : don't know how.");
                fprintf(stderr,"URI : %s\n", tmp1->interface->URI);
            }
        }
        tmp1 = tmp1->next;
    }

    return res;
}