• Home
  • Raw
  • Download

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);
2326 pANTLR3_TOPO topo = (pANTLR3_TOPO)ANTLR3_MALLOC(sizeof(ANTLR3_TOPO)); in antlr3TopoNew() local
2328 if (topo == NULL) in antlr3TopoNew()
2336 topo->visited = NULL; // Don't know how big it is yet in antlr3TopoNew()
2337 topo->limit = 1; // No edges added yet in antlr3TopoNew()
2338 topo->edges = NULL; // No edges added yet in antlr3TopoNew()
2339 topo->sorted = NULL; // Nothing sorted at the start in antlr3TopoNew()
2340 topo->cycle = NULL; // No cycles at the start in antlr3TopoNew()
2341 topo->cycleMark = 0; // No cycles at the start in antlr3TopoNew()
2342 topo->hasCycle = ANTLR3_FALSE; // No cycle at the start in antlr3TopoNew()
2346 topo->addEdge = addEdge; in antlr3TopoNew()
2347 topo->sortToArray = sortToArray; in antlr3TopoNew()
2348 topo->sortVector = sortVector; in antlr3TopoNew()
2349 topo->free = freeTopo; in antlr3TopoNew()
2351 return topo; in antlr3TopoNew()
2356 addEdge (pANTLR3_TOPO topo, ANTLR3_UINT32 edge, ANTLR3_UINT32 dependency) in addEdge() argument
2376 if (topo->edges == NULL) in addEdge()
2380 topo->edges = (pANTLR3_BITSET*)ANTLR3_CALLOC(sizeof(pANTLR3_BITSET) * (maxEdge + 1), 1); in addEdge()
2381 if (topo->edges == NULL) in addEdge()
2388 topo->limit = maxEdge + 1; in addEdge()
2390 else if (topo->limit <= maxEdge) in addEdge()
2394topo->edges = (pANTLR3_BITSET*)ANTLR3_REALLOC(topo->edges, sizeof(pANTLR3_BITSET) * (maxEdge + 1)); in addEdge()
2395 if (topo->edges == NULL) in addEdge()
2402 for (i = topo->limit; i <= maxEdge; i++) in addEdge()
2404 *((topo->edges) + i) = NULL; in addEdge()
2409 topo->limit = maxEdge + 1; in addEdge()
2423 edgeDeps = *((topo->edges) + edge); in addEdge()
2430 *((topo->edges) + edge) = edgeDeps; in addEdge()
2455 DFS(pANTLR3_TOPO topo, ANTLR3_UINT32 node) in DFS() argument
2461 if (topo->hasCycle == ANTLR3_TRUE) in DFS()
2466 if (topo->visited->isMember(topo->visited, node)) in DFS()
2473 for (i=0; i<topo->cycleMark; i++) in DFS()
2475 if (topo->cycle[i] == node) in DFS()
2483 for (l = i; l < topo->cycleMark; l++) in DFS()
2485 topo->cycle[l - i] = topo->cycle[l]; // Move to zero base in the cycle list in DFS()
2490 topo->cycleMark -= i; in DFS()
2494 topo->hasCycle = ANTLR3_TRUE; in DFS()
2505 topo->cycle[topo->cycleMark++] = node; in DFS()
2509 topo->visited->add(topo->visited, node); in DFS()
2515 edges = *((topo->edges) + node); in DFS()
2540 DFS(topo, i); in DFS()
2550 topo->sorted[topo->limit++] = node; in DFS()
2554 if (topo->hasCycle == ANTLR3_FALSE) in DFS()
2556 topo->cycleMark--; in DFS()
2563 sortToArray (pANTLR3_TOPO topo) in sortToArray() argument
2570 if (topo->edges == NULL) in sortToArray()
2578 topo->sorted = (pANTLR3_UINT32)ANTLR3_MALLOC(topo->limit * sizeof(ANTLR3_UINT32)); in sortToArray()
2579 if (topo->sorted == NULL) in sortToArray()
2583 topo->cycle = (pANTLR3_UINT32)ANTLR3_MALLOC(topo->limit * sizeof(ANTLR3_UINT32)); in sortToArray()
2584 if (topo->cycle == NULL) in sortToArray()
2595 topo->visited = antlr3BitsetNew(0); in sortToArray()
2600 oldLimit = topo->limit; // Number of nodes to traverse linearly in sortToArray()
2601 topo->limit = 0; // Next entry in the sorted table in sortToArray()
2608 if (topo->visited->isMember(topo->visited, v) == ANTLR3_FALSE) in sortToArray()
2612 DFS(topo, v); in sortToArray()
2618 if (topo->hasCycle == ANTLR3_TRUE) in sortToArray()
2629 topo->limit = oldLimit; in sortToArray()
2635 return topo->sorted; in sortToArray()
2639 sortVector (pANTLR3_TOPO topo, pANTLR3_VECTOR v) in sortVector() argument
2661 if (topo->sortToArray(topo) == 0) in sortVector()
2666 if (topo->hasCycle == ANTLR3_TRUE) in sortVector()
2676 if (topo->limit > v->count) in sortVector()
2682 topo->limit = v->count; in sortVector()
2690 vIndex = (pANTLR3_UINT32)ANTLR3_MALLOC(topo->limit * sizeof(ANTLR3_UINT32)); in sortVector()
2699 for (i = 0; i < topo->limit; i++) in sortVector()
2709 for (i=0; i < topo->limit; i++) in sortVector()
2716 if (vIndex[topo->sorted[i]] == i) in sortVector()
2726 ind = vIndex[topo->sorted[i]]; in sortVector()
2734 vIndex[topo->sorted[i]] = i; in sortVector()
2745 freeTopo (pANTLR3_TOPO topo) in freeTopo() argument
2751 if (topo->sorted != NULL) in freeTopo()
2753 ANTLR3_FREE(topo->sorted); in freeTopo()
2754 topo->sorted = NULL; in freeTopo()
2759 if (topo->visited != NULL) in freeTopo()
2762 topo->visited->free(topo->visited); in freeTopo()
2763 topo->visited = NULL; in freeTopo()
2768 if (topo->edges != NULL) in freeTopo()
2773 for (i=0; i<topo->limit; i++) in freeTopo()
2775 edgeList = *((topo->edges) + i); in freeTopo()
2782 ANTLR3_FREE(topo->edges); in freeTopo()
2784 topo->edges = NULL; in freeTopo()
2788 if (topo->cycle != NULL) in freeTopo()
2790 ANTLR3_FREE(topo->cycle); in freeTopo()
2793 ANTLR3_FREE(topo); in freeTopo()