Module stack_graphs::c
source · Expand description
Defines a C API for working with stack graphs in other languages.
Structs§
- Connects two nodes in a stack graph.
- A source file that we have extracted stack graph data from.
- An array of all of the files in a stack graph. File handles are indices into this array. There will never be a valid file at index 0; a handle with the value 0 represents a missing file.
- Implements a phased forward partial path stitching algorithm.
- A node in a stack graph.
- Encodes a set of node handles.
- Uniquely identifies a node in a stack graph.
- A tuple of a node handle and source information for that node. Used with the
sg_add_source_info
function to add source information to a stack graph. - An array of all of the nodes in a stack graph. Node handles are indices into this array. There will never be a valid node at index 0; a handle with the value 0 represents a missing node.
- The offset of a character within a string (typically a line of source code), using several different units
- A portion of a name-binding path.
- Manages the state of a collection of partial paths to be used in the path-stitching algorithm.
- Contains a “database” of partial paths.
- Details about one of the edges in a partial path
- The edges in a path keep track of precedence information so that we can correctly handle shadowed definitions.
- An element of a partial path edge list.
- The array of all of the partial path edge list content in a partial path arena.
- A list of paths found by the path-finding algorithm.
- An array of all of the partial paths in a partial path database. Partial path handles are indices into this array. There will never be a valid partial path at index 0; a handle with the value 0 represents a missing partial path.
- A pattern that might match against a scope stack. Consists of a (possibly empty) list of exported scopes, along with an optional scope stack variable.
- An element of a partial scope stack.
- The array of all of the partial scope stack content in a partial path arena.
- A symbol with an unknown, but possibly empty, list of exported scopes attached to it.
- A pattern that might match against a symbol stack. Consists of a (possibly empty) list of partial scoped symbols.
- An element of a partial symbol stack.
- The array of all of the partial symbol stack content in a partial path arena.
- All of the position information that we have about a character in a source file
- Contains information about a range of code in a source code file.
- An array of all of the source information in a stack graph. Source information is associated with nodes, so node handles are indices into this array. It is not guaranteed that there will an entry in this array for every node handle; if you have a node handle whose value is larger than
count
, then use a 0-valuedsg_source_info
if you need source information for that node. - All of the position information that we have about a range of content in a source file
- Contains all of the nodes and edges that make up a stack graph.
- Arbitrary string content associated with some part of a stack graph.
- An array of all of the interned strings in a stack graph. String handles are indices into this array. There will never be a valid string at index 0; a handle with the value 0 represents a missing string.
- A name that we are trying to resolve using stack graphs.
- An array of all of the symbols in a stack graph. Symbol handles are indices into this array. There will never be a valid symbol at index 0; a handle with the value 0 represents a missing symbol.
- A half-open range identifying a range of characters in a string.
Enums§
- Describes in which direction the content of a deque is stored in memory.
- The different kinds of node that can appear in a stack graph.
- Describes the result of a computation
Constants§
- The handle of the singleton “jump to scope” node.
- The local_id of the singleton “jump to scope” node.
- The handle of an empty list.
- The null value for all of our handles.
- The handle of the singleton root node.
- The local_id of the singleton root node.
Functions§
- Frees a forward path stitcher.
- Creates a new forward partial path stitcher that is “seeded” with a set of starting stack graph nodes. The path stitcher will be set up to find complete paths only.
- Creates a new forward partial path stitcher that is “seeded” with a set of initial partial paths.
- Runs the next phase of the algorithm. We will have built up a set of incomplete partial paths during the previous phase. Before calling this function, you must ensure that
db
contains all of the possible partial paths that we might want to extend any of those candidate partial paths with. - Sets the maximum amount of work that can be performed during each phase of the algorithm. By bounding our work this way, you can ensure that it’s not possible for our CPU-bound algorithm to starve any worker threads or processes that you might be using. If you don’t call this method, then we allow ourselves to process all of the extensions of all of the paths found in the previous phase, with no additional bound.
- Sets whether similar path detection should be enabled during path stitching. Paths are similar if start and end node, and pre- and postconditions are the same. The presence of similar paths can lead to exponential blow up during path stitching. Similar path detection is disabled by default because of the accociated preformance cost.
- Adds new partial path edge lists to the partial path arena.
count
is the number of partial path edge lists you want to create. The content of each partial path edge list comes from two arrays. Thelengths
array must havecount
elements, and provides the number of edges in each partial path edge list. Theedges
array contains the contents of each of these partial path edge lists in one contiguous array. Its length must be the sum of all of the counts in thelengths
array. - Adds new partial scope stacks to the partial path arena.
count
is the number of partial scope stacks you want to create. The content of each partial scope stack comes from three arrays. Thelengths
array must havecount
elements, and provides the number of scopes in each scope stack. Thescopes
array contains the contents of each of these scope stacks in one contiguous array. Its length must be the sum of all of the counts in thelengths
array. Thevariables
array must havecount
elements, and provides the optional scope stack variable for each partial scope stack. - Adds new partial symbol stacks to the partial path arena.
count
is the number of partial symbol stacks you want to create. The content of each partial symbol stack comes from two arrays. Thelengths
array must havecount
elements, and provides the number of symbols in each partial symbol stack. Thesymbols
array contains the contents of each of these partial symbol stacks in one contiguous array. Its length must be the sum of all of the counts in thelengths
array. Thevariables
array must havecount
elements, and provides the optional symbol stack variable for each partial symbol stack. - Finds all complete paths reachable from a set of starting nodes, placing the result into the
path_list
output parameter. You must free the path list when you are done with it by callingsg_path_list_done
. - Finds all partial paths in a file that are productive and as complete as possible, placing the result into the
partial_path_list
output parameter. You must free the path list when you are done with it by callingsg_partial_path_list_done
. - Frees a path arena, and all of its contents.
- Creates a new, initially empty partial path arena.
- Returns a reference to the array of partial path edge list content in a partial path arena. The resulting array pointer is only valid until the next call to any function that mutates the partial path arena.
- Returns a reference to the array of partial scope stack content in a partial path arena. The resulting array pointer is only valid until the next call to any function that mutates the partial path arena.
- Returns a reference to the array of partial symbol stack content in a partial path arena. The resulting array pointer is only valid until the next call to any function that mutates the path arena.
- Adds new partial paths to the partial path database.
paths
is the array of partial paths that you want to add;count
is the number of them. - Ensures all partial paths in the database are availabe in both forwards and backwards orientation.
- Ensures all partial paths in the database are in forwards orientation.
- Determines which nodes in the stack graph are “local”, taking into account the partial paths in this database. The result is valid until the next call to this function, or until the database is freed.
- Frees a partial path database, and all of its contents.
- Returns a reference to the set of stack graph nodes that are local, according to this database of partial paths. The resulting set is only valid until the next call to any function that mutates the partial path database.
- Marks that a list of stack graph nodes are local.
- Creates a new, initially empty partial path database.
- Returns a reference to the array of partial path data in this partial path database. The resulting array pointer is only valid until the next call to any function that mutates the partial path database.
- Creates a new, empty sg_partial_path_list.
- Adds new edges to the stack graph. You provide an array of
struct sg_edges
instances. A stack graph can contain at most one edge between any two nodes. It is not an error if you try to add an edge that already exists, but it won’t have any effect on the graph. - Adds new files to the stack graph. You provide all of the file content concatenated together into a single string, and an array of the lengths of each file. You also provide an output array, which must have the same size as
lengths
. We will place each file’s handle in the output array. - Adds new source information to the stack graph. You provide an array of
sg_node_source_info
instances. Any existing source information for any node mentioned in the array is overwritten. - Adds new strings to the stack graph. You provide all of the string content concatenated together into a single string, and an array of the lengths of each string. You also provide an output array, which must have the same size as
lengths
. We will place each string’s handle in the output array. - Adds new symbols to the stack graph. You provide all of the symbol content concatenated together into a single string, and an array of the lengths of each symbol. You also provide an output array, which must have the same size as
lengths
. We will place each symbol’s handle in the output array. - Returns a reference to the array of file data in this stack graph. The resulting array pointer is only valid until the next call to any function that mutates the stack graph.
- Frees a stack graph, and all of its contents.
- Adds new nodes to the stack graph. You provide an array of
struct sg_node
instances. You also provide an output array, which must have the same length asnodes
, in which we will place each node’s handle in the stack graph. - Creates a new, initially empty stack graph.
- Returns a reference to the array of nodes in this stack graph. The resulting array pointer is only valid until the next call to any function that mutates the stack graph.
- Returns a reference to the array of source information in this stack graph. The resulting array pointer is only valid until the next call to any function that mutates the stack graph.
- Returns a reference to the array of string data in this stack graph. The resulting array pointer is only valid until the next call to any function that mutates the stack graph.
- Returns a reference to the array of symbol data in this stack graph. The resulting array pointer is only valid until the next call to any function that mutates the stack graph.
Type Aliases§
- A handle to a file in a stack graph. A zero handle represents a missing file.
- A handle to a node in a stack graph. A zero handle represents a missing node.
- A handle to an element of a partial path edge list. A zero handle represents a missing partial path edge list. A UINT32_MAX handle represents an empty partial path edge list.
- A handle to a partial path in a partial path database. A zero handle represents a missing partial path.
- A handle to an element of a partial scope stack. A zero handle represents a missing partial scope stack. A UINT32_MAX handle represents an empty partial scope stack.
- A handle to an element of a partial symbol stack. A zero handle represents a missing partial symbol stack. A UINT32_MAX handle represents an empty partial symbol stack.
- Represents an unknown list of exported scopes.
- A handle to an interned string in a stack graph. A zero handle represents a missing string.
- A handle to a symbol in a stack graph. A zero handle represents a missing symbol.
- Represents an unknown list of scoped symbols.