00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <circular.h>
00019 #include <block.h>
00020 #include <assert.h>
00021
00022 void initBlocklist(blocklist_t * bl)
00023 {
00024 bl->first = NULL;
00025 bl->last = NULL;
00026 }
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 block_t *mkBlock(Agraph_t * g)
00044 {
00045 block_t *sn;
00046
00047 sn = NEW(block_t);
00048 initBlocklist(&sn->children);
00049 sn->sub_graph = g;
00050 return sn;
00051 }
00052
00053 void freeBlock(block_t * sp)
00054 {
00055 if (!sp)
00056 return;
00057 freeNodelist(sp->circle_list);
00058 free(sp);
00059 }
00060
00061
00062
00063
00064 void appendBlock(blocklist_t * bl, block_t * bp)
00065 {
00066 bp->next = NULL;
00067 if (bl->last) {
00068 bl->last->next = bp;
00069 bl->last = bp;
00070 } else {
00071 bl->first = bp;
00072 bl->last = bp;
00073 }
00074 }
00075
00076
00077
00078
00079 void insertBlock(blocklist_t * bl, block_t * bp)
00080 {
00081 if (bl->first) {
00082 bp->next = bl->first;
00083 bl->first = bp;
00084 } else {
00085 bl->first = bp;
00086 bl->last = bp;
00087 }
00088 }
00089
00090 #ifdef DEBUG
00091 void printBlocklist(blocklist_t * snl)
00092 {
00093 block_t *bp;
00094 for (bp = snl->first; bp; bp = bp->next) {
00095 Agnode_t *n;
00096 char *p;
00097 Agraph_t *g = bp->sub_graph;
00098 fprintf(stderr, "block=%s\n", g->name);
00099 for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
00100 Agedge_t *e;
00101 if (PARENT(n))
00102 p = PARENT(n)->name;
00103 else
00104 p = "<nil>";
00105 fprintf(stderr, " %s (%d %s)\n", n->name, VAL(n), p);
00106 for (e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) {
00107 fprintf(stderr, " %s--%s\n", e->tail->name,
00108 e->head->name);
00109 }
00110 }
00111 }
00112 }
00113 #endif