int noll_dform_array_check_entl (noll_var_array * lv1, noll_dform_array * df1, noll_var_array * lv2, noll_uid_array * m, noll_dform_array * df2) { // TODO: for the moment prited out into a file char *fname = (char *) malloc (20 * sizeof (char)); fname[0] = '\0'; snprintf (fname, 20, "df-%d.txt", ndform); ndform++; FILE *f = fopen (fname, "w"); fprintf (f, "lhs = ("); noll_var_array_fprint (f, lv1, "["); fprintf (f, "] "); noll_dform_array_fprint (f, lv1, df1); fprintf (f, ") \n==>\nrhs = ("); noll_var_array_fprint (f, lv2, "["); fprintf (f, "] x ["); for (uint_t i = 0; i < noll_vector_size (m); i++) fprintf (f, "%d -> %d,", i, noll_vector_at (m, i)); fprintf (f, "] "); noll_dform_array_fprint (f, lv2, df2); fprintf (f, ") \n"); fclose (f); free (fname); return 1; }
void noll_pure_fprint (FILE * f, noll_var_array * lvars, noll_pure_t * phi) { if (!phi || !phi->m) { fprintf (f, "null\n"); return; } for (uid_t l = 0; l < phi->size; l++) for (uid_t c = l; c < phi->size; c++) { fprintf (f, "%s", noll_var_name (lvars, l, NOLL_TYP_RECORD)); switch (noll_pure_matrix_at (phi, l, c)) { case NOLL_PURE_EQ: fprintf (f, "="); break; case NOLL_PURE_NEQ: fprintf (f, "<>"); break; default: fprintf (f, "#"); break; } fprintf (f, "%s, ", noll_var_name (lvars, c, NOLL_TYP_RECORD)); } noll_dform_array_fprint (f, lvars, phi->data); fprintf (f, "\n"); }
/** * Return the edge of @p g2 having label @p label between nodes @p args. * * @param args [inout] contains the mapping of arguments of the edge * on nodes of @p g or UNDEFINED_ID * @param df [inout] collect the equality constraints between data * required by the mapping found * @return the identifier of the edge matched or UNDEFINED_ID */ uint_t noll_graph_get_edge (noll_graph_t * g, noll_edge_e kind, uint_t label, noll_uid_array * args, noll_dform_array * df) { // store of edge identifier matching the searched edge uint_t uid_res = UNDEFINED_ID; // source and destination nodes for edge searched uint_t nroot = noll_vector_at (args, 0); // a new intermediary node uint_t nend = noll_vector_at (args, 1); uint_t fargs = noll_vector_size (args); uint_t shift_j = 0; if (noll_pred_isUnaryLoc (label) == true) { nend = 0; fargs++; shift_j++; } #ifndef NDEBUG fprintf (stdout, "\n---- Search for edge n%d---(kind=%d, label=%d)-->n%d:\n", nroot, kind, label, nend); #endif if (g->mat[nroot] != NULL) { for (uint_t i = 0; (i < noll_vector_size (g->mat[nroot])) && (uid_res == UNDEFINED_ID); i++) { uint_t ei = noll_vector_at (g->mat[nroot], i); noll_edge_t *edge_i = noll_vector_at (g->edges, ei); if ((edge_i->kind == kind) && (edge_i->label == label) && (noll_vector_size (edge_i->args) == fargs)) { #ifndef NDEBUG fprintf (stdout, "\t found e%d, same kind, label and root\n", ei); #endif // edge found with the same kind, label and root, // check the other arguments than source are equal bool ishom = true; for (uint_t j = 1; j < noll_vector_size (args) && (ishom == true); j++) { uint_t naj = noll_vector_at (args, j); uint_t nej = noll_vector_at (edge_i->args, j + shift_j); if (naj == UNDEFINED_ID) { #ifndef NDEBUG fprintf (stdout, "\t\t update arg %d to n%d\n", j, nej); #endif noll_uid_array_set (args, j, nej); } else if (naj != nej) { noll_typ_t ty = noll_graph_get_node_type (g, naj); if ((ty == NOLL_TYP_INT) || (ty == NOLL_TYP_BAGINT)) { // generate an equality constraint uid_t vaj = noll_graph_get_var (g, naj); uid_t vej = noll_graph_get_var (g, naj); noll_dform_t *df_eq = noll_dform_new_eq (noll_dterm_new_var (vaj, ty), noll_dterm_new_var (vej, ty)); noll_dform_array_push (df, df_eq); } else { // if it is a location node, then error #ifndef NDEBUG fprintf (stdout, "\t\t but different arg %d (n%d != n%d)\n", j, naj, nej); #endif ishom = false; } } } if (ishom == true) { #ifndef NDEBUG fprintf (stdout, "\t\t , the same args, and the df = "); noll_dform_array_fprint (stdout, g->lvars, df); #endif uid_res = ei; } } } } #ifndef NDEBUG fprintf (stdout, "\t edge-%d matches!\n", uid_res); #endif if (uid_res == UNDEFINED_ID) noll_dform_array_clear (df); // TODO: free also the pointers inside return uid_res; }