-
Notifications
You must be signed in to change notification settings - Fork 32
Check State Machine Uses
This algorithm traverses a state machine definition and checks that each use of a state machine symbol refers to a definition. It also constructs the use-def map in the state machine analysis.
-
A state machine definition smd.
-
A state machine analysis data structure sma representing the results of analysis so far.
Visit each of the state machine members smm of smd as specified below.
Visit a state machine member smm as follows:
-
Initial transition specifiers: If smm is an initial transition specifier, then visit its transition expression.
-
Choice definitions: If smm is a choice definition, then
-
Visit the identifier following the keyword
if
in the guard name group. -
Visit each of the two transition expressions.
-
-
State definitions: If smm is a state definition d with name n, then
-
Construct the unique state symbol sym corresponding to d.
-
Look up the mapping from sym to s in the symbol-scope map of sma. If no such mapping exists, then throw an internal error.
-
Push s onto the nested scope of sma.
-
Visit each member of d.
-
Pop s off the nested scope of sma.
-
-
Other members: For other state machine members, do nothing.
Visit a state definition member sdm as follows:
-
Initial transition specifiers, choice definitions, and state definitions: If sdm is an initial transition specifier, choice definition, or state definition, then visit it as specified for the corresponding state machine member.
-
State transition specifiers: If smm is a state transition specifier, then do the following:
-
Let n be the identifier following the keyword
on
. Visit n in the signal name group. -
If an
if
clause is present, then visit its identifier in the guard name group. -
Visit each of the identifiers in the action list of smm in the action name group.
-
If a transition expression is present, then visit it.
-
Visit a transition expression e as follows:
-
Visit the each identifier in the action list of e in the action name group.
-
Let q be the qualified identifier appearing after the keyword
enter
in e. Visit q in the state name group.
Visit an identifier n in name group G as follows:
-
Look up the mapping from n to sym in the innermost nested scope of sma in name group G. If no such mapping exists, then throw a semantic error.
-
Record the mapping from n to sym in the use-def map of sma.
Visit a qualified identifier q in name group G as follows:
-
Unqualified names: If q is an unqualified name n, then visit the identifier n in name group G.
-
Qualified names: Otherwise if q is a qualified name q'.n, then
-
Visit q'.
-
Look up the mapping from q' to sym' in the use-def map of sma. If no such mapping exists, then throw an internal error.
-
Look up the mapping from sym' to s in the symbol-scope map of sma. If no such mapping exists, then throw a semantic error.
-
Look up the mapping from n to sym in s. If no such mapping exists, then throw a semantic error.
-
Record the mapping from q to sym in the use-def map of sma.
-