-
Notifications
You must be signed in to change notification settings - Fork 1
Instance Assignment
We split the assigment statement on the assignment operator (.= or ..= in Scrall) to obtain the left and right hand sides (lhs, rhs)
We also note the cardinality of the assignment as one or many instances assigned.
Next we create a Flow_ap named tuple for the executing instance flow.
Now we need to be careful here, because an assigner does not have an executing instance. So the xi_instance_flow is None in the case of an assigner Activity.
Now we process the rhs of our statement which, in the case of an instance assignment, will always be an instance set.
We careate an instance of Instance Set which sets some initial self attributes and then we process.
(These are split out since we need some return values from process)
The self.component flow attribute represents the current input to our data flow in process. This is either the executing instance or, if this is an assigner, it is None.
The first action we parse out is a special case, so we use a boolean first_action initially set to True
Now we iterate through the components of the iset parse.
For our example, we have this:
PATH_a(hops=[R_a(rnum='R2'), R_a(rnum='R28'), N_a(name='Shaft Level'), R_a(rnum='R3'), N_a(name='Accessible Shaft Level')])
And for reference, the corresponding scrall is:
/R2/R28/Shaft Level/R3/Accessible Shaft Level
So there is only one component to the instance set which happens to be a Path_a named tuple.
Since the path begins with a '/' it requires an executing instance as the starting point. This is allowed only in a Lifecycle State or Method Activity. We can tell if the path is the very first component in the instance set that it is intending to traverse from the executing instance. So if that's the case, we verify that if we have a State activity, that State is not in an Assigner State Model, otherwise we raise an exception.
Otherwise, we execute the 'PATH_a' case which tells us to populate a Traverse Action.
The Traverse Action validates the path, raising an exception if there is any inconsistency with the user (domain) class model and then we obtain the action id as well as the output flow from the Traverse Action.
Copyright 2022, 2023, 2025 © Leon Starr under MIT Open Source License