diff options
Diffstat (limited to 'src/graph')
-rw-r--r-- | src/graph/layout.c | 92 |
1 files changed, 34 insertions, 58 deletions
diff --git a/src/graph/layout.c b/src/graph/layout.c index 725d76c..0b4a6c6 100644 --- a/src/graph/layout.c +++ b/src/graph/layout.c @@ -127,77 +127,53 @@ static char *complete_graph_links(const GtkGraphView *view, GtkBinView **views, { size_t i; /* Boucle de parcours #1 */ GRenderingLine *last; /* Dernière ligne d'un bloc */ - GRenderingLine *dest; /* Ligne visée par une autre */ - InstructionLinkType type; /* Type de lien entre lignes */ - bool link_next; /* Lien auto. avec la suivante */ + GRenderingLine **dests; /* Ligne visée par une autre */ + InstructionLinkType *types; /* Type de lien entre lignes */ + size_t dcount; /* Nombre de liens de dest. */ + size_t j; /* Boucle de parcours #2 */ vmpa_t addr; /* Addresse de destination */ - size_t k; /* Boucle de parcours #2 */ + size_t k; /* Boucle de parcours #3 */ char buffer[LINKS_DESC_LEN]; /* Tampon pour l'ajout de liens*/ + GRenderingLine *next; /* Ligne suivante dans le flux */ for (i = 0; i < count; i++) { last = gtk_bin_view_get_last_line(views[i]); - if (g_rendering_line_has_destination(last)) + if (g_rendering_line_has_destinations(last)) { - link_next = false; + dcount = g_rendering_line_get_destinations(last, &dests, &types); - /* Premier saut : exigé par l'instruction */ - - dest = g_rendering_line_get_destination(last, &type); - - addr = get_rendering_line_address(dest); - - for (k = 0; k < count; k++) - if (gtk_bin_view_contain_address(views[k], addr)) - break; - - if (k < count) - switch (type) - { - case ILT_JUMP: - snprintf(buffer, LINKS_DESC_LEN, "_%p -> _%p;\n", views[i], views[k]); - desc = stradd(desc, buffer); - break; - - case ILT_JUMP_IF_TRUE: - snprintf(buffer, LINKS_DESC_LEN, "_%p -> _%p;\n", views[i], views[k]); - desc = stradd(desc, buffer); - link_next = true; - break; - - case ILT_JUMP_IF_FALSE: - snprintf(buffer, LINKS_DESC_LEN, "_%p -> _%p;\n", views[i], views[k]); - desc = stradd(desc, buffer); - link_next = true; - break; - - default: - break; - - } - - /* Second saut : automatique selon l'instruction */ - - if (link_next) + for (j = 0; j < dcount; j++) { - dest = g_rendering_line_get_next_iter(gtk_bin_view_get_lines(GTK_BIN_VIEW(view)), - last, - gtk_bin_view_get_last_line(GTK_BIN_VIEW(view))); - - if (dest == NULL) continue; - - addr = get_rendering_line_address(dest); + addr = get_rendering_line_address(dests[j]); for (k = 0; k < count; k++) if (gtk_bin_view_contain_address(views[k], addr)) break; if (k < count) - { - snprintf(buffer, LINKS_DESC_LEN, "_%p -> _%p;\n", views[i], views[k]); - desc = stradd(desc, buffer); - } + switch (types[j]) + { + case ILT_JUMP: + snprintf(buffer, LINKS_DESC_LEN, "_%p -> _%p;\n", views[i], views[k]); + desc = stradd(desc, buffer); + break; + + case ILT_JUMP_IF_TRUE: + snprintf(buffer, LINKS_DESC_LEN, "_%p -> _%p;\n", views[i], views[k]); + desc = stradd(desc, buffer); + break; + + case ILT_JUMP_IF_FALSE: + snprintf(buffer, LINKS_DESC_LEN, "_%p -> _%p;\n", views[i], views[k]); + desc = stradd(desc, buffer); + break; + + default: + break; + + } } @@ -206,13 +182,13 @@ static char *complete_graph_links(const GtkGraphView *view, GtkBinView **views, /* Si la ligne n'est pas la dernière, on suit le flux normal */ else if (last != gtk_bin_view_get_last_line(view)) { - dest = g_rendering_line_get_next_iter(gtk_bin_view_get_lines(GTK_BIN_VIEW(view)), + next = g_rendering_line_get_next_iter(gtk_bin_view_get_lines(GTK_BIN_VIEW(view)), last, gtk_bin_view_get_last_line(GTK_BIN_VIEW(view))); - if (dest == NULL) continue; + if (next == NULL) continue; - addr = get_rendering_line_address(dest); + addr = get_rendering_line_address(next); for (k = 0; k < count; k++) if (gtk_bin_view_contain_address(views[k], addr)) |