MCPcopy Create free account
hub / github.com/nodejs/node / TrackingCodeGenerator

Class TrackingCodeGenerator

tools/inspector_protocol/jinja2/meta.py:17–33  ·  view source on GitHub ↗

We abuse the code generator for introspection.

Source from the content-addressed store, hash-verified

15
16
17class 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
36def find_undeclared_variables(ast):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected