| 178 | |
| 179 | |
| 180 | class Scope: |
| 181 | def __init__(self, stmts: list[BranchStatement], scope_type: ScopeType) -> None: |
| 182 | self.branch_stmts: list[BranchStatement] = stmts |
| 183 | self.scope_type = scope_type |
| 184 | self.undefined_refs: dict[str, set[NameExpr]] = {} |
| 185 | |
| 186 | def copy(self) -> Scope: |
| 187 | result = Scope([s.copy() for s in self.branch_stmts], self.scope_type) |
| 188 | result.undefined_refs = self.undefined_refs.copy() |
| 189 | return result |
| 190 | |
| 191 | def record_undefined_ref(self, o: NameExpr) -> None: |
| 192 | if o.name not in self.undefined_refs: |
| 193 | self.undefined_refs[o.name] = set() |
| 194 | self.undefined_refs[o.name].add(o) |
| 195 | |
| 196 | def pop_undefined_ref(self, name: str) -> set[NameExpr]: |
| 197 | return self.undefined_refs.pop(name, set()) |
| 198 | |
| 199 | |
| 200 | class DefinedVariableTracker: |
no outgoing calls
no test coverage detected
searching dependent graphs…