1.1 --- a/inspector.py Tue Aug 30 16:51:10 2016 +0200
1.2 +++ b/inspector.py Tue Aug 30 17:25:15 2016 +0200
1.3 @@ -67,11 +67,6 @@
1.4 self.in_conditional = False
1.5 self.global_attr_accesses = {}
1.6
1.7 - # Nested scope handling.
1.8 -
1.9 - self.parent_function = None
1.10 - self.propagated_names = {}
1.11 -
1.12 # Usage tracking.
1.13
1.14 self.trackers = []
1.15 @@ -917,9 +912,6 @@
1.16
1.17 # Reset conditional tracking to focus on the function contents.
1.18
1.19 - parent_function = self.parent_function
1.20 - self.parent_function = self.in_function and self.get_namespace_path() or None
1.21 -
1.22 in_conditional = self.in_conditional
1.23 self.in_conditional = False
1.24
1.25 @@ -931,34 +923,19 @@
1.26 # Track attribute usage within the namespace.
1.27
1.28 path = self.get_namespace_path()
1.29 - init_item(self.propagated_names, path, set)
1.30
1.31 self.start_tracking(locals)
1.32 self.process_structure_node(n.code)
1.33 self.stop_tracking()
1.34
1.35 - # Propagate names from parent scopes.
1.36 -
1.37 - for local in self.propagated_names[path]:
1.38 - if not local in argnames and self.trackers[-1].have_name(local):
1.39 - argnames.append(local)
1.40 - defaults.append((local, Reference("<var>")))
1.41 - self.set_function_local(local)
1.42 -
1.43 - # Exit to the parent and note propagated names.
1.44 + # Exit to the parent.
1.45
1.46 self.exit_namespace()
1.47
1.48 - parent = self.get_namespace_path()
1.49 - if self.propagated_names.has_key(parent):
1.50 - for local in self.propagated_names[path]:
1.51 - self.propagated_names[parent].add(local)
1.52 -
1.53 # Update flags.
1.54
1.55 self.in_function = in_function
1.56 self.in_conditional = in_conditional
1.57 - self.parent_function = parent_function
1.58
1.59 # Define the function using the appropriate name.
1.60
1.61 @@ -1170,14 +1147,7 @@
1.62
1.63 branches = tracker.tracking_name(n.name)
1.64
1.65 - # Find names inherited from a parent scope.
1.66 -
1.67 - if not branches and self.parent_function:
1.68 - branches = tracker.have_name(n.name)
1.69 - if branches:
1.70 - self.propagate_name(n.name)
1.71 -
1.72 - # Local or inherited name.
1.73 + # Local name.
1.74
1.75 if branches:
1.76 self.record_branches_for_access(branches, n.name, None)
1.77 @@ -1340,12 +1310,6 @@
1.78 tracker = BranchTracker()
1.79 self.trackers.append(tracker)
1.80
1.81 - # For functions created from expressions or for functions within
1.82 - # functions, propagate usage to the new namespace.
1.83 -
1.84 - if self.parent_function:
1.85 - tracker.inherit_branches(parent, names)
1.86 -
1.87 # Record the given names established as new branches.
1.88
1.89 tracker.assign_names(names)
1.90 @@ -1387,13 +1351,6 @@
1.91 self.attr_usage[self.name] = tracker.get_all_usage()
1.92 self.name_initialisers[self.name] = tracker.get_all_values()
1.93
1.94 - def propagate_name(self, name):
1.95 -
1.96 - "Propagate the given 'name' into the current namespace."
1.97 -
1.98 - path = self.get_namespace_path()
1.99 - self.propagated_names[path].add(name)
1.100 -
1.101 def record_assignments_for_access(self, tracker):
1.102
1.103 """