-
Notifications
You must be signed in to change notification settings - Fork 67
Add State Enums
This algorithm traverses a source model and adds to each state machine
definition that has a body an enum definition named State, called the
state enum.
The constants of the state enum represent the leaf states of the state
machine.
-
A list tul' of translation units in which each state machine definition that has a body has a state enum as its first member, if the transformation succeeds; otherwise an error.
For each state machine definition d that has a body:
-
Collect the leaf states of d. A leaf state is a state with no substates. Its name is the names of its enclosing states followed by its own name, joined with underscore characters. Throw an error if there are too many leaf states.
-
Construct the enumerated constants of the state enum: first
__FPRIME_UNINITIALIZED, then the leaf state names in increasing order, carrying the annotations of their state definitions. No constant has an explicit value. -
Construct the state enum with these constants and with representation type
U8if there are fewer than 256 constants,U16if fewer than 65536, andU32otherwise. -
Add the state enum as the first member of d.