Skip to content

Enter State Machine Symbols

Rob Bocchino edited this page Jul 17, 2024 · 14 revisions

This algorithm traverses a source model and enters symbols into their scopes.

Input

  1. A list tul of translation units.

  2. An Statemachine analysis data structure a representing the results of analysis so far.

Output

  1. An updated state machine analysis data structure a with symbols entered.

Procedure

  1. Translation unit lists: Visit each translation unit tu in tul in order.

  2. Translation units: Visit a translation unit tu by visiting its members tum.

  3. Translation unit members: Visit a translation unit member tum as follows:

    1. State and Junction definitions: If tum is a state or junction definition d with name n, then

      1. Look up the symbol sym with unqualified name n in the innermost nested scope of a in the state name group.

      2. If sym exists and is a state symbol, then let s be the scope corresponding to sym in the symbol-scope map of a.

      3. Otherwise if sym exists then report an error.

      4. Otherwise

        1. Let s be a fresh scope.

        2. Construct a state symbol sym.

        3. Add the mapping from n to sym in the innermost nested scope of a in every state group.

        4. Add sym to the parent symbol map of a.

      5. Add n to the scope name list of a.

      6. Push s onto the nested scope of a.

      7. Visit each State member of d, yielding a new analysis data structure a.

        1. Let s' be the innermost nested scope of a.

        2. Add the mapping from sym to s' in the symbol-scope map of a.

      8. Pop s' off the nested scope of a.

      9. Remove n from the scope name list of a.

    2. Action definitions: If tum is a action definition d with name n, then

      1. Construct the unique symbol s of the correct kind for d.

      2. Add the mapping from n to s in the global scope of a in the action name group.

      3. Add s to the parent symbol map of a.

    3. Signal definitions: If tum is a signal definition d with name n, then

      1. Construct the unique symbol s of the correct kind for d.

      2. Add the mapping from n to s in the global scope of a in the signal name group.

      3. Add s to the parent symbol map of a.

    4. Guard definitions: If tum is a guard definition d with name n, then

      1. Construct the unique symbol s of the correct kind for d.

      2. Add the mapping from n to s in the global scope of a in the guard name group.

      3. Add s to the parent symbol map of a.

Clone this wiki locally