Variables represent named tokens that are accessible to their scope. They may either point to a string or, once resolved, a Group/Node. Not all variables can be resolved
| 145 | |
| 146 | |
| 147 | class Variable(): |
| 148 | """ |
| 149 | Variables represent named tokens that are accessible to their scope. |
| 150 | They may either point to a string or, once resolved, a Group/Node. |
| 151 | Not all variables can be resolved |
| 152 | """ |
| 153 | def __init__(self, token, points_to, line_number=None): |
| 154 | """ |
| 155 | :param str token: |
| 156 | :param str|Call|Node|Group points_to: (str/Call is eventually resolved to Nodes|Groups) |
| 157 | :param int|None line_number: |
| 158 | """ |
| 159 | assert token |
| 160 | assert points_to |
| 161 | self.token = token |
| 162 | self.points_to = points_to |
| 163 | self.line_number = line_number |
| 164 | |
| 165 | def __repr__(self): |
| 166 | return f"<Variable token={self.token} points_to={repr(self.points_to)}" |
| 167 | |
| 168 | def to_string(self): |
| 169 | """ |
| 170 | For logging |
| 171 | :rtype: str |
| 172 | """ |
| 173 | if self.points_to and isinstance(self.points_to, (Group, Node)): |
| 174 | return f'{self.token}->{self.points_to.token}' |
| 175 | return f'{self.token}->{self.points_to}' |
| 176 | |
| 177 | |
| 178 | class Call(): |
no outgoing calls
no test coverage detected