Refactor and fix state contexts in Rust backend #31
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This significantly refactors the generation of the state context initialization code in the Rust backend, making state contexts work correctly and consistently for all ways of entering a state (initial state, transitions, and change-states).
Previously, state contexts were only initialized correctly for transitions, which led to limitations in initial states described in #22 and in change-states, described in #27. Both of these issues are fixed.
For initial states, only state variables and exit parameters are allowed (i.e. not state parameters or enter parameters). It could be possible to also allow either state parameters or enter parameters by passing these in to the state machine constructor. However, it's not clear which of these should take precedence. Also, these features are usually only accessible in Frame, so it would be inconsistent to allow access to them from Rust for initial states. Thus, it seems like a reasonable limitation that these features are not available for initial states.
For change-states, enter and exit parameters are not allowed since these events are not triggered by a change-state.
This PR needs approval from @frame-lang since the PR includes a minor change to the parser to enable parsing state parameters on change-states.
Fixes #22
Fixes #27