Lines Matching full:we

128 	// All we have to do is create the hashtable tracking structure  in antlr3HashTableNew()
212 /* Allow sparse tables, though we don't create them as such at present in antlr3HashFree()
222 /* Save next entry - we do not want to access memory in entry after we in antlr3HashFree()
236 /* Free the key memory - we know that we allocated this in antlr3HashFree()
246 entry = nextEntry; /* Load next pointer to see if we shoud free it */ in antlr3HashFree()
254 /* Now we can free the bucket memory in antlr3HashFree()
259 /* Now we free teh memory for the table itself in antlr3HashFree()
281 /* First we need to know the hash of the provided key in antlr3HashRemoveI()
285 /* Knowing the hash, we can find the bucket in antlr3HashRemoveI()
289 /* Now, we traverse the entries in the bucket until in antlr3HashRemoveI()
290 * we find the key or the end of the entries in the bucket. in antlr3HashRemoveI()
291 * We track the element prior to the one we are examining in antlr3HashRemoveI()
292 * as we need to set its next pointer to the next pointer in antlr3HashRemoveI()
293 * of the entry we are deleting (if we find it). in antlr3HashRemoveI()
300 /* See if this is the entry we wish to delete in antlr3HashRemoveI()
304 /* It was the correct entry, so we set the next pointer in antlr3HashRemoveI()
316 /* We found an entry but it wasn't the one that was wanted, so in antlr3HashRemoveI()
338 /* First we need to know the hash of the provided key in antlr3HashRemove()
342 /* Knowing the hash, we can find the bucket in antlr3HashRemove()
346 /* Now, we traverse the entries in the bucket until in antlr3HashRemove()
347 * we find the key or the end of the entires in the bucket. in antlr3HashRemove()
348 * We track the element prior to the one we are exmaining in antlr3HashRemove()
349 * as we need to set its next pointer to the next pointer in antlr3HashRemove()
350 * of the entry we are deleting (if we find it). in antlr3HashRemove()
357 /* See if this is the entry we wish to delete in antlr3HashRemove()
361 /* It was the correct entry, so we set the next pointer in antlr3HashRemove()
367 /* Release the key - if we allocated that in antlr3HashRemove()
381 /* We found an entry but it wasn't the one that was wanted, so in antlr3HashRemove()
402 /* Now we can free the elements and the entry in order in antlr3HashDeleteI()
426 /* Now we can free the elements and the entry in order in antlr3HashDelete()
450 /* First we need to know the hash of the provided key in antlr3HashGetI()
454 /* Knowing the hash, we can find the bucket in antlr3HashGetI()
458 /* Now we can inspect the key at each entry in the bucket in antlr3HashGetI()
459 * and see if we have a match. in antlr3HashGetI()
474 /* If we got here, then we did not find the key in antlr3HashGetI()
490 /* First we need to know the hash of the provided key in antlr3HashGet()
494 /* Knowing the hash, we can find the bucket in antlr3HashGet()
498 /* Now we can inspect the key at each entry in the bucket in antlr3HashGet()
499 * and see if we have a match. in antlr3HashGet()
514 /* If we got here, then we did not find the key in antlr3HashGet()
530 /* First we need to know the hash of the provided key in antlr3HashPutI()
534 /* Knowing the hash, we can find the bucket in antlr3HashPutI()
538 /* Knowing the bucket, we can traverse the entries until we in antlr3HashPutI()
539 * we find a NULL pointer or we find that this is already in antlr3HashPutI()
547 * If duplicates are allowed then we don't care what it is, but in antlr3HashPutI()
548 * must reject this add if the key is the same as the one we are in antlr3HashPutI()
559 /* Point to the next entry pointer of the current entry we in antlr3HashPutI()
560 * are traversing, if it is NULL we will create our new in antlr3HashPutI()
566 /* newPointer is now pointing at the pointer where we need to in antlr3HashPutI()
578 …entry->keybase.type = ANTLR3_HASH_TYPE_INT; /* Indicate the key type stored here for when we free… in antlr3HashPutI()
601 /* First we need to know the hash of the provided key in antlr3HashPut()
605 /* Knowing the hash, we can find the bucket in antlr3HashPut()
609 /* Knowign the bucket, we can traverse the entries until we in antlr3HashPut()
610 * we find a NULL pointer ofr we find that this is already in antlr3HashPut()
618 * If duplicates are allowed then we don't care what it is, but in antlr3HashPut()
619 * must reject this add if the key is the same as the one we are in antlr3HashPut()
630 /* Point to the next entry pointer of the current entry we in antlr3HashPut()
631 * are traversing, if it is NULL we will create our new in antlr3HashPut()
637 /* newPointer is now poiting at the pointer where we need to in antlr3HashPut()
741 * we would not be at this point in the logic flow. in antlr3EnumNext()
746 /* Return pointers are set up, so now we move the element in antlr3EnumNext()
787 * more buckets then chase them until we find an entry. in antlr3EnumNextEntry()
799 /* There was an entry in this bucket, so we can use it in antlr3EnumNextEntry()
806 /* There was nothing in the bucket we just examined, move to the in antlr3EnumNextEntry()
812 /* Here we have exhausted all buckets and the enumeration pointer will in antlr3EnumNextEntry()
813 * have its bucket count = table->modulo which signifies that we are done. in antlr3EnumNextEntry()
824 /* Nothing to check, we just free it. in antlr3EnumFree()
876 /* Now we need to add a new table in antlr3ListNew()
977 /* Now we need to add a new table in antlr3StackNew()
1113 // Now we can install the API in antlr3SetVectorApi()
1140 // We must traverse every entry in the vector and if it has in antlr3VectorClear()
1141 // a pointer to a free function then we call it with the in antlr3VectorClear()
1154 // Having called any free pointers, we just reset the entry count in antlr3VectorClear()
1165 // We must traverse every entry in the vector and if it has in antlr3VectorFree()
1166 // a pointer to a free function then we call it with the in antlr3VectorFree()
1293 // Need to resize the element pointers. We double the allocation in antlr3VectorResize()
1294 // we already have unless asked for a specific increase. in antlr3VectorResize()
1305 // Now we know how many we need, so we see if we have just expanded in antlr3VectorResize()
1310 // We were already larger than the internal size, so we just in antlr3VectorResize()
1323 // The current size was less than or equal to the internal array size and as we always start in antlr3VectorResize()
1324 …// with a size that is at least the maximum internal size, then we must need to allocate new memory in antlr3VectorResize()
1325 // for external pointers. We don't want to take the time to calculate if a requested element in antlr3VectorResize()
1326 … // is part of the internal or external entries, so we copy the internal ones to the new space in antlr3VectorResize()
1346 // Do we need to resize the vector table? in antlr3VectorAdd()
1350 // Give no hint, we let it add 1024 or double it in antlr3VectorAdd()
1376 // If the vector is currently not big enough, then we expand it in antlr3VectorSet()
1380 // We will get at least this many in antlr3VectorSet()
1421 // If the vector is currently not big enough, then we do nothing in antlr3VectorSwap()
1502 // First we need to clear out anything that is still in the vector in returnVector()
1506 // We have a free stack available so we can add the vector we were in returnVector()
1508 // factory, so we already know how to release its memory when it in returnVector()
1525 /* Ensure we have enough pointers allocated in newPool()
1533 // realloc failed, but we still have the old allocation in newPool()
1570 // First see if we have a free chain stack to release? in closeVectorFactory()
1577 /* We iterate the vector pools one at a time in closeVectorFactory()
1585 /* Work out how many tokens we need to check in this pool. in closeVectorFactory()
1589 /* Marginal condition, we might be at the start of a brand new pool in closeVectorFactory()
1594 /* We have some vectors allocated from this pool in closeVectorFactory()
1605 // vector, we don't free the element allocations yet. We do that in a in closeVectorFactory()
1615 /* We iterate the vector pools one at a time once again, but this time in closeVectorFactory()
1616 * we are going to free up any allocated element pointers. Note that we are doing this in closeVectorFactory()
1617 * so that we do not try to release vectors twice. When building ASTs we just copy in closeVectorFactory()
1627 /* Work out how many tokens we need to check in this pool. in closeVectorFactory()
1631 /* Marginal condition, we might be at the start of a brand new pool in closeVectorFactory()
1636 /* We have some vectors allocated from this pool in closeVectorFactory()
1644 // Anything in here should be factory made, but we do this just in closeVectorFactory()
1645 // to triple check. We just free up the elements if they were in closeVectorFactory()
1656 … // We can now free this pool allocation as we have called free on every element in every vector in closeVectorFactory()
1663 /* All the pools are deallocated we can free the pointers to the pools in closeVectorFactory()
1668 /* Finally, we can free the space for the factory itself in closeVectorFactory()
1679 // If we have anything on the re claim stack, reuse it in newVector()
1685 // Cool we got something we could reuse in newVector()
1694 // See if we need a new vector pool before allocating a new in newVector()
1699 // We ran out of vectors in the current pool, so we need a new pool in newVector()
1708 // Assuming everything went well (we are trying for performance here so doing minimal in newVector()
1709 // error checking. Then we can work out what the pointer is to the next vector. in newVector()
1714 // We have our token pointer now, so we can initialize it to the predefined model. in newVector()
1719 // We know that the pool vectors are created at the default size, which means they in newVector()
1720 // will start off using their internal entry pointers. We must initialize our pool vector in newVector()
1727 // And we are done in newVector()
1737 * will whip through this. Otherwise we must loop shifting a one
1738 * bit and masking. The values we tend to be placing in out integer
1739 * patricia trie are usually a lot lower than the 64 bits we
1780 * we need to mask off singly. The data values will stay in
1820 /* Now we need to allocate the root node. This makes it easier in antlr3IntTrieNew()
1821 * to use the tree as we don't have to do anything special in antlr3IntTrieNew()
1837 /* Now we seed the root node with the index being the in antlr3IntTrieNew()
1838 * highest left most bit we want to test, which limits the in antlr3IntTrieNew()
1844 /* And as we have nothing in here yet, we set both child pointers in antlr3IntTrieNew()
1852 * we use calloc() to initialise it. in antlr3IntTrieNew()
1874 * then by definition (as the bit index decreases as we descent the trie) in intTrieGet()
1875 * we have reached a 'backward' pointer. A backward pointer means we in intTrieGet()
1877 * and it must either be the key we are looking for, or if not then it in intTrieGet()
1878 * means the entry was not in the trie, and we return NULL. A backward pointer in intTrieGet()
1885 /* While we are descending the tree nodes... in intTrieGet()
1893 /* We now test the bit indicated by the bitmap in the next node in intTrieGet()
1894 * in the key we are searching for. The new next node is the in intTrieGet()
1907 /* Here we have reached a node where the bitMap index is lower than in intTrieGet()
1911 * we wanted, or if that key is not in the trie it is another key in intTrieGet()
1926 return NULL; /* That key is not in the trie (note that we set the pointer to -1 if no payload) */ in intTrieGet()
1942 * Basically we descend the trie as we do when searching it, which will
1945 * we add the supplied data in a new chained bucket to that data node. If it does
1946 * not accept duplicates then we merely return FALSE in case the caller wants to know
1948 * If the node we locate is not the key we are looking to add, then we insert a new node
1950 * node pointing to itself or the data node we are inserting 'before'.
1969 nextNode = trie->root->leftN; /* And assume we start to the left */ in intTrieAdd()
1972 * key we are being asked to insert. in intTrieAdd()
1988 /* Bit at the required index was 0, so we traverse to the left in intTrieAdd()
1993 /* Here we have located the only node that can be reached by the in intTrieAdd()
1995 * we need to use to insert the new key. in intTrieAdd()
1999 /* We have located an exact match, but we will only append to the bucket chain in intTrieAdd()
2004 /* Yes, we are accepting duplicates in intTrieAdd()
2010 /* Out of memory, all we can do is return the fact that the insert failed. in intTrieAdd()
2028 /* We want to be able to traverse the stored elements in the order that they were in intTrieAdd()
2029 …* added as duplicate keys. We might need to revise this opinion if we end up having many duplicate… in intTrieAdd()
2044 /* We found the key is already there and we are not allowed duplicates in this in intTrieAdd()
2051 /* Here we have discovered the only node that can be reached by the bits in the key in intTrieAdd()
2052 * but we have found that this node is not the key we need to insert. We must find the in intTrieAdd()
2053 * the leftmost bit by which the current key for that node and the new key we are going in intTrieAdd()
2057 …xorKey = (key ^ nextNode->key); /* Gives 1 bits only where they differ then we find the left mos… in intTrieAdd()
2114 /* We have located the leftmost differing bit, indicated by the depth variable. So, we know what in intTrieAdd()
2115 * bit index we are to insert the new entry at. There are two cases, being where the two keys in intTrieAdd()
2119 …* at bit 3, then we have the "skipped" bit case. But if that chain was Bit 4, Bit 2 and they diffe… in intTrieAdd()
2120 * then we have the easy bit <pun>. in intTrieAdd()
2123 * according to whether we skip the bit that differs or not. in intTrieAdd()
2144 /* Bit at the required index was 0, so we traverse to the left in intTrieAdd()
2150 /* We have located the correct insert point for this new key, so we need in intTrieAdd()
2167 /* Out of memory, all we can do is return the fact that the insert failed. in intTrieAdd()
2205 /* Finally, we need to change the pointers at the node we located in intTrieAdd()
2226 * Basic algorithm is that we do a depth first left descent and free
2240 /* We have a left node that needs descending, so do it. in freeIntNode()
2246 * we need to descend any right nodes that are not back pointers in freeIntNode()
2255 /* Now all the children are dealt with, we can destroy in freeIntNode()
2264 /* Do we need to call a custom free pointer for this string entry? in freeIntNode()
2277 /* The bucket entry is now gone, so we can free the memory for in freeIntNode()
2295 /* the nodes are all gone now, so we need only free the memory in intTrieFree()
2370 // We need to add an edge to says that the node indexed by 'edge' is in addEdge()
2374 // First see if we have enough room in the edges array to add the edge? in addEdge()
2378 // We don't have any edges yet, so create an array to hold them in addEdge()
2386 // Set the limit to what we have now in addEdge()
2392 // WE have some edges but not enough in addEdge()
2400 // Initialize the new bitmaps to ;indicate we have no edges defined yet in addEdge()
2407 // Set the limit to what we have now in addEdge()
2412 // If the edge was flagged as depending on itself, then we just in addEdge()
2442 // And we are all set in addEdge()
2450 * to) until we find one without edges. Having found a node without edges, we have
2451 * discovered the bottom of a depth first search, which we can then ascend, adding
2463 return; // We don't do anything else if we found a cycle in DFS()
2468 // Check to see if we found a cycle. To do this we search the in DFS()
2469 // current cycle stack and see if we find this node already in the stack. in DFS()
2477 // Stop! We found a cycle in the input, so rejig the cycle in DFS()
2500 // So far, no cycles have been found and we have not visited this node yet, in DFS()
2501 // so this node needs to go into the cycle stack before we continue in DFS()
2502 // then we will take it out of the stack once we have descended all its in DFS()
2507 // First flag that we have visited this node in DFS()
2511 // Now, if this node has edges, then we want to ensure we visit in DFS()
2512 // them all before we drop through and add this node into the sorted in DFS()
2518 // We have some edges, so visit each of the edge nodes in DFS()
2528 // Stop if we exahust the bit list or have checked the in DFS()
2529 // number of edges that this node refers to (so we don't in DFS()
2538 // Found an edge, make sure we visit and descend it in DFS()
2545 // At this point we will have visited all the dependencies in DFS()
2547 // So we just add the node into the sorted list at the in DFS()
2552 // Remove this node from the cycle list if we have not detected a cycle in DFS()
2574 // First we need a vector to populate with enough in sortToArray()
2576 // the maximum cycle we could detect which is all nodes such as 0->1->2->3->0 in sortToArray()
2589 // Next we need an empty bitset to show whether we have visited a node in sortToArray()
2590 // or not. This is the bit that gives us linear time of course as we are essentially in sortToArray()
2591 // dropping through the nodes in depth first order and when we get to a node that in sortToArray()
2592 // has no edges, we pop back up the stack adding the nodes we traversed in reverse in sortToArray()
2597 // Now traverse the nodes as if we were just going left to right, but in sortToArray()
2605 // If we did not already visit this node, then descend it until we in sortToArray()
2606 // get a node without edges or arrive at a node we have already visited. in sortToArray()
2610 // We have not visited this one so descend it in sortToArray()
2615 // Break the loop if we detect a cycle as we have no need to go any in sortToArray()
2624 // Reset the limit to the number we recorded as if we hit a in sortToArray()
2625 // cycle, then limit will have stopped at the node where we in sortToArray()
2627 // we need to know how many we may have allocated and traverse them all. in sortToArray()
2631 // Having traversed all the nodes we were given, we in sortToArray()
2641 // To sort a vector, we first perform the in sortVector()
2643 // we are given. This is just a convenience routine that allows you to in sortVector()
2658 // Sort into an array, then we can use the array that is in sortVector()
2668 return; // Do nothing if we detected a cycle in sortVector()
2671 // Ensure that the vector we are sorting is at least as big as the in sortVector()
2672 // the input sequence we were asked to sort. It does not matter if it is in sortVector()
2678 // We can only sort the entries that we have dude! The caller is in sortVector()
2684 // We need to know the locations of each of the entries in sortVector()
2685 // in the vector as we don't want to duplicate them in a new vector. We in sortVector()
2687 // according to where we moved it last. Then we can just swap vector entries until in sortVector()
2688 // we are done :-) in sortVector()
2704 // Now we traverse the sorted array and moved the entries of in sortVector()
2706 // table we just created. The index telsl us where in the vector the in sortVector()
2714 // should be, then we skip moving it of course. in sortVector()
2723 // at topo->sorted[i] may have already been swapped out though, so we in sortVector()
2729 // Update our index. The element at i is now the one we wanted in sortVector()
2730 // to be sorted here and the element we swapped out is now the in sortVector()
2731 // element that was at i just before we swapped it. If you are lost now in sortVector()
2732 // don't worry about it, we are just reindexing on the fly is all. in sortVector()
2738 // Having traversed all the entries, we have sorted the vector in place. in sortVector()