summaryrefslogtreecommitdiff
path: root/src/gtkext/graph/nodes
diff options
context:
space:
mode:
Diffstat (limited to 'src/gtkext/graph/nodes')
-rw-r--r--src/gtkext/graph/nodes/flow.c144
1 files changed, 126 insertions, 18 deletions
diff --git a/src/gtkext/graph/nodes/flow.c b/src/gtkext/graph/nodes/flow.c
index 7ebaf78..5173810 100644
--- a/src/gtkext/graph/nodes/flow.c
+++ b/src/gtkext/graph/nodes/flow.c
@@ -24,6 +24,9 @@
#include "flow.h"
+#include <assert.h>
+
+
#include "../layout.h"
#include "../node-int.h"
@@ -242,8 +245,13 @@ GGraphNode *g_flow_node_new(GFlowBlock *block, GtkBufferView *view)
result->block = block;
result->view = view;
+ gtk_widget_show(GTK_WIDGET(result->view));
+ gtk_widget_size_allocate(GTK_WIDGET(result->view), (GtkAllocation []) { { 0, 0, 100, 100 } });
+
gtk_widget_get_preferred_size(GTK_WIDGET(result->view), NULL, &requisition);
+ printf("PREFERED :: (%d ; %d)\n", requisition.width, requisition.height);
+
G_GRAPH_NODE(result)->alloc.width = requisition.width;
G_GRAPH_NODE(result)->alloc.height = requisition.height;
@@ -614,26 +622,76 @@ static void g_flow_node_setup_entry_slots(GFlowNode *node)
GArchInstruction **instrs; /* Instr. visée par une autre */
InstructionLinkType *types; /* Type de lien entre lignes */
size_t icount; /* Nombre de liens de dest. */
+ size_t usable; /* Nombre de liens utiles ici */
size_t i; /* Boucle de parcours */
+ size_t used; /* Nombre de liens utilisés */
g_flow_block_get_boundary(node->block, &first, NULL);
icount = g_arch_instruction_get_sources(first, &instrs, &types);
- node->entries = (node_slot_t *)calloc(icount, sizeof(node_slot_t));
- node->entries_count = icount;
+ usable = 0;
for (i = 0; i < icount; i++)
- {
- g_object_ref(instrs[i]);
- node->entries[i].instr = instrs[i];
+ switch (types[i])
+ {
+ case ILT_EXEC_FLOW:
+ case ILT_JUMP:
+ case ILT_CASE_JUMP:
+ case ILT_JUMP_IF_TRUE:
+ case ILT_JUMP_IF_FALSE:
+ case ILT_LOOP:
+ case ILT_CATCH_EXCEPTION:
+ usable++;
+ break;
- node->entries[i].type = types[i];
- node->entries[i].group_index = g_arch_instruction_compute_group_index(&instrs[i],
- instrs, icount);
- node->entries[i].slot_index = i;
+ default:
+ break;
+ }
+
+ if (usable == 0)
+ {
+ node->entries = NULL;
+ node->entries_count = 0;
+ }
+ else
+ {
+ node->entries = (node_slot_t *)calloc(usable, sizeof(node_slot_t));
+ node->entries_count = usable;
}
+ used = 0;
+
+ for (i = 0; i < icount; i++)
+ switch (types[i])
+ {
+ case ILT_EXEC_FLOW:
+ case ILT_JUMP:
+ case ILT_CASE_JUMP:
+ case ILT_JUMP_IF_TRUE:
+ case ILT_JUMP_IF_FALSE:
+ case ILT_LOOP:
+ case ILT_CATCH_EXCEPTION:
+
+ g_object_ref(instrs[i]);
+ node->entries[used].instr = instrs[i];
+
+ node->entries[used].type = types[i];
+ node->entries[used].group_index = g_arch_instruction_compute_group_index(&instrs[i],
+ instrs, icount);
+ node->entries[used].slot_index = i;
+
+ used++;
+
+ break;
+
+ default:
+ break;
+
+ }
+
+ assert(used == usable);
+
}
@@ -655,25 +713,75 @@ static void g_flow_node_setup_exit_slots(GFlowNode *node)
GArchInstruction **instrs; /* Instr. visée par une autre */
InstructionLinkType *types; /* Type de lien entre lignes */
size_t icount; /* Nombre de liens de dest. */
+ size_t usable; /* Nombre de liens utiles ici */
size_t i; /* Boucle de parcours */
+ size_t used; /* Nombre de liens utilisés */
g_flow_block_get_boundary(node->block, NULL, &last);
icount = g_arch_instruction_get_destinations(last, &instrs, &types, NULL);
- node->exits = (node_slot_t *)calloc(icount, sizeof(node_slot_t));
- node->exits_count = icount;
+ usable = 0;
for (i = 0; i < icount; i++)
- {
- g_object_ref(instrs[i]);
- node->exits[i].instr = instrs[i];
+ switch (types[i])
+ {
+ case ILT_EXEC_FLOW:
+ case ILT_JUMP:
+ case ILT_CASE_JUMP:
+ case ILT_JUMP_IF_TRUE:
+ case ILT_JUMP_IF_FALSE:
+ case ILT_LOOP:
+ case ILT_CATCH_EXCEPTION:
+ usable++;
+ break;
- node->exits[i].type = types[i];
- node->exits[i].group_index = g_arch_instruction_compute_group_index(&instrs[i],
- instrs, icount);
- node->exits[i].slot_index = i;
+ default:
+ break;
+ }
+
+ if (usable == 0)
+ {
+ node->exits = NULL;
+ node->exits_count = 0;
}
+ else
+ {
+ node->exits = (node_slot_t *)calloc(usable, sizeof(node_slot_t));
+ node->exits_count = usable;
+ }
+
+ used = 0;
+
+ for (i = 0; i < icount; i++)
+ switch (types[i])
+ {
+ case ILT_EXEC_FLOW:
+ case ILT_JUMP:
+ case ILT_CASE_JUMP:
+ case ILT_JUMP_IF_TRUE:
+ case ILT_JUMP_IF_FALSE:
+ case ILT_LOOP:
+ case ILT_CATCH_EXCEPTION:
+
+ g_object_ref(instrs[i]);
+ node->exits[used].instr = instrs[i];
+
+ node->exits[used].type = types[i];
+ node->exits[used].group_index = g_arch_instruction_compute_group_index(&instrs[i],
+ instrs, icount);
+ node->exits[used].slot_index = i;
+
+ used++;
+
+ break;
+
+ default:
+ break;
+
+ }
+
+ assert(used == usable);
}