1.1 --- a/inspector.py Tue Mar 07 19:21:09 2017 +0100
1.2 +++ b/inspector.py Tue Mar 07 22:21:58 2017 +0100
1.3 @@ -100,10 +100,6 @@
1.4
1.5 self.resolve()
1.6
1.7 - # Define the invocation requirements in each namespace.
1.8 -
1.9 - self.set_invocation_usage()
1.10 -
1.11 # Propagate to the importer information needed in subsequent activities.
1.12
1.13 self.propagate()
1.14 @@ -740,50 +736,44 @@
1.15
1.16 path = self.get_namespace_path()
1.17
1.18 - self.allocate_arguments(path, n.args)
1.19 + in_invocation = self.in_invocation
1.20 + self.in_invocation = None
1.21
1.22 - try:
1.23 - in_invocation = self.in_invocation
1.24 - self.in_invocation = None
1.25 + # Process the arguments.
1.26
1.27 - # Process the arguments.
1.28 -
1.29 - keywords = set()
1.30 + keywords = set()
1.31
1.32 - for arg in n.args:
1.33 - self.process_structure_node(arg)
1.34 - if isinstance(arg, compiler.ast.Keyword):
1.35 - keywords.add(arg.name)
1.36 + for arg in n.args:
1.37 + self.process_structure_node(arg)
1.38 + if isinstance(arg, compiler.ast.Keyword):
1.39 + keywords.add(arg.name)
1.40
1.41 - keywords = list(keywords)
1.42 - keywords.sort()
1.43 + keywords = list(keywords)
1.44 + keywords.sort()
1.45
1.46 - # Communicate to the invocation target expression that it forms the
1.47 - # target of an invocation, potentially affecting attribute accesses.
1.48 + # Communicate to the invocation target expression that it forms the
1.49 + # target of an invocation, potentially affecting attribute accesses.
1.50
1.51 - self.in_invocation = len(n.args), keywords
1.52 + self.in_invocation = len(n.args), keywords
1.53
1.54 - # Process the expression, obtaining any identified reference.
1.55 + # Process the expression, obtaining any identified reference.
1.56
1.57 - name_ref = self.process_structure_node(n.node)
1.58 - self.in_invocation = in_invocation
1.59 + name_ref = self.process_structure_node(n.node)
1.60 + self.in_invocation = in_invocation
1.61
1.62 - # Detect class invocations.
1.63 -
1.64 - if isinstance(name_ref, ResolvedNameRef) and name_ref.has_kind("<class>"):
1.65 - return InstanceRef(name_ref.reference().instance_of())
1.66 + # Detect class invocations.
1.67
1.68 - elif isinstance(name_ref, NameRef):
1.69 - return InvocationRef(name_ref)
1.70 + if isinstance(name_ref, ResolvedNameRef) and name_ref.has_kind("<class>"):
1.71 + return InstanceRef(name_ref.reference().instance_of())
1.72 +
1.73 + elif isinstance(name_ref, NameRef):
1.74 + return InvocationRef(name_ref)
1.75
1.76 - # Provide a general reference to indicate that something is produced
1.77 - # by the invocation, useful for retaining assignment expression
1.78 - # details.
1.79 + # Provide a general reference to indicate that something is produced
1.80 + # by the invocation, useful for retaining assignment expression
1.81 + # details.
1.82
1.83 - return VariableRef()
1.84 -
1.85 - finally:
1.86 - self.deallocate_arguments(path, n.args)
1.87 + return VariableRef()
1.88
1.89 def process_lambda_node(self, n):
1.90
1.91 @@ -1457,55 +1447,6 @@
1.92 value = ResolvedNameRef(literal_name, ref)
1.93 self.set_special(literal_name, value)
1.94
1.95 - # Functions and invocations.
1.96 -
1.97 - def set_invocation_usage(self):
1.98 -
1.99 - """
1.100 - Discard the current invocation storage figures, retaining the maximum
1.101 - values.
1.102 - """
1.103 -
1.104 - for path, (current, maximum) in self.function_targets.items():
1.105 - self.importer.function_targets[path] = self.function_targets[path] = maximum
1.106 -
1.107 - for path, (current, maximum) in self.function_arguments.items():
1.108 - self.importer.function_arguments[path] = self.function_arguments[path] = maximum
1.109 -
1.110 - def allocate_arguments(self, path, args):
1.111 -
1.112 - """
1.113 - Allocate temporary argument storage using current and maximum
1.114 - requirements for the given 'path' and 'args'.
1.115 - """
1.116 -
1.117 - # Class and module initialisation is ultimately combined.
1.118 -
1.119 - if not self.in_function:
1.120 - path = self.name
1.121 -
1.122 - init_item(self.function_targets, path, lambda: [0, 0])
1.123 - t = self.function_targets[path]
1.124 - t[0] += 1
1.125 - t[1] = max(t[0], t[1])
1.126 -
1.127 - init_item(self.function_arguments, path, lambda: [0, 0])
1.128 - t = self.function_arguments[path]
1.129 - t[0] += len(args) + 1
1.130 - t[1] = max(t[0], t[1])
1.131 -
1.132 - def deallocate_arguments(self, path, args):
1.133 -
1.134 - "Deallocate temporary argument storage for the given 'path' and 'args'."
1.135 -
1.136 - # Class and module initialisation is ultimately combined.
1.137 -
1.138 - if not self.in_function:
1.139 - path = self.name
1.140 -
1.141 - self.function_targets[path][0] -= 1
1.142 - self.function_arguments[path][0] -= len(args) + 1
1.143 -
1.144 # Exceptions.
1.145
1.146 def record_exception_handler(self):