diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2009-07-15 22:04:38 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2009-07-15 22:04:38 (GMT) |
commit | 293f9f24c6338b5d41dd8f613aefae6be9bdbfcb (patch) | |
tree | 2edadc11a52af0a37b89e057fd51bb6ecde834e7 /src/graph | |
parent | b8ebd9e4d8f90c8ae8860d2a09f619a14c91715e (diff) |
Stored several destinations for each line when needed.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@95 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
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)) |