Lines Matching refs:topo
116 static void addEdge (pANTLR3_TOPO topo, ANTLR3_UINT32 edge, ANTLR3_UINT32 depe…
117 static pANTLR3_UINT32 sortToArray (pANTLR3_TOPO topo);
118 static void sortVector (pANTLR3_TOPO topo, pANTLR3_VECTOR v);
119 static void freeTopo (pANTLR3_TOPO topo);
2286 pANTLR3_TOPO topo = (pANTLR3_TOPO)ANTLR3_MALLOC(sizeof(ANTLR3_TOPO)); in antlr3TopoNew() local
2288 if (topo == NULL) in antlr3TopoNew()
2296 topo->visited = NULL; // Don't know how big it is yet in antlr3TopoNew()
2297 topo->limit = 1; // No edges added yet in antlr3TopoNew()
2298 topo->edges = NULL; // No edges added yet in antlr3TopoNew()
2299 topo->sorted = NULL; // Nothing sorted at the start in antlr3TopoNew()
2300 topo->cycle = NULL; // No cycles at the start in antlr3TopoNew()
2301 topo->cycleMark = 0; // No cycles at the start in antlr3TopoNew()
2302 topo->hasCycle = ANTLR3_FALSE; // No cycle at the start in antlr3TopoNew()
2306 topo->addEdge = addEdge; in antlr3TopoNew()
2307 topo->sortToArray = sortToArray; in antlr3TopoNew()
2308 topo->sortVector = sortVector; in antlr3TopoNew()
2309 topo->free = freeTopo; in antlr3TopoNew()
2311 return topo; in antlr3TopoNew()
2316 addEdge (pANTLR3_TOPO topo, ANTLR3_UINT32 edge, ANTLR3_UINT32 dependency) in addEdge() argument
2336 if (topo->edges == NULL) in addEdge()
2340 topo->edges = ANTLR3_CALLOC(sizeof(pANTLR3_BITSET) * (maxEdge + 1), 1); in addEdge()
2341 if (topo->edges == NULL) in addEdge()
2348 topo->limit = maxEdge + 1; in addEdge()
2350 else if (topo->limit <= maxEdge) in addEdge()
2354 topo->edges = ANTLR3_REALLOC(topo->edges, sizeof(pANTLR3_BITSET) * (maxEdge + 1)); in addEdge()
2355 if (topo->edges == NULL) in addEdge()
2362 for (i = topo->limit; i <= maxEdge; i++) in addEdge()
2364 *((topo->edges) + i) = NULL; in addEdge()
2369 topo->limit = maxEdge + 1; in addEdge()
2383 edgeDeps = *((topo->edges) + edge); in addEdge()
2390 *((topo->edges) + edge) = edgeDeps; in addEdge()
2415 DFS(pANTLR3_TOPO topo, ANTLR3_UINT32 node) in DFS() argument
2421 if (topo->hasCycle == ANTLR3_TRUE) in DFS()
2426 if (topo->visited->isMember(topo->visited, node)) in DFS()
2433 for (i=0; i<topo->cycleMark; i++) in DFS()
2435 if (topo->cycle[i] == node) in DFS()
2443 for (l = i; l < topo->cycleMark; l++) in DFS()
2445 topo->cycle[l - i] = topo->cycle[l]; // Move to zero base in the cycle list in DFS()
2450 topo->cycleMark -= i; in DFS()
2454 topo->hasCycle = ANTLR3_TRUE; in DFS()
2465 topo->cycle[topo->cycleMark++] = node; in DFS()
2469 topo->visited->add(topo->visited, node); in DFS()
2475 edges = *((topo->edges) + node); in DFS()
2500 DFS(topo, i); in DFS()
2510 topo->sorted[topo->limit++] = node; in DFS()
2514 if (topo->hasCycle == ANTLR3_FALSE) in DFS()
2516 topo->cycleMark--; in DFS()
2523 sortToArray (pANTLR3_TOPO topo) in sortToArray() argument
2530 if (topo->edges == NULL) in sortToArray()
2538 topo->sorted = ANTLR3_MALLOC(topo->limit * sizeof(ANTLR3_UINT32)); in sortToArray()
2539 topo->cycle = ANTLR3_MALLOC(topo->limit * sizeof(ANTLR3_UINT32)); in sortToArray()
2547 topo->visited = antlr3BitsetNew(0); in sortToArray()
2552 oldLimit = topo->limit; // Number of nodes to traverse linearly in sortToArray()
2553 topo->limit = 0; // Next entry in the sorted table in sortToArray()
2560 if (topo->visited->isMember(topo->visited, v) == ANTLR3_FALSE) in sortToArray()
2564 DFS(topo, v); in sortToArray()
2570 if (topo->hasCycle == ANTLR3_TRUE) in sortToArray()
2581 topo->limit = oldLimit; in sortToArray()
2587 return topo->sorted; in sortToArray()
2591 sortVector (pANTLR3_TOPO topo, pANTLR3_VECTOR v) in sortVector() argument
2613 if (topo->sortToArray(topo) == 0) in sortVector()
2618 if (topo->hasCycle == ANTLR3_TRUE) in sortVector()
2628 if (topo->limit > v->count) in sortVector()
2634 topo->limit = v->count; in sortVector()
2642 vIndex = ANTLR3_MALLOC(topo->limit * sizeof(ANTLR3_UINT32)); in sortVector()
2646 for (i = 0; i < topo->limit; i++) in sortVector()
2656 for (i=0; i < topo->limit; i++) in sortVector()
2663 if (vIndex[topo->sorted[i]] == i) in sortVector()
2673 ind = vIndex[topo->sorted[i]]; in sortVector()
2681 vIndex[topo->sorted[i]] = i; in sortVector()
2692 freeTopo (pANTLR3_TOPO topo) in freeTopo() argument
2698 if (topo->sorted != NULL) in freeTopo()
2700 ANTLR3_FREE(topo->sorted); in freeTopo()
2701 topo->sorted = NULL; in freeTopo()
2706 if (topo->visited != NULL) in freeTopo()
2709 topo->visited->free(topo->visited); in freeTopo()
2710 topo->visited = NULL; in freeTopo()
2715 if (topo->edges != NULL) in freeTopo()
2720 for (i=0; i<topo->limit; i++) in freeTopo()
2722 edgeList = *((topo->edges) + i); in freeTopo()
2729 ANTLR3_FREE(topo->edges); in freeTopo()
2731 topo->edges = NULL; in freeTopo()
2735 if (topo->cycle != NULL) in freeTopo()
2737 ANTLR3_FREE(topo->cycle); in freeTopo()
2740 ANTLR3_FREE(topo); in freeTopo()