diff options
Diffstat (limited to 'src/gtkext/graph/nodes/flow.c')
-rw-r--r-- | src/gtkext/graph/nodes/flow.c | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/src/gtkext/graph/nodes/flow.c b/src/gtkext/graph/nodes/flow.c index 5173810..863d86c 100644 --- a/src/gtkext/graph/nodes/flow.c +++ b/src/gtkext/graph/nodes/flow.c @@ -299,6 +299,7 @@ static void g_flow_node_prepare_x_line(GFlowNode *node, GGraphNode *nodes) { GGraphNode *base; /* Autre vision de l'instance */ GArchInstruction *last; /* Dernière instr. du noeud */ + size_t loop_index; /* Indice de sortie en boucle */ GFlowNode *target; /* Bloc visé par le lien */ node_slot_t *dest_slot; /* Accrochage d'arrivée */ pending_position pos; /* Position à transmettre */ @@ -312,25 +313,52 @@ static void g_flow_node_prepare_x_line(GFlowNode *node, GGraphNode *nodes) g_flow_block_get_boundary(node->block, NULL, &last); - switch (node->exits_count) + for (loop_index = 0; loop_index < node->exits_count; loop_index++) + if (node->exits[loop_index].type == ILT_LOOP) + break; + + switch (node->exits_count - (loop_index == node->exits_count ? 0 : 1)) { case 0: break; case 1: - if (node->exits[0].type == ILT_LOOP) - break; + if (loop_index == node->exits_count) + { + target = G_FLOW_NODE(find_node_for_instruction(nodes, node->exits[0].instr)); + + dest_slot = g_flow_node_get_slot(target, true, + last, node->exits[0].group_index); - target = G_FLOW_NODE(find_node_for_instruction(nodes, node->exits[0].instr)); + } + else + { + target = G_FLOW_NODE(find_node_for_instruction(nodes, node->exits[1].instr)); - dest_slot = g_flow_node_get_slot(target, true, - last, node->exits[0].group_index); + dest_slot = g_flow_node_get_slot(target, true, + last, node->exits[1].group_index); + + } pos.direct_x = g_flow_node_get_slot_offset(target, true, dest_slot); pos.direct_x = (G_GRAPH_NODE(target)->alloc.width / 2) - pos.direct_x; - if (target->entries_count == 1) + pos.direct_x -= (G_GRAPH_NODE(target)->alloc.width - G_GRAPH_NODE(node)->alloc.width) / 2; + + size_t count_and_skip_loop(GFlowNode *n) + { + size_t counter; + + for (counter = 0; counter < n->entries_count; counter++) + if (n->entries[counter].type == ILT_LOOP) + break; + + return counter < n->entries_count ? n->entries_count - 1 : n->entries_count; + + } + + if (count_and_skip_loop(target) == 1) g_graph_node_set_pending_position(G_GRAPH_NODE(target), PPF_DIRECT_X, pos, base); break; @@ -678,7 +706,7 @@ static void g_flow_node_setup_entry_slots(GFlowNode *node) node->entries[used].type = types[i]; node->entries[used].group_index = g_arch_instruction_compute_group_index(&instrs[i], - instrs, icount); + instrs, icount); node->entries[used].slot_index = i; used++; @@ -769,7 +797,7 @@ static void g_flow_node_setup_exit_slots(GFlowNode *node) node->exits[used].type = types[i]; node->exits[used].group_index = g_arch_instruction_compute_group_index(&instrs[i], - instrs, icount); + instrs, icount); node->exits[used].slot_index = i; used++; |