Add next level of if/else scope that is predicated with the `predicate`. The user might have provided a predicate from a scope of higher level, which means that `predicate` might be subject to additional slicing. Apply that slicing and return the actual predicate that will be
(self, predicate)
| 185 | self._is_registration_allowed = True |
| 186 | |
| 187 | def push_predicate(self, predicate): |
| 188 | """Add next level of if/else scope that is predicated with the `predicate`. |
| 189 | The user might have provided a predicate from a scope of higher level, which means |
| 190 | that `predicate` might be subject to additional slicing. Apply that slicing and return |
| 191 | the actual predicate that will be used for slicing when entering this scope. |
| 192 | |
| 193 | The situation will happen for example in a case like this, where both predicates are |
| 194 | produced in global scope: |
| 195 | |
| 196 | pred_0 = ... |
| 197 | pred_1 = ... |
| 198 | |
| 199 | if pred_0: # push_pred(pred_0) -> returns pred_0 |
| 200 | if pred_1: # push_pred(pred_1) -> |
| 201 | # -> returns fn._conditional.slice(pred_1, predicate=pred_0) |
| 202 | |
| 203 | Parameters |
| 204 | ---------- |
| 205 | predicate : DataNode |
| 206 | Predicate guarding this scope. |
| 207 | |
| 208 | Returns |
| 209 | ------- |
| 210 | DataNode |
| 211 | Actual predicate after applying necessary slices to use it in this scope. |
| 212 | """ |
| 213 | new_pred = self.preprocess_input(predicate) |
| 214 | new_entry = _StackEntry(new_pred) |
| 215 | self._stack.append(new_entry) |
| 216 | return new_pred |
| 217 | |
| 218 | def top(self): |
| 219 | """Get the top scope in the stack""" |