For each operator a C function is declared, with the same name. This function implements the storage option and returns (a pointer to) the term constructed from its arguments.
The emalloc and friends functions are used for allocating memory, they call the system memory allocation routines and check the return status. The emalloc and friends functions' interfaces use the void* type3, and hide the fact that some malloc libraries use the char* type from the user.
The uniqmalloc and friends routines are used to implement the hashtables' storage. They claim large chunks from the system and pass out small blocks. These blocks cannot be freed by themselves, it is only possible to free a complete collection of chunks as a whole. Each collection of chunks can be identified by its kc_memory_info_t*.
Initialize the allocation information of a new set-of-chunks and return a pointer to it.
Returns a pointer to a block of size n from the chunks administrated in mi.
Report whether or not p was allocated via mi.
Free all chunks allocated (managed) via mi .
Free one block allocated by uniqmalloc. However, its current implementation is a no-op.
In the generated code these allocation routines are used via the following macros: MALLOC and friends are used for all allocation, except for the allocation of memory by the Operator functions. UNIQMALLOC2 is used to allocate memory for the phyla that have the `uniq' storage option. NONUNIQMALLOC is used for the remaining phyla. If you want different ones, redefine MALLOC and friends, in your included code. For example, the default definition of MALLOC and NONUNIQMALLOC is emalloc, the default definition of UNIQMALLOC2 is uniqmalloc.
kc_size_t is by default typedef'ed to unsigned.
The generated code contains the definition of the enumerated type kc_storageclass_t , which contains all storage classes, including the predefined storage class uniq.
Makes ht the hashtable for storage class sc, and return the previously assigned hashtable.
Return the hashtable assigned to storage class sc.
Creates a hashtable of size n, using the kc_ht_create_bucketmanagement routine with default allocation routines (uniqmalloc and friends). For the bucket_alloc routines ecalloc and friends are used.
Creates a hashtable of size n with the given allocation routines. A 0 argument can be given for uniq_free_all, uniq_free_element and/or for in_block, if those routines are not implemented. This routine uses the kc_ht_create_bucketmanagement routine with default bucket allocation routines (ecalloc and friends).
Creates a hashtable of size n with the given allocation routines. A 0 argument can be given for uniq_free_all, uniq_free_element and/or for in_block, if those routines are not implemented, as well as for the info routines, and either the bucket_free or the bucket_free_all routines.
Clears hashtable ht, ie. frees its elements (either using uniq_free_elements or, preferably, uniq_free_all), and its buckets. The result of this routine should be equivalent with calling kc_ht_delete followed by kc_ht_create.
First kc_ht_clears the hashtable, and then frees the hashtable itself.
Prepares hashtable ht for reuse, ie. frees its elements, but not its buckets.
The basic phylum constructors. They convert a value of a C string into the corresponding phylum value. From a casestring or nocasestring value the string can be referenced as cs->name. In the case of case insensitive strings, this field will contain the string as it is capitalized at its first occurrence.
The template of user-provided functions.
The function that tests for structural equality of terms. Attribute values do not influence the comparison. If the phylum is uniquely represented, the test always takes constant time. Note that the comparison of a casestring with a nocasestring is not type correct.
The node p is zeroed and freed. If recursive is True, the subterms are freed as well. The body of a free function for a phylum with storage class uniq is empty.
Free the list, but not the elements of the list. In other words, free the spine.
Produce a new list that is the concatenation of the two arguments. If the second argument is the empty list, and the list phylum is not uniquely represented, this is equivalent to a copy of the list nodes (the `spine'). The list elements are never copied.
Return a copy of p. If copy_attributes is False attribute values are initialised as defined in the definition of phylum. If copy_attributes is True the values of the attributes are copied. Please note that this does not imply that the attributes themselves are copied. This function is ineffective on uniquely represented phyla.
Produce a list that is the reverse of the argument list.
Yield the number of elements in a list, a nil list has zero elements.
Yield the last element of a list, or an error if there isn't one.
Yield the list constructed from the element-wise application of f. It `lifts' f to a function on lists.
Yield the list of elements of which f is True.
Print the argument term on a given file (f = 0 means standard output - print_phylum( p ) is identical to fprint_phylum( 0, p )) in a canonical format. In this format each operator appears on a separate line. It is mainly intended for debugging.
Print the argument term p, with its attributes, on a given file (f = 0 means standard output) in dot input format. Dot is a program that draws directed acyclic graphs in various output formats, among which are postscript and gif. It is available as part of the GraphViz graph visualisation package[EKN]. If print_node_labels is True, the nodes are labeled with the names of the operators, the types of the subtrees, and the attribute names and types (or values, for boolean attributes), and the root node is labeled with root_label_prefix followed by phylum. The edges are numbered; the edge numbers show a depth-first left-to-right treewalk. The numbers are prefixed with the contents of edge_label_prefix, which can make it easier to see to which tree an edge belongs when several trees are combined in the same picture, as discussed below. Attributes of the edges (colors, fonts, etc.) can be given with edge_attributes. Shared non-leaf tree nodes appear as such in the drawing. For leaf nodes (like integers, (no)casestrings) the amount of sharing can be influenced with the use_context_when_sharing_leaves argument: if it is False leaf nodes with the same value will be shared (which resembles the internal program structure, but may give pictures that are a bit confusing, especially if no non-leaf nodes are shared), if it is True then the ancestor of the leaf node is taken into account for the sharing, i.e. leaf nodes with the same value but different ancestors will not be shared. Finally, it is possible to combine several trees in one drawing. To do so, start by invoking fprintdotprologue. Next, invoke fprintdot_phylum for each tree, with argument print_prologue_and_epilogue set to False. You likely want to use a different edge_label_prefix for each tree. Finally, invoke fprintdotepilogue. If only one tree is to be drawn, then it is sufficient to invoke fprintdot_phylum with print_prologue_and_epilogue set to True (and fprintdotprologue and fprintdotepilogue need not be invoked 'by hand').
Set the size of the hashtable that the fprintdot_phylum routines use to detect node-sharing. Return the previous value.
Yield the normal form of the first argument with respect to the rewrite system and view.
Unparses the argument p and its descendants, with view and printer as given.
To read and write a term from a structure file (see Section 3.5). FILE is the standard file i/o type defined in <stdio.h>. The functions return a null pointer if all went well. If not, they return a pointer to a string containing an error message.
Set the size of the hashtable that the CSGIOwrite_phylum routines use to detect node-sharing. Return the previous value.
Disable (b = False) or re-enable the use of node-sharing while writing structure files. This does not affect the ability to read structure files that contain node-sharing! By default (if this routine is not called) node-sharing in structure files is enabled. Return the previous value.
Print for each operator its size in bytes, the number of create calls, the number of actually created elements (usually much lower if its phylum has the uniq storage option), the number of free calls (recursive and non-recursive), the number of freed elements, the number of remaining nodes and the amount of space that these take, in bytes. The routine is equivalent to a no-op, unless the preprocessor symbol KC_STATISTICS is defined.
Print the number of hashtable buckets that contain zero, one, two, three, four, five, six, seven, eight or more elements.
Print information about the memory management of h. (This will only be possible if node- and bucket memory-management routines have been specified.)