-
Notifications
You must be signed in to change notification settings - Fork 32
Check State Machine Uses
This algorithm traverses a state machine source model and checks that each use refers to definition. It also constructs the use-def map.
-
A list tul of translation units.
-
An analysis data structure a representing the results of analysis so far.
-
Translation unit lists: Visit each translation unit tu in tul in order.
-
Translation units: Visit a translation unit tu by visiting its members tum.
-
Translation unit members: Visit a translation unit member tum as follows:
-
Statemachine definitions: Otherwise if tum is a state machine definition d then visit each translation unit member of d
-
State definitions: Otherwise if tum 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 a. If no such mapping exists, then throw an internal error.
-
Push s onto the nested scope of a.
-
Visit each member of d.
-
Pop s off the nested scope of a.
-
-
Action definitions: If tum is a action definition, then visit the type name use appearing in tum.
-
Guard definitions: If tum is a guard definition, then visit the type name use appearing in tum.
-
Signal definitions: If tum is a signal definition, then visit the type name use appearing in tum.
-
Initial transition specifications: If tum is a initial transition specification, then visit the action as a unqualified name using the action name group and visit the state as a qualified name using the state name group in tum.
-
State transition specifications: If tum is a state transition specification, then visit the signal as a unqualified name using the signal name group and visit the guard as a unqualified name using the guard name group, and visit the action as a unqualified name using the action name group, and visit the state as a qualified name in the state name group in tum.
-
Junction definitions: If tum is a junction definition, then visit the guard as a unqualified name using the guard name group, and visit the action as a unqualified name using the action name group, and visit the state as a qualified name using the state name group in tum.
-
-
Expressions: Visit an expression e as follows:
-
Unqualified names: If e is an unqualified name n, then
-
Look up the mapping from n to sym in the innermost nested scope of a in the value name group. If no such mapping exists, then throw a semantic error.
-
Record the mapping from e to sym in the use-def map of a.
-
-
Dot expressions: Otherwise if e is a dot expression e'.n, then
-
Visit e'.
-
Look up the mapping from e' to sym' in the use-def map of a. If no such mapping exists, then throw an internal error.
-
Look up the mapping from sym' to s in the symbol-scope map of a. 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 e to sym in the use-def map of a.
-
-
Other expressions: Otherwise visit each expression and type appearing in e.
-
-
Type names: Visit a type name tn as follows:
-
Unqualified names: Use the same algorithm as for unqualified name expressions, but use the type name group instead of the value name group.
-
Qualified names: Use the same algorithm as for dot expressions, but use the type name group instead of the value name group.
-
Other types: Nothing to do.
-