-
Notifications
You must be signed in to change notification settings - Fork 35
Check Transition Graph
This algorithm constructs and checks the transition graph for a state machine definition.
-
A state machine definition smd.
-
A state machine analysis data structure sma representing the results of analysis so far.
-
sma with the transition graph updated if the check passes; otherwise an error.
-
Visit all the enter expressions that are transitively part of smd and construct the transition graph.
-
Check that the transition graph is connected.
-
Check for illegal cycles in the transition graph.
-
Update the transition graph in sma.
-
Visit the nodes in the transition graph and compute a map that records, for each state definition and junction definition d in the graph, the number of graph edges that have d as their terminal nodes.
-
Check that each number stored in the map is at least 1.
-
Create the following data structures, initially empty:
-
path: A list of graph edges representing the current path being traversed. A graph edge stores an initial node and a terminal node.
-
path node set: The set of nodes in the current path.
-
visited node set: The set of nodes visited so far.
-
-
For each junction definition node n in the transition graph
-
Check whether n appears in the path node set. If so, then the path node list represents an illegal cycle. Throw a semantic error. Use the path node list to construct the cycle for the error message.
-
Otherwise if n is not in the visited node set, then
-
Add n to the path node set.
-
For each edge e = (n,n') such that n' is a junction definition
-
Add e to the path.
-
Visit n'.
-
-
Add n to the visited node set.
-
-
Otherwise we have already visited n; do nothing.
-