-
Notifications
You must be signed in to change notification settings - Fork 34
Compute Flattened Choice Transition Map
This algorithm flattens the choice transitions in a state machine definition. By flattening transitions, we simplify the code generation and runtime logic.
-
A state machine definition smd.
-
A state machine analysis data structure sma representing the results of analysis so far.
-
sma with the flattened choice transition map updated.
The following diagrams illustrate how choice transitions are flattened.
Figure 1 shows how choice transitions to states are flattened. S1 is a state with a choice C. S2 is a state with a substate S3. It has an initial transition specifier with actions A' and target S3.
The solid left-to-right arrow represents a transition T in the hierarchical state machine from C to S2 with actions A. T generates the flattened transition represented by the dashed arrow. The action list for this transition is the concatenation of the action lists shown. In these lists, exit(S) represents the list of exit functions specified by S, and similarly for entry(S).
Note that each flattened transition goes from a choice to a leaf state.
Figure 2 shows how choice transitions to choices are flattened. S1 is a state with a choice C1. S2 is a state with a choice C2. The solid left-to-right arrow represents a transition T in the hierarchical state machine from C1 to C2. T generates the flattened transition represented by the dashed arrow. The action list for this transition is the concatenation of the action lists shown.
Visit each of the choices in smd.
-
Let sd be the state definition being visited.
-
For each choice definition cd in sd
-
For each transition expression e in cd
-
Let A be the actions of e.
-
Let soc be the state or choice that is the target of e.
-
Construct the transition t from cd to soc with actions A
-
Map e to t in the flattened choice transition map of sma.
-
-