We abuse the code generator for introspection.
| 15 | |
| 16 | |
| 17 | class TrackingCodeGenerator(CodeGenerator): |
| 18 | """We abuse the code generator for introspection.""" |
| 19 | |
| 20 | def __init__(self, environment): |
| 21 | CodeGenerator.__init__(self, environment, '<introspection>', |
| 22 | '<introspection>') |
| 23 | self.undeclared_identifiers = set() |
| 24 | |
| 25 | def write(self, x): |
| 26 | """Don't write.""" |
| 27 | |
| 28 | def enter_frame(self, frame): |
| 29 | """Remember all undeclared identifiers.""" |
| 30 | CodeGenerator.enter_frame(self, frame) |
| 31 | for _, (action, param) in iteritems(frame.symbols.loads): |
| 32 | if action == 'resolve': |
| 33 | self.undeclared_identifiers.add(param) |
| 34 | |
| 35 | |
| 36 | def find_undeclared_variables(ast): |
no outgoing calls
no test coverage detected